Site icon Database Tutorials

Must declare the scalar variable “@variable”

 

If there is a variable in the script we run and we have not declared this variable, we will get this error.

For example, with the help of the following script, let’s create a table named “databaseandlogins” in the “TestDB” database.

Then try to add data to this table as follows.

When we try to add data in this way, we will get an error as follows.

After we declare and set the required variables, you will see that the problem is solved when we run it again.

You can learn more about declaring variable in the artilce “Declare Variables in SQL Server(TSQL)

Exit mobile version