Must declare the scalar variable

前端 未结 8 1293
小蘑菇
小蘑菇 2020-11-29 01:41

@RowFrom int

@RowTo int

are both Global Input Params for the Stored Procedure, and since I am compiling the SQL query inside the St

8条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 02:18

    If someone else comes across this question while no solution here made my sql file working, here's what my mistake was:

    I have been exporting the contents of my database via the 'Generate Script' command of Microsofts' Server Management Studio and then doing some operations afterwards while inserting the generated data in another instance.

    Due to the generated export, there have been a bunch of "GO" statements in the sql file.

    What I didn't know was that variables declared at the top of a file aren't accessible as far as a GO statement is executed. Therefore I had to remove the GO statements in my sql file and the error "Must declare the scalar variable xy" was gone!

提交回复
热议问题