Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I find out, if database (@DataBaseName) exists?
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
00761718
Message ID:
00761724
Vues:
23
>>>Hi everybody,
>>>
>>>Is there a way to check, if the database exists? I know, how to do it for tables, but what about databases?
>>>
>>>Thanks.
>>
IF EXISTS ( SELECT * FROM INFORMATION_SCHEMA.SCHEMATA
>>			WHERE catalog_name = 'master'	)
>>	PRINT 'Yes'
>>
>Interesting. In the time you answered I found the info in the Master database SysDatabases table. Is your way better?

Yes. MS doesn't recomend to query system tables directly because they could change in the future version(s).
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform