Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Error 7320.......Using linked servers

Author  Topic 

flextera
Yak Posting Veteran

50 Posts

Posted - 2014-09-17 : 15:13:49
Msg 7320, Level 16, State 2, Procedure selectlogHistory, Line 68
Cannot execute the query "SELECT Tbl1001.DateTime Col1009,Tbl1001.TagName Col1010,Tbl1001.Value Col1011 FROM Runtime.dbo.AnalogHistory Tbl1001 WHERE Tbl1001.TagName=? AND Tbl1001.DateTime=? AND Tbl1001.wwRetrievalMode=N'Delta'" against OLE DB provider "INSQL" for linked server "INSQL".


I get this error message when running a query. Keep in mind that this query is using linked servers in SQL.

Thanks in advance

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-09-17 : 15:28:33
Show us the actual query and not just the error.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

flextera
Yak Posting Veteran

50 Posts

Posted - 2014-09-17 : 15:49:16
I'm not looking for a fix in my query code. I am looking for information regarding this certain error.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-09-17 : 16:07:47
My point is that we need to see the query in order to help you with the error.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

flextera
Yak Posting Veteran

50 Posts

Posted - 2014-09-17 : 16:50:47
Here is my stored procedure
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-09-17 : 16:56:30
I don't see INSQL anywhere in that stored procedure.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

flextera
Yak Posting Veteran

50 Posts

Posted - 2014-09-17 : 16:59:32
Exactly why this is so confusing...
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-09-17 : 17:12:57
quote:
Originally posted by flextera

Msg 7320, Level 16, State 2, Procedure selectlogHistory, Line 68
Cannot execute the query "SELECT Tbl1001.DateTime Col1009,Tbl1001.TagName Col1010,Tbl1001.Value Col1011 FROM Runtime.dbo.AnalogHistory Tbl1001 WHERE Tbl1001.TagName=? AND Tbl1001.DateTime=? AND Tbl1001.wwRetrievalMode=N'Delta'" against OLE DB provider "INSQL" for linked server "INSQL".


I get this error message when running a query. Keep in mind that this query is using linked servers in SQL.

Thanks in advance

Are there two stored procedures in play here? The error message is coming from line 68 of stored proc named selectlogHistory, and the code you have posted is for the stored procedure selectAnalogHistory (And which you deleted now :)
Go to Top of Page

flextera
Yak Posting Veteran

50 Posts

Posted - 2014-09-17 : 17:17:16
No. There are definitely not two stored procedures running.

I deleted it because I didn't want to much ex-poser of world class stored procedures.
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-09-17 : 17:38:06
quote:
Originally posted by flextera

No. There are definitely not two stored procedures running.

I deleted it because I didn't want to much ex-poser of world class stored procedures.



You're kidding right?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-09-17 : 17:57:28
quote:
Originally posted by flextera

world class stored procedures.





Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

flextera
Yak Posting Veteran

50 Posts

Posted - 2014-09-18 : 08:52:31
Of course I'm kidding. I deleted it on accident. All I want is information regarding "Msg 7320, Level 16, State 2" And what could be causing this error.
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-09-18 : 09:24:57
Your query uses a three-part database identifier, "Runtime.dbo.AnalogHistory". Normally a linked server would have four parts:

server.database.schema.table

Is Runtime a database? If not, what is it exactly?
Go to Top of Page

flextera
Yak Posting Veteran

50 Posts

Posted - 2014-09-18 : 10:07:45
Runtime is a database. AnalogHistory is a view. Runtime is the database that I get all my tables and views from.


BUT Runtime is one of the many databases in the master.
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-09-18 : 10:19:43
fine, so your query is NOT using a linked server, is it?
Go to Top of Page

flextera
Yak Posting Veteran

50 Posts

Posted - 2014-09-18 : 10:25:47
I believe it is. It's grabbing information from a linked historian.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-09-18 : 10:44:31
Are there any triggers on the tables involved in the stored procedure? I can't remember if I saw any DML commands in it.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

flextera
Yak Posting Veteran

50 Posts

Posted - 2014-09-18 : 10:48:21
I don't believe so.
Go to Top of Page

flextera
Yak Posting Veteran

50 Posts

Posted - 2014-09-18 : 10:51:33
OLE DB provider "INSQL" for linked server "INSQL" returned message "Error: parameter 2 is NULL in a parameterized SQL query.".
Msg 7320, Level 16, State 2, Procedure selectAnalogHistory, Line 68
Cannot execute the query "SELECT Tbl1001.DateTime Col1009,Tbl1001.TagName Col1010,Tbl1001.Value Col1011 FROM Runtime.dbo.AnalogHistory Tbl1001 WHERE Tbl1001.TagName=? AND Tbl1001.DateTime=? AND Tbl1001.wwRetrievalMode=N'Delta'" against OLE DB provider "INSQL" for linked server "INSQL".


FULL ERROR MESSAGE ^
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-09-18 : 11:07:18
Look for the stored procedure or view that uses the query indicated in the error message using:
SELECT * FROM SYS.OBJECTS
WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%SELECT Tbl1001.DateTime Col1009,Tbl1001.TagName Col1010,Tbl1001.Value Col1011 FROM Runtime.dbo.AnalogHistory%'
That might give you a clue.
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-09-18 : 11:08:32
quote:
Originally posted by flextera

Of course I'm kidding. I deleted it on accident. All I want is information regarding "Msg 7320, Level 16, State 2" And what could be causing this error.

I must admit, for a moment there, I thought you were serious!!
Go to Top of Page
    Next Page

- Advertisement -