Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return servername and default DB from system DSN name

Status
Not open for further replies.

spangeman

Programmer
Oct 16, 2004
96
EU
Hello

I need to run a BCP command, but only know the DSN name at the time of running it. Looking around the web I can see no way of using a DSN name with BCP.

Therefore I need to extract the server name and default DB of the system DSN within my C# app.

Any ideas of how I could do this?

Regards
Spangeman
 
I found a SQL solution to this instead. Logged into the DSN using either an ADO.net or OSQL you can excute the following SQL:-

SELECT CURRENTDB = (SELECT name FROM master.dbo.sysdatabases where dbid in (SELECT distinct DB_ID() AS DB_ID FROM master.dbo.sysdatabases))

SELECT CURRENTSERVER = (SELECT @@servername)


Regards
Spangeman

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top