Posted by Erland Sommarskog on 12/20/06 22:53
fireball (fireball@onet.kropka.eu) writes:
> which is more proper:
> if DB_ID(@db) IS NOT NULL
> or
> IF EXISTS (SELECT name FROM sys.databases WHERE name = @db)
> ?
Whichever you fancy. I would probably write the second nine times out
of ten, but that it would only be because db_id() would not come in
my mind. And a nice characteristic of the first, is that it works on
SQL 2000 as well.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
[Back to original message]
|