Information générale
Forum:
Microsoft SQL Server
Versions des environnements
SQL Server:
SQL Server 2000
It's neat to see how the process for assigning stars has been removed from the original poster.
A great time saver.
>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
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement