In Query Analyzer, use the shortcut key to get the list of fields.

Source: Internet
Author: User
Tags key query table name
Query Analysis | Using shortcut keys
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

After adding the shortcut key, in Query Analyzer, select a table name, press the corresponding shortcut key, cool bar.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.