April 7, 2006 at 4:36 am
is there some way to allow this to execute, using a function or something?:
select * from 'cusomer'
you see i have a list of about 300 table name in string format, and i want to use a cursor to itterate through each table, but as all the table names are in string format i cant get it done. any ideas??
April 7, 2006 at 4:51 am
--You can run this in QA
Declare @tablename varchar(50)
Declare @SQLCommand varchar(350)
Declare Cursor1 Cursor Static ForWard_Only For
select sysobjects.name
FROM sysobjects
WHERE sysobjects.type = 'U'
Open Cursor1
Fetch Next From Cursor1 Into @TableName
While @@Fetch_status = 0
Begin
select @TableName
Select @SQLCommand = 'Select * from '+ ltrim(rtrim(@TableName))
exec( @SQLCommand)
Fetch Next From Cursor1 Into @TableName
End -- While Fetch
Close Cursor1
Deallocate Cursor1
------------
When you 've got a hammer, everything starts to look like a nail...
April 7, 2006 at 4:58 am
thank you. very helpful. much appriciated.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply