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 @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 @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
After adding shortcuts, in the query analyzer, select a table name, press the corresponding shortcut, cool.