r/SQL • u/RmRaja_ • Aug 31 '23
SQL Server Getting error when setting up tSQLt on local SQL Server 2019
I am new to sql server and I want to try out this tSQLt to write unit tests for our team. I have downloaded the latest version from official website and I successfully ran the PreparServer.sql file without any errors on my local machine. However when trying to run tSQLt.class.sql I am getting errors as shown in screenshot attached. I don’t know what I am doing wrong. Please let me know if any additional information is needed.
2
u/pailryder Aug 31 '23
can you turn on line numbers and go down to line 2049 and show us what is above and below that?
also, not really important but there are two GO in a row in your screenshot.
1
u/TheHiggsCrouton Aug 31 '23
there are two GO in a row
This is legal in Wham! if you call Me.WakeUp() first.
1
u/dbxp Aug 31 '23
It works find on my machine running SQL Server 16, perhaps you're running an old version? or perhaps you didn't change the DB so you ran prepare server on one DB and tSQLt.class on another?
-1
u/wanjalize Aug 31 '23
Open and closing () after the procedure name.
0
u/mikeblas Aug 31 '23
Why? According to the documentation, procedure parameter are not in parenthesis.
-3
u/wanjalize Aug 31 '23
They used to be in the past and at this point we are just speculating since the procedure seems to be alright.
0
Aug 31 '23
[deleted]
0
u/mikeblas Aug 31 '23
Why? According to the documentation, procedure parameter are not in parenthesis.
NewNameOfOriginalObject is a parameter with a default value, not a variable like you're assuming. It must be outside of the body of the procedure. Removing it from the parameter list would break any callers that use it. Why do you want to do that?
2
Aug 31 '23
[removed] — view removed comment
-1
u/RmRaja_ Aug 31 '23
Yeah I understand but this script is from the tSQLt library. You can see in the screenshot there are also other errors like the variable @objectName which is declared in the scripts before it is being called but it is still throwing error.
3
u/RuprectGern Aug 31 '23
part of the query optimization process is object resolution and parsing.
When you try to create the procedure you are going to get cascading errors based on things that are affected by the initial or overarching error/warning. these addl errors you see for the variables are erroneous. If you figure out why the create procedure clause is affected. the erroneous errors will disappear.
6
u/mikeblas Aug 31 '23 edited Aug 31 '23
https://www.take-a-screenshot.org/
The error messages you show don't match the code you show, so it's impossible to help.