Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL statement won't run in ASP! HELP!

Status
Not open for further replies.

jbarron14

Technical User
Aug 7, 2000
2
US
I have this SQL statement:<br><br><br>drop table #tmp<br>go<br><br>select<br> substring(system_source_descr,1,15) 'Platform',<br> substring(system_id_type,1,15) 'ID_Type',<br> substring(person_source_descr,1,25) 'Person_Source', &quot;ID_Linked&quot; = <br><br>CASE<br> WHEN no_person_flg IS NULL THEN 'ID Not Linked' <br> WHEN no_person_flg = ''&nbsp;&nbsp;&nbsp;&nbsp;THEN 'ID Not Linked' <br> WHEN no_person_flg = 'Y'&nbsp;&nbsp;&nbsp;THen 'ID Not Linked'<br> WHEN no_person_flg&nbsp;&nbsp;= 'N'&nbsp;&nbsp;&nbsp;THEN 'ID Linked' ELSE 'ID Not Linked'<br>END&nbsp;&nbsp;<br><br>into #tmp&nbsp;&nbsp;<br><br>&nbsp;&nbsp;&nbsp;from cdr_master_xref<br>&nbsp;&nbsp;&nbsp;where&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;system_id_status_flg not in ('I','X','Z')<br><br><br>Select Platform,<br> ID_Type,<br> ID_Linked,<br> Person_Source,<br> count(*) <br><br>&nbsp;&nbsp;&nbsp;from #tmp<br><br>&nbsp;&nbsp;&nbsp;group by Platform,<br> ID_Type,<br> ID_Linked,<br> Person_Source<br><br><br><br>and in VB Script I use the SQL statement in an ASP as follows:<br><br><br>&nbsp;&nbsp;&nbsp;SQLStmt.CommandText = &quot;drop table #tmp&quot; &_<br>&quot; go&quot; &_<br>&quot; select&quot; &_<br>&quot; substring(system_source_descr,1,15) 'Platform',&quot; &_<br>&quot; substring(system_id_type,1,15) 'ID_Type',&quot; &_<br>&quot; substring(person_source_descr,1,25) 'Person_Source', &quot; & chr(34) & &quot;ID_Linked&quot; & chr(34) & &quot; =&quot; &_<br>&quot; CASE&quot; &_<br>&quot; WHEN no_person_flg IS NULL THEN 'ID Not Linked'&quot; &_<br>&quot; WHEN no_person_flg = ''&nbsp;&nbsp;&nbsp;&nbsp;THEN 'ID Not Linked'&quot; &_<br>&quot; WHEN no_person_flg = 'Y'&nbsp;&nbsp;&nbsp;THen 'ID Not Linked'&quot; &_<br>&quot; WHEN no_person_flg&nbsp;&nbsp;= 'N'&nbsp;&nbsp;&nbsp;THEN 'ID Linked' ELSE 'ID Not Linked'&quot; &_<br>&quot; END&quot; &_ <br>&quot; into #tmp&quot;&nbsp;&nbsp;&_<br>&quot;&nbsp;&nbsp;&nbsp;from cdr_master_xref&quot; &_<br>&quot;&nbsp;&nbsp;&nbsp;where&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;system_id_status_flg not in ('I','X','Z')&quot; &_<br>&quot; Select Platform,&quot; &_<br>&quot; ID_Type,&quot; &_<br>&quot; ID_Linked,&quot; &_<br>&quot; Person_Source,&quot; &_<br>&quot; count(*)&quot; &_<br>&quot;&nbsp;&nbsp;&nbsp;from #tmp&quot; &_<br>&quot;&nbsp;&nbsp;&nbsp;group by Platform,&quot; &_<br>&quot; ID_Type,&quot; &_<br>&quot; ID_Linked,&quot; &_<br>&quot; Person_Source&quot;<br>SQLStmt.CommandType = 1<br>Set SQLStmt.ActiveConnection = OBJdbConnection <br>RS.Open SQLStmt<br><br><br>For some reason I get the error message:&nbsp;&nbsp;<br><br>Microsoft OLE DB Provider for ODBC Drivers error '80040e14' <br>[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 'go'. <br><br>/newtotal.asp, line 97 <br><br><br>Does anyone have any ideas why this isn't working?&nbsp;&nbsp;Any advice is appreciated.<br><br>Thanks,<br>John
 
I don't think &quot;GO&quot; is a valid keyword when you are passing the statement thru ASP.&nbsp;&nbsp;In fact, I'm pretty sure of it.<br><br>If you want to use the &quot;GO&quot; keyword you have to make your SQL statement into a stored procedure and call the stored procedure.<br><br><br> <p> Jeff Friestman<br><a href=mailto: > </a><br><a href= View my Brainbench transcript</a><br>Brainbench 'Most Valuable Professional' for ASP<br>
Brainbench 'Most Valuable Professional' for JavaScript<br>
 
Thanks for the help.&nbsp;&nbsp;That error was driving me crazy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top