Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Dynamically create column headers in a SELECT stat

Author  Topic 

ssingh
Starting Member

25 Posts

Posted - 2001-09-12 : 08:14:00
I'm writing a stored procedure in which I pass a year(int) like 2002. In the stored proc I need to display the data in a table which will have column names as
SCORES 2002, SCORES 2001 etc.
I want to pass @year parameter to the stored proc and then append it to 'SCORES '. Something like:

SELECT
[scores_current] AS 'SCORES ' + CAST((@year) AS VARCHAR(4))
...
..
INTO FINAL_TBL
FROM #temp_tbl

But it is not working. Please let me know if there is a way to do it.


   

- Advertisement -