June 27, 2008 at 8:57 am
Does anyone know how to attach an mdf using a vbs script?
The only thing i could come with was using a run to point to osql.exe and providing an answer file (attach.sql)
Option Explicit
Dim objshell
Set objshell = CreateObject("WScript.shell")
objshell.Run"""C:\Program Files\Microsoft SQL Server\90\Tools\Binn\osql"" -E -i C:\drivers\utility\scripts\attach.SQL""",0,False
Wscript.Quit
there must be a better way?
June 27, 2008 at 9:28 am
I can't provide specific help, but you might want to look at SMO. My guess would be to start with BOL and go from there.
😎
June 27, 2008 at 9:47 am
DMO/SMO is what you need to examine. You can create a handle to a SQL Server object and then perform various actions.
A few resources:
http://msdn.microsoft.com/en-us/library/ms162169.aspx
http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=259
June 29, 2008 at 10:39 pm
What is the error you are getting? There might be a problem with your shell. Have a look at microsoft books online.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply