use pubs
 
if exists (select * from sysobjects where name='a')
drop table aselect top 5 * into a from syscolumns where id=object_id('titles')     --以显示titles前5列为例。declare @exec varchar(8000)
set @exec=''
select @exec=@exec+','+ name from a where id=object_id('titles')
set @exec=substring(@exec,2,8000)
print @exec---结果
/*
(所影响的行数为 5 行)title_id,title,type,pub_id,price
*/select title_id,title,type,pub_id,price from titles--结果
/*
title_id   title                                  type         pub_id     price
-------------------------------------------------------------------------------------
BU1032 The Busy Executive's Database Guide business     1389 19.9900
BU1111 Cooking with Computers: Surreptitious Balance Sheets business     1389 11.9500
BU2075 You Can Combat Computer Stress! business     0736 2.9900
BU7832 Straight Talk About Computers business     1389 19.9900
MC2222 Silicon Valley Gastronomic Treats mod_cook     0877 19.9900
MC3021 The Gourmet Microwave mod_cook     0877 2.9900
MC3026 The Psychology of Computer Cooking UNDECIDED    0877 NULL
PC1035 But Is It User Friendly? popular_comp 1389 22.9500
PC8888 Secrets of Silicon Valley popular_comp 1389 20.0000
PC9999 Net Etiquette popular_comp 1389 NULL
PS1372 Computer Phobic AND Non-Phobic Individuals: Behavior Variations psychology   0877 21.5900
PS2091 Is Anger the Enemy? psychology   0736 10.9500
PS2106 Life Without Fear psychology   0736 7.0000
PS3333 Prolonged Data Deprivation: Four Case Studies psychology   0736 19.9900
PS7777 Emotional Security: A New Algorithm psychology   0736 7.9900
TC3218 Onions, Leeks, and Garlic: Cooking Secrets of the Mediterranean trad_cook    0877 20.9500
TC4203 Fifty Years in Buckingham Palace Kitchens trad_cook    0877 11.9500
TC7777 Sushi, Anyone? trad_cook    0877 14.9900
*/