Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Exec (my_sp) to an output variable
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01191155
Message ID:
01191397
Vues:
13
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
Fil
Voir

Click here to load this message in the networking platform