sql syntax issue

  • Hi,

    I am getting error in my below sql statement

    Declare @sqlquery varchar(max)

    Set @sqlquery='INSERT INTO dbo.Staging_Temp_1 fnGetFirstOcurrences(col001, '¯',@Columns),LoadDate FROM dbo.Staging_Temp'

    Select @sqlquery

    error:-

    Msg 102, Level 15, State 1, Line 11

    Incorrect syntax near '¯'.

    plz suggeste me the correct syntax

    regards,

    Vipin jha

  • vipin_jha123 (4/10/2015)


    Hi,

    I am getting error in my below sql statement

    Declare @sqlquery varchar(max)

    Set @sqlquery='INSERT INTO dbo.Staging_Temp_1 fnGetFirstOcurrences(col001, '¯',@Columns),LoadDate FROM dbo.Staging_Temp'

    Select @sqlquery

    error:-

    Msg 102, Level 15, State 1, Line 11

    Incorrect syntax near '¯'.

    plz suggeste me the correct syntax

    regards,

    Vipin jha

    Single quotation marks (apostrophes) must be escaped within the string

    😎

    Declare @sqlquery varchar(max)

    Set @sqlquery='INSERT INTO dbo.Staging_Temp_1 fnGetFirstOcurrences(col001, ''¯'',@Columns),LoadDate FROM dbo.Staging_Temp'

    Select @sqlquery

  • Hi,

    I want below Output from above command

    insert into staging_temp_1

    select dbo.fnGetFirstOcurrences(col001, '¯',@Columns),LoadDate from staging_temp

  • vipin_jha123 (4/10/2015)


    Hi,

    I want below Output from above command

    insert into staging_temp_1

    select dbo.fnGetFirstOcurrences(col001, '¯',@Columns),LoadDate from staging_temp

    Escaping the quotation marks produces the correct output

    😎

    INSERT INTO dbo.Staging_Temp_1 fnGetFirstOcurrences(col001, '¯',@Columns),LoadDate FROM dbo.Staging_Temp

  • You're missing the SELECT.

    And BTW, I suggest to remove the scalar function if possible. We can help you build a faster option.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply