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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Dynamic SQL and function

Author  Topic 

hennie7863
Starting Member

12 Posts

Posted - 2004-10-06 : 05:07:08
Hi i have a problem i have the following Trans SQL statement in a function

SET @desc= (Select description From table Where id = @id)

Now i want to make table dynamic. Something like this

SET @desc= (Select description From @table Where id = @id)

Yeah yeah i know i can't do this:

SET @desc= EXEC('Select description From '+ @table + ' Where id = '+ @id)
is not possible

Writing to a temporary table is prohibited by functions. But i need a function because i want to use the result in a query..

Can someone help me?

Hennie


spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-10-06 : 05:22:32
you can write it to a table variable ...
declare @MyTable table (column definitions...)


Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -