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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-07-16 : 09:32:28
|
| Joester writes "Is it possible to select from a table using the id of the table from sysobjects?" |
|
|
M.E.
Aged Yak Warrior
539 Posts |
Posted - 2002-07-16 : 10:08:10
|
| Really don't know why you'd want to.. but dynamic SQL would work.set a variable to the table name.. I'll call it @tablename (using sys objects to set it)set @sql = 'select * from ' +@tablenameexec(@sql)-----------------------Take my advice, I dare ya |
 |
|
|
dsdeming
479 Posts |
Posted - 2002-07-16 : 12:58:15
|
| You can pass the id to the OBJECT_NAME() function:declare @vcCommand varchar( 1000 )select @vcCommand = 'select * from ' + object_name( 194099732 )print @vcCommandexecute ( @vcCommand )However, if you know the id, shouldn't you already know the name? |
 |
|
|
|
|
|