Declaring Variables and Retrieving Variables — Parv The IT Geek

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 on January 26, 2015.


Published by Parvinder Nijjar

I blog at

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: