Linked SQL Server to C/ODBC

patric@starrepublic.com
Member Posts: 2
Hi!
I'm using a Linked Server in SQL Server 2005 to connect to C/ODBC, and it work fine.
http://www.codeguru.com/vb/vb_internet/ ... php/c8903/
My problem is when I try to declare a variable (@Timestamp) in my stored procedure, it says "Column not found: @Timestamp". I can't see what’s wrong, any idée’s?
Create PROCEDURE ActionLog
@Timestamp nvarchar(50) as
DBCC TRACEON(8765) SELECT * FROM OPENQUERY(NAVISION, 'SELECT * FROM "Action Log" WHERE "Timestamp Wipcore"=@Timestamp')
RETURN
GO
Best regards
Patric
I'm using a Linked Server in SQL Server 2005 to connect to C/ODBC, and it work fine.
http://www.codeguru.com/vb/vb_internet/ ... php/c8903/
My problem is when I try to declare a variable (@Timestamp) in my stored procedure, it says "Column not found: @Timestamp". I can't see what’s wrong, any idée’s?
Create PROCEDURE ActionLog
@Timestamp nvarchar(50) as
DBCC TRACEON(8765) SELECT * FROM OPENQUERY(NAVISION, 'SELECT * FROM "Action Log" WHERE "Timestamp Wipcore"=@Timestamp')
RETURN
GO
Best regards
Patric
0
Comments
-
In thank the variable @TimeStamp is not valid on "'SELECT * FROM "Action Log" WHERE "Timestamp Wipcore"=@Timestamp'" scope.
If you would like to pass a parameter you must define a query as "string" and then execute a sp_execute_sql sentence, as this example:
DECLARE @IntVariable INT
DECLARE @SQLString NVARCHAR(500)
/* Build and execute a string with one parameter value. */
SET @IntVariable = 35
SET @SQLString = N'SELECT * FROM pubs.dbo.employee WHERE job_lvl = ' +
CAST(@IntVariable AS NVARCHAR(10))
EXEC(@SQLString)
/* Build and execute a string with a second parameter value. */
SET @IntVariable = 201
SET @SQLString = N'SELECT * FROM pubs.dbo.employee WHERE job_lvl = ' +
CAST(@IntVariable AS NVARCHAR(10))
EXEC(@SQLString)0 -
[Topic moved from Navision Attain forum to SQL General forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions