笔记222 选择表全部列数据除了某列

笔记222 选择表全部列数据除了某列

 1 --选择表全部列数据除了某列
 2 USE [pratice]
 3 GO
 4 
 5 create view vtest
 6 as
 7 select 1 as a,2 as b ,3 as c
 8 go
 9 
10 SELECT * FROM vtest
11 
12 
13 declare @s varchar(1000)
14 
15 select @s = isnull(@s+',','') +name
16 from syscolumns
17 where id = OBJECT_ID('vtest') and name <> 'a'
18 
19 exec('select '+ @s + ' from vtest')
20 
21 drop view vtest

 

posted @ 2013-08-04 13:46 桦仔 阅读(...) 评论(...)  编辑 收藏