Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Exec (my_sp) to an output variable
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01191155
Message ID:
01191187
Views:
15
This message has been marked as the solution to the initial question of the thread.
See How to return a value from dynamicaly executed T-SQL code FAQ #8130

>
>I have a SP in one DB that needs to call a SP in another database that returns a value. The problem is that I would like for the DB name to be user-configured in the first DB.
>
>Below is a sample of how it works if the DB is hard-coded:
>
>declare @x varchar(20)
>set @x = 'LookUp_Value'
>exec [Database2].[dbo].[my_sp] @x output
>print (@x)
>
>This works fine. However, as I stated earlier, I need to make the DB name user-configurable.
>
>Here's is what I am attempting (which does not work) ...
>
>declare @db varchar(20)
>declare @x varchar(20)
>declare @exec varchar(100)
>set @db = 'Database2'
>set @x = 'LookUp_Value'
>set @exec = '[' + @db + '].[dbo].[my_sp] @x output'
>exec (@exec)
>print (@x)
>
>... any ideas?
>
>Thanks
>Doug
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform