Execute SQL Server scripts: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (Reverted edits by 94.27.104.213 to last version by 80.84.114.148) |
|||
Line 3: | Line 3: | ||
== Description == | == Description == | ||
With SQL Server 2000...a little bit untidy at present. This executes the script and dumps the output in the detail window. Todo: only dump the output if there's errors (and thats why I use '-b') | With SQL Server 2000...a little bit untidy at present. This executes the script and dumps the output in the detail window. Todo: only dump the output if there's errors (and thats why I use '-b') | ||
xcvbxcbxcb | |||
nbvnmn | |||
cvmnbmc | |||
ncvmn.,b | |||
ccvmn.c,vmn | |||
.vcmnc.v,n | |||
cncv,mn.cvn | |||
cncv.,mn | |||
== The Script == | == The Script == |
Revision as of 09:51, 6 May 2010
Author: bazzargh (talk, contrib) |
Description
With SQL Server 2000...a little bit untidy at present. This executes the script and dumps the output in the detail window. Todo: only dump the output if there's errors (and thats why I use '-b') xcvbxcbxcb nbvnmn cvmnbmc ncvmn.,b ccvmn.c,vmn .vcmnc.v,n cncv,mn.cvn cncv.,mn
The Script
; path to the sql command line tools ReadRegStr $R1 HKLM "SOFTWARE\Microsoft\Microsoft SQL Server\80\Tools\ClientSetup" "SQLPath" ; the computer name. obviously you can prompt for a host ReadRegStr $R2 HKLM "SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" "ComputerName" GetTempFileName $R0 ExecWait '"$R1\Binn\isql.exe" -U "some-username" -P "some-password" -S "$R2" -d master -i "some-file.sql" -o "$R0" -b' ClearErrors ; this dumps the logfile to the detail window FileOpen $R1 $R0 "r" IfErrors FileOpenFailed MoreMessages: ClearErrors FileRead $R1 $R0 IfErrors NoMoreMessages StrCpy $R0 $R0 -2 ; remove newline DetailPrint $R0 Goto MoreMessages FileOpenFailed: DetailPrint "Can't read from $R0" NoMoreMessages: FileClose $R1 ClearErrors