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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Accessing a "\" server

Author  Topic 

GRAYWOLF
Posting Yak Master

106 Posts

Posted - 2008-12-03 : 02:29:15
We have servers that are running both SQL2K & 2K5. The 2K5 version is given something like \2k5. How do you tell your script to access that server?

SET @lastmediasetid = (select max(media_set_id )
from msdb.dbo.backupmediafamily @server = N'sqlserver\2K5'

I have tried it three different ways:

from sqlserver.msdb.dbo.backupmediafamily
from sqlserver\2k3.msdb.dbo.backupmediafamily
from msdb.dbo.backupmediafamily @server = N'sqlserver\2K5'


---------------------------

Working until "the morning sun sets the midnight sky on fire"!

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-12-03 : 02:46:25
You have to use either linked server or OPENROWSET for this because you want to access data in another server.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

GRAYWOLF
Posting Yak Master

106 Posts

Posted - 2008-12-03 : 02:54:59
The server is linked. It errors on the "\" in from sqlserver\2k3.msdb.dbo.backupmediafamily

I am having trouble telling it to access the dbs on that particular server.

---------------------------

Working until "the morning sun sets the midnight sky on fire"!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-03 : 03:01:50
quote:
Originally posted by GRAYWOLF

The server is linked. It errors on the "\" in from [sqlserver\2k3].msdb.dbo.backupmediafamily

I am having trouble telling it to access the dbs on that particular server.

---------------------------

Working until "the morning sun sets the midnight sky on fire"!


try like above
Go to Top of Page

GRAYWOLF
Posting Yak Master

106 Posts

Posted - 2008-12-03 : 03:20:16
Thanks, that's it....DUH!! I should have thought of that...

---------------------------

Working until "the morning sun sets the midnight sky on fire"!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-03 : 03:27:27
You're welcome
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-12-03 : 04:07:23
Oh, you are working with two instances on same server?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -