What Is Variable in SQL Server Transact-SQL
What is a variable in SQL Server Transact-SQL?
A variable in Transact-SQL is a symbolic name representing a memory storage that holds a piece of data.
A variable has the following the components:
1. Variable name - A symbolic name to represent the variable. Variable names in Transact-SQL must starts with the @ character. For example, @count and @price are variable names.
2. Variable data type - A predefined format on how the data is stored in the variable. For example, INTEGER and MONEY are variable types.
3. Variable value - The value represented by the data in variable storage. For example, 3 and 9.99 could be variable values stored in @count and @price variables.
4. Variable scope - The period of execution in which the variable is declared, assigned with a value and required to hold the value.
Here is an example using variables in Transact-SQL in a statement batch:
DECLARE @price MONEY; SET @price = 9.99; PRINT @price;
In the above example:
2017-04-22, 389👍, 0💬
How to download and install Microsoft SQL Server Management Studio Express in SQL Server? Microsoft ...
How To Import One Table Back from a Dump File in Oracle? If you only want to import one table back t...
How To Locate and Take Substrings with CHARINDEX() and SUBSTRING() Functions in SQL Server Transact-...
How To Calculate Age in Days, Hours and Minutes in SQL Server Transact-SQL? On many Web sites, news ...
How To Provide Values to Stored Procedure Parameters in SQL Server Transact-SQL? If a stored procedu...