Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Q on batch processing multi update sql statemens
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

bjlt
Senior Member

1144 Posts

Posted - 05 November 2003 :  05:58:47  Show Profile
My question is, is it possible to batch processing multiple update statemens in one conn.execute? if so, how to write the line break (\n) in vbscript?



strSQL=strSQL&"UPDATE TEST SET A = 1 WHERE ID = 1\n"; 
strSQL=strSQL&""UPDATE TEST SET B = 3 WHERE ID = 2\n"; 
oConn.Execute(strSQL); 

=
sSql = "UPDATE TEST " &_
	"SET A = 1" &_
	" WHERE ID = 4866" & vbCrLf &_
sSql = sSql & "UPDATE TEST " &_
	"SET A = 1" &_
	" WHERE ID = 4867"
my_Conn.Execute (sSql)

this generates an error.


Thanks in advance.

DavidRhodes
Senior Member

United Kingdom
1222 Posts

Posted - 05 November 2003 :  06:07:15  Show Profile
try seperating the statements with a ;

strSQL = strSQL & "UPDATE TEST SET A = 1 WHERE ID = 1;"
strSQL = strSQL &" UPDATE TEST SET B = 3 WHERE ID = 2;"
oConn.Execute(strSQL)

The UK MkIVs Forum
Go to Top of Page

bjlt
Senior Member

1144 Posts

Posted - 05 November 2003 :  14:03:47  Show Profile
Thanks.
I get an error still. saying something like: found string after the sql statement when ; is added.
I tested on access, btw.
Go to Top of Page

pweighill
Junior Member

United Kingdom
453 Posts

Posted - 05 November 2003 :  14:54:36  Show Profile
sSql = "UPDATE TEST SET A=1 WHERE ID=4866" & vbCrLf
sSql = sSql & "UPDATE TEST SET A=1 WHERE ID=4867"
my_Conn.Execute (sSql)

Should work with MS SQL Server, but might not with Access.

You could always try:
sSql = "UPDATE TEST SET A=1 WHERE ID IN (4866,4867)"

Edited by - pweighill on 05 November 2003 14:55:40
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.25 seconds. Powered By: Snitz Forums 2000 Version 3.4.07