Articles → SQL SERVER → Variables In SQL Server

Variables In SQL Server






Purpose





Syntax


DECLARE @variable_name data_type




DECLARE @row_count INT





Setting Values




  1. Using the "SET" keyword
  2. Using the "SELECT" query

Using the "SET" keyword




SET @variable_name = val




SET @errormessage = 'Invalid User'



Using the "SELECT" query




SELECT 
  @variable_name = [column_Name | Aggregate function] 
FROM 
  table_name




SELECT 
  @row_count = count(*) 
FROM 
  user_information



Posted By  -  Karan Gupta
 
Posted On  -  Saturday, April 2, 2011

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250