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
 SQL Server Development (2000)
 Dynamic Sql

Author  Topic 

mohd_javedk
Starting Member

1 Post

Posted - 2002-07-03 : 04:30:54
I want to execute Dnyamic sql satement and want to store result into variable
What i am doing explaining here

Declare @Rtable nvarchar(10)
Declare @Txt nvarchar(110)
Declare @User nvarchar(20)
Set @Rtable='DayType'
Set @Txt='Select UserId From '+ @Rtable + ' Where DayTypeNb=1'
exec @User= spExecDynSQL @Txt

The SpExecDynSql sp executing perfectly @Txt statememt but that's unable to set the return value into @User, i am getting empty

CREATE PROCEDURE spExecDynSQL
@SQL nvarchar ( 100 )
AS

EXEC ( @SQL )


GO



macka
Posting Yak Master

162 Posts

Posted - 2002-07-03 : 04:49:37
This should help:

[url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=14763[/url]

macka.

Go to Top of Page
   

- Advertisement -