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.

PRINT CURRENT_TIMESTAMP

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.

Published by Parvinder Nijjar

I blog at ParvTheITGeek.com

Leave a Reply

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

WordPress.com Logo

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

Google photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s

%d bloggers like this: