SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 OPENROWSET Query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Ads
Starting Member

23 Posts

Posted - 05/03/2012 :  06:26:08  Show Profile  Reply with Quote
Hi,

I have an OPENROWSET query which isnt working as it did on server 2000.

I'm now seing an error: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'WHERE'.

The code I am using:

<%
Dim rsSelectOrder
Dim rsSelectOrder_numRows

Set rsSelectOrder = Server.CreateObject("ADODB.Recordset")
rsSelectOrder.ActiveConnection = MM_conn_to_mhwebdb_STRING
rsSelectOrder.Source = "SELECT * from " &ActinicPersonsNew&" "&ActinicOrdersNew&" WHERE [Contact ID] = [Invoice Contact ID] AND [Order Number] NOT IN ( SELECT OrderNumber from dbo.tbl_QuasarOrdersEntered)"
rsSelectOrder.CursorType = 0
rsSelectOrder.CursorLocation = 2
rsSelectOrder.LockType = 1
rsSelectOrder.Open()

rsSelectOrder_numRows = 0
%>

Thanks

Ads

sunitabeck
Flowing Fount of Yak Knowledge

5152 Posts

Posted - 05/03/2012 :  07:22:46  Show Profile  Reply with Quote
What I would suggest is to print out the query and see if you can execute it from an SSMS window. It seems to me that your query is something like:
SELECT * from ActinicPersonsNew ActinicOrdersNew WHERE [Contact ID] ....
May be you need a comma somewhere in there?
rsSelectOrder.Source = "SELECT * from " &ActinicPersonsNew&" ,"&ActinicOrdersNew&" WHERE [Contact ID] = [Invoice Contact ID] AND [Order Number] NOT IN ( SELECT OrderNumber from dbo.tbl_QuasarOrdersEntered)"
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8529 Posts

Posted - 05/03/2012 :  07:23:50  Show Profile  Visit webfred's Homepage  Reply with Quote
Are

ActinicPersonsNew
ActinicOrdersNew

two tables?
If so then a comma is missing.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8529 Posts

Posted - 05/03/2012 :  07:24:18  Show Profile  Visit webfred's Homepage  Reply with Quote



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Ads
Starting Member

23 Posts

Posted - 05/03/2012 :  09:08:24  Show Profile  Reply with Quote
Thanks,


ActinicPersonsNew and ActinicOrdersNew were pointing at the incorrect file! plus the comma missing.

Cheers
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000