SQL query, excluding specified fields

Source: Internet
Author: User

Excerpt from:http://blog.163.com/[email protected]/blog/static/164628503201231925214824/
 query all fields except the specified field 
declare @name varchar (declare @sql varchar) SET @sql = ' SELECT ' Declare C11 CURSOR for select name from Sysco Lumns where id= (select Max (id) from sysobjects where xtype= ' u ' and name= ' table name ') and name <> ' except Fields ' OPEN C11 FETCH N EXT from C11 to @name IF @ @FETCH_STATUS <> 0 BEGIN deallocate C11 RETURN END while (@ @FETC H_status = 0) BEGIN SET @[email protected][email protected]+ ', ' FETCH NEXT from C11 into @name END deallocate C11 Set @sql =substring (@sql, 1,len (@sql)-1) + ' from table name ' EXEC (@sql) 
--Query all fields in a tableselect name from syscolumns where id= (select Max (id) from sysobjects where xtype= ' u ' and name= ' table name ')

SQL query, excluding specified fields

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.