游标
Declare @Name varchar(40)
Declare Cur Cursor For Select b.name from syscolumns a ,sysobjects b where a.id = b.id and a.name = 'custcode'
Open Cur
Fetch next From Cur Into @Name
While @@fetch_status=0
Begin
exec ('select * from ' + @Name)
Fetch Next From Cur Into @Name
End
Close Cur
Deallocate Cur