Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Using a table as a variable

Author  Topic 

hubschrauber
Starting Member

16 Posts

Posted - 2006-03-17 : 10:21:24
Is this possible ?


DECLARE @item nvarchar(50)
DECLARE @tabel varchar (50)

SET @item = 'ZVIN'
SET @tabel = 'u_tbl_inhuizen_openstaand_nw_deze_week'

select * from @tabel as tt where itemtype = @item

nr
SQLTeam MVY

12543 Posts

Posted - 2006-03-17 : 10:48:47
exec ('select * from ' + @tabel + ' as tt where itemtype = ''' + @item + '''')

With the asociated performance and security risks.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -