日期:2014-05-18 浏览次数:20842 次
--不好意思 掉了个)号
declare @name nvarchar(100)
declare cur cursor for select name from sysobjects where type = 'U'
open cur
fetch next from cur into @name
WHILE @@FETCH_STATUS = 0
begin
  declare @sql nvarchar(500),@s varchar(5000)
  set @s =''
  set @sql='select @s=isnull(@s+''+'','''')+'''''',''''''+''+cast(isnull([''+name+''],'''''''') as varchar)'' from syscolumns where id=object_id('''+@name+''') and xtype in(175,239,99,231,35,167) '  
  exec sp_executesql @sql,N'@s varchar(5000) out',@s out
  if len(@s) > 0  
  exec('if exists(select 1 from (select '+ @s+' as col from ['+@name+']) b where 用户编号 in(''001'',''002'')) print '''+@name+'''')
  fetch next from cur into @name
end
close cur
DEALLOCATE cur