[SQLServer]Stored Procedure サンプル
- 2008 2/28
- 投稿者 : flied_onion
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
declare @tn nvarchar(40) declare @cln nvarchar(40) declare @sql nvarchar(200) declare ca Cursor for select syscolumns.name,sysobjects.name from sysobjects,syscolumns where sysobjects.xtype='U' and sysobjects.id=syscolumns.id and syscolumns.name like '%Employ%' OPEN ca Fetch next from ca into @cln,@tn WHILE(@@fetch_status = 0) begin --exec sp_executesql N'select ' + @cln + N' from ' + @tn; set @sql = 'select ' + @cln + ' from ' + @tn + ' where ' + @cln + ' is not null'; exec sp_executesql @sql; print @sql Fetch next from ca into @cln,@tn end close ca deallocate ca |
最近のコメント