Store Result Set In Variable Sql. Unlike SET if the query results in multiple rows then the variable value is set to the value of the last row. Having a basic SQL issue using microsoft sql server 2012.
The syntax is as follows SET anyVariableName yourQuery. If you are looking to set the ID variable parameter you need to specify it as an OUTPUT parameter and set its value in your query. Create procedure addFaculty ID int OUTPUT as begin IF NOT EXISTS Select AccountType from UserTable where AccountType Faculty begin Insert into CredentialsTable values iamafaculty.
If you are looking to set the ID variable parameter you need to specify it as an OUTPUT parameter and set its value in your query.
Syntex to Declare Variable in SQL Server DECLARE Your_variable_name datatype initial_value Your_variable_name datatype initial_value. Im trying to set a variable from a SQL query. To understand the above concept let us create a table. SET PrimaryContactKey SELECT cPrimaryCntctKey FROM tarcustomer c tarinvoice i WHERE icustkey ccustkey AND iinvckey tmp_key Make sure you have both a starting and an ending parenthesis.