query using variable | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

query using variable

hi,
Here is my table data.
ShiftID Name StartTime EndTime ModifiedDate
——- ————————————————– ———————– ———————– ———————–
1 Day 1900-01-01 07:00:00.000 1900-01-01 15:00:00.000 1998-06-01 00:00:00.000
2 Evening 1900-01-01 15:00:00.000 1900-01-01 23:00:00.000 1998-06-01 00:00:00.000
3 Night 1900-01-01 23:00:00.000 1900-01-01 07:00:00.000 1998-06-01 00:00:00.000 ColumnName
I want to o/p of the query in the form of evening,night,day
ratherthan
Columnname
evening
night
day
how to get the query in the above format using variable
Thanks,
Ravi

Why are you asking specifically about using a variable?
This can be resolved with a cross-tab query. Check out the "PIVOT" syntax in Books Online, or use Excel or Access to do a TRANSFORM (which will be a lot easier to set up than PIVOT).

]]>

Software Reviews | Book Reviews | FAQs | Tips | Articles | Performance Tuning | Audit | BI | Clustering | Developer | Reporting | DBA | ASP.NET Ado | Views tips | | Developer FAQs | Replication Tips | OS Tips | Misc Tips | Index Tuning Tips | Hints Tips | High Availability Tips | Hardware Tips | ETL Tips | Components Tips | Configuration Tips | App Dev Tips | OLAP Tips | Admin Tips | Software Reviews | Error | Clustering FAQs | Performance Tuning FAQs | DBA FAQs |