|
-
Jul 22nd, 2010, 04:43 AM
#1
Thread Starter
Fanatic Member
SQLCMD: call SP add param as contents of a file
Hi,
I'd like to use SQLCMD to update my database. I've created a SP and am now trying to figure out how to supply one of the parameters as a variable/contents of a file, is this possible?
I'm using SQL Server '05
Code:
sqlcmd -S server -U uname -P pwd /d mydb -h-1 -s"" -W /Q "exec up_gNewEmail 'This is my subject', 'This is my email body'" -o out.log
Any help will be greatly appreciated.
Cheers Al
Last edited by aconybeare; Jul 22nd, 2010 at 06:48 AM.
Reason: Misspelt the command (slap)
-
Jul 22nd, 2010, 06:47 AM
#2
Thread Starter
Fanatic Member
Re: SQLCMD: call SP add param as contents of a file
Think I've got it, however it's not going to work for me because newlines are replaced with slashes "/". I can't be sure that if I replace the slashes in my SP with newlines that I won't removing legitamate slashes.
Code:
@echo off
setlocal enabledelayedexpansion
set SEPARATOR=/
set filecontent=
for /f "delims=" %%a in (myBody.txt) do (
set currentline=%%a
set filecontent=!filecontent!%SEPARATOR%!currentline!
)
echo The file contents are: %filecontent%
sqlcmd -S server -U uname -P pwd /d mydb -h-1 -s"" -W /Q "exec up_gNewEmail 'This is my subject','%filecontent%'" -o out.log
I'm now considering executing this thing using vbscript ".vbs"
e.g. cscript updateMyDbAndSendMyEmail.vbs
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|