Hi everyone,
On daily basis I need to generate excerpts by mean of Excel. Prior to sql25k I used to play with Enterprise Manager and pick up the name of all the columns for a table very easily doing this
select top 1 f1,f2,-.. from table
nameage
enric80
How do I such thing from Sql Management Studio?
It's a silly thing, I know, but it's very useful for me because when I've got those columns then I can do paste them perfectly into .XLS.
Otherwise I see forced to write one by one and sometimes tables have more than 60 columns
It's not useful generate a CREATE TABLE script or launch SP_HELP <MYTABLE> because I obtain the name of the columns in vertical no horizontal.
Thanks a lot!!!
Hi Enric
How about this:
EXEC sp_columns @.table_name = 'customers'
Give it a try
Rgds,
Worf
|||select * from information_schema.columnswhere table_name = 'customers'|||
Hi guys,
It doesn't useful at all for me. I'm looking for a way which allow me get the columns in horizontal way, just for copy them:
f1 f2 f3 f4
TIA
|||I gotcha..you can do the same thing in Managment Studio. Just create a new query, and type in:
select top 1 * from Table
that will give you the fields that you want.
|||hi there,
Ok, setting "results as text" in results panel.
Thanks
|||Declare @.columns nvarchar(max)
Select @.columns = IsNull(@.columns + ', ', '') + column_name
From information_schema.columns
Where table_name = 'customers'
Select @.columns
-- or
Print @.columns
No comments:
Post a Comment