Coming from this thread, I hve dug around and it doesn't seem possibl to do it through ps, so I decided to go back to vbscript and try to execute the sql file.
I have a script that should work, more or less. But it only connects to the database, without choosing a table to write to.
I don't know if it will actually work if I "choose" a table to write to, maybe some of you guys can help me out
Any help appreciated!
I have a script that should work, more or less. But it only connects to the database, without choosing a table to write to.
I don't know if it will actually work if I "choose" a table to write to, maybe some of you guys can help me out
Code:
Option Explicit
Dim objFSO, strTextFile, strData, strLine, arrLines, mConnection, filestream
CONST ForReading = 1
strTextFile = "C:\file.sql"
Set objFSO = CreateObject("Scripting.FileSystemObject")
set filestream = objFSO.OpenTextFile(strTextFile,ForReading,false,-1)
Function WriteToDatabase(sUserName)
Set mConnection = CreateObject("ADODB.Connection")
mConnection.Open "Provider=SQLOLEDB.1;Data Source=sqlserver\instance;Initial Catalog=mydb","user","password"
do while not filestream.atendofstream
strData = filestream.readline
mConnection.Execute strData
loop
Set mConnection = Nothing
End Function
Any help appreciated!