Linked SQL Server to C/ODBC

patric@starrepublic.compatric@starrepublic.com Member Posts: 2
edited 2007-06-01 in SQL General
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

Comments

  • bernatrmbernatrm Member Posts: 5
    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)
  • krikikriki Member, Moderator Posts: 9,115
    [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!


Sign In or Register to comment.