if exists(select * from sysobjects where name='depart') drop table depart create table depart ( dId int, dName varchar(20) --,dNum int --要有这个列的话去掉注释就OK了 ) go
if exists(select * from sysobjects where name='view_name') drop view view_name go create view view_name as select top 100 percent name from syscolumns where id=object_id('depart') order by colorder go --select * from view_name
declare @count int select @count= count(*) from view_name where name='dnum' --print @count declare @result bit --用来存放最后结果0表示没有dnum列,1表示有