August 19, 2011 at 8:51 am
create table #temptable(Name varchar(25))
GO
insert into #temptable values('Larry');
insert into #temptable values('Moe');
insert into #temptable values('Curley');
select * from #temptable
Name
------
Larry
Moe
Curley
I never know what the resulst will be but I want them to be column headinds
Larry Mo Curley
August 19, 2011 at 9:41 am
Column headings where? And what will be displayed under them?
August 19, 2011 at 9:45 am
The columns would be the results of the select statement
select * from #temptable
Name Larry Moe Curley
----- ----- ---- ------
Larry
Moe
Curley
August 19, 2011 at 10:05 am
Where are you going to use these columns and what kind of data will be under them?
If you want to return empty recordset with "columns" to the client application, then you should do this in the application itself, not in t-sql, as its not designed for this sort of work...
However, it can be done using dynamic sql
August 19, 2011 at 10:07 am
Data will be put in those columns from another table later. Right now i just want the columns added and have them blank
August 19, 2011 at 10:34 am
That would be very bad desing. You should not do it in T-SQL.
As to achieve it you will need to write everything in dynamic SQL for no benefits at all.
How you going to add data later on when you don't know the how many columns you will have? Dynamic SQL again...
So, do it in the client up.
Or
There are some samples on i-net:
http://www.simple-talk.com/community/blogs/andras/archive/2007/09/14/37265.aspx
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply