A variable can be best described as being a place holder for information which you then fill in with relevant information which you will want to retrieve later.
The below query shows the result from the CURRENT_TIMESTAMP which returns the current date and time.
Jan 15 2015 11:44AM
The CURRENT_TIMESTAMP result can be made into a variable which can be retrieved later.
DECLARE @ThisIsTheCurrentDateandTime Datetime = CURRENT_TIMESTAMP PRINT @ThisIsTheCurrentDateandTime
The DECLARE command creates the variable, assigns the datatype and the information I would like to put into the variable.
After I have created the variable I then retrieve it using the PRINT command to show the value stored.
Originally published at https://parvtheitgeek.com on January 26, 2015.