在查询分析器中,用快捷键取得字段的列表。
ALTER procedure sp_getfields @tablename varchar(100) as declare tmpCursor cursor for select name from syscolumns where id = Object_ID(@tablename) open tmpCursor declare @fieldname varchar(50) declare @ sql str1 varchar(250) declare @sqlstr
ALTER procedure sp_getfields
@tablename varchar(100)
as
declare tmpCursor cursor for
select name from syscolumns where id = Object_ID(@tablename)
open tmpCursor
declare @fieldname varchar(50)
declare @
sqlstr1 varchar(250)
declare @sqlstr2 varchar(250)
set @fieldname = ''
set @sqlstr1 = ''
set @sqlstr2 = ''
fetch next from tmpCursor into @fieldname
while @@fetch_status = 0
begin
if len(@sqlstr1) < 250 - len(@fieldname)
set @sqlstr1 = @sqlstr1 + @fieldname + ','
else
set @sqlstr2 = @sqlstr2 + @fieldname + ','
fetch next from tmpCursor into @fieldname
end
close tmpCursor
Deallocate tmpCursor
if @sqlstr2 = ''
set @sqlstr1 = left(@sqlstr1, len(@sqlstr1) -1)
else
set @sqlstr2 = left(@sqlstr2, len(@sqlstr2) -1)
select @sqlstr1
if @sqlstr2 <> ''
select @sqlstr2
加了快捷键后,在查询分析器中,选中一个表名,按相应的快捷键,酷吧。
原文转自:http://www.ltesting.net
|