Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Identifying database for a specific command
Message
 
 
À
22/03/2011 14:49:51
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Scripting
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01504553
Message ID:
01504555
Vues:
50
This message has been marked as the solution to the initial question of the thread.
>If I have the following command:
>
>
>IF EXISTS(SELECT 1 FROM sys.objects WHERE OBJECT_ID = OBJECT_ID(N'MyTable') AND type = (N'U')) PRINT 'TEST'
>
>
>How can I adjust it to have it bound to another database then the one the script window is defaulting to?
IF EXISTS (select 1 from myDB.sys.Objects WHERE OBJECT_ID = OBJECT_ID(N'MyTable') AND type = (N'U')) PRINT 'TEST'
Alternatively,
IF EXISTS (select 1 from MyDB.INFORMATION_SCHEMA.Tables where TABLE_Name = 'MyTable') PRINT 'TEST'
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform