Tables

in SQL 2014 can i divide one column into more than one with the same name in the header of the column. like this

The header name of the table

anything related to the header anything related to the header anything related to the header
anything related to the header
February 5th, 2015 4:48pm

Right-click on the Row handle and Add row above the existing header row of the tablix. Add as many columns as you need in the tablix. Select all the cells from the topmost header row, right-click and select 'Merge Cells'.

-Hope this helps.

Free Windows Admin Tool Kit Click here and download it now
February 5th, 2015 4:56pm

Not really clear what you're asking, but my guess is that in the table, no you cannot, columns must have unique names, and if you understand first normal form you know you can't have (and shouldn't want!) repeating columns in a table.

But as the results of a query, maybe you can, look at "pivot tables" and see if that's what you're after, can be produced by TSQL in SQL Server or from a standard table and query by using something like Excel.

Or just in any query you can put anything you want, even the same value, at the head of every column:

select
1 as 'foo', 2 as 'foo'
Or if you want to "snake" results in four columns across a page, ... hmm, ... not directly in TSQL, no, the only way I'd think of doing that would be to output the data as text and then use Word to snake it.

Josh


  • Edited by JRStern 10 hours 26 minutes ago
February 5th, 2015 8:05pm

Hello

I am not sure if I understand your issue but I think you want to split the value of one column to have multiple ones.

you can use the LEFT, RIGHT, SUBSTRING functions to accomplish that

http://social.technet.microsoft.com/wiki/contents/articles/17948.t-sql-right-left-substring-and-charindex-functions.aspx

select left(NAME,2), SUBSTRING(NAME,2,100), RIGHT(NAME,4) from MyTable

Regards

Free Windows Admin Tool Kit Click here and download it now
February 5th, 2015 10:06pm

Is this a SSRS requirement? Otherwise didnt understand relevance of header etc

February 6th, 2015 12:58am

Not really clear what you're asking, but my guess is that in the table, no you cannot, columns must have unique names, and if you understand first normal form you know you can't have (and shouldn't want!) repeating columns in a table.

But as the results of a query, maybe you can, look at "pivot tables" and see if that's what you're after, can be produced by TSQL in SQL Server or from a standard table and query by using something like Excel.

Or just in any query you can put anything you want, even the same value, at the head of every column:

select
1 as 'foo', 2 as 'foo'
Or if you want to "snake" results in four columns across a page, ... hmm, ... not directly in TSQL, no, the only way I'd think of doing that would be to output the data as text and then use Word to snake it.

Josh


  • Edited by JRStern Friday, February 06, 2015 1:01 AM
Free Windows Admin Tool Kit Click here and download it now
February 6th, 2015 4:00am

There is no such construct in the T-SQL language. But if you are using a tool (such as Reporting Services), then there might be such constructs - check with the tool you are using.
February 6th, 2015 4:33am

Hi Taymour.Lank.Farawilla,

As per my understanding, you want to divide one column into more than one then use the same column name in column header. To achieve the goal, we can use merge cells in Reporting Services of SQL Server.

To split the value of one column to multiple columns, we can use LEFT, RIGHT, SUBSTRING functions as Javier mentioned. For detail information, please refer to the following steps:

  1. Create a Report Server Project with Business Intelligence Development Studio(BIDS) or SQL Server Data Tools(SSDT).
  2. Create a new report definition file.
  3. Create data source and dataset to retrieve data for the report.
  4. In the Toolbox, click Table, and then click on the design surface and drag the mouse.
  5. Right-click column handle, then click expression, type the expression like below to get part of the column value:

=Split(Fields!EnglishProductName.Value,",").GetValue(0)

  6. Select the columns you want to merge, click Merge cells, then type column name.

The following screenshots are for your reference:

For more information about Creating a Report Server Project, please refer to the following document:
https://msdn.microsoft.com/en-us/library/ms167559.aspx

If you have any more questions, please feel free to ask.

Thanks,
Wendy Fu

Free Windows Admin Tool Kit Click here and download it now
February 9th, 2015 3:11am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics