Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
insanepaul
Posting Yak Master
178 Posts |
Posted - 2008-12-14 : 13:54:14
|
| I use a linked server to programmatically send data from 1 server to a remote server.However on occasion the database on the remote server may actually reside on the same server. If this is true then there is no point in opening a linked server.I've noticed that all the database's have a unique name. So I think all I have to do is search the existing server for the database name.How would I do this? |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2008-12-14 : 14:00:49
|
| SQL 2000:IF EXISTS(SELECT 1 FROM master..sysdatabases WHERE name = 'Your database name') -- Do somethingSQL 2005/2008IF EXISTS(SELECT 1 FROM sys.databases WHERE name = 'Your database name') -- Do something--Gail ShawSQL Server MVP |
 |
|
|
insanepaul
Posting Yak Master
178 Posts |
Posted - 2008-12-14 : 15:09:42
|
quote: Originally posted by GilaMonster SQL 2000:IF EXISTS(SELECT 1 FROM master..sysdatabases WHERE name = 'Your database name') -- Do somethingSQL 2005/2008IF EXISTS(SELECT 1 FROM sys.databases WHERE name = 'Your database name') -- Do something--Gail ShawSQL Server MVP
Thats great thanks |
 |
|
|
|
|
|