How to do a select in sql and store values into a variable.

I know this is very simple, but the simplest things we usually forget, so I thought I would just write this and keep it for reference later and hope someone out there would find it useful too.

DECLARE @fromDate datetime;
DeCLARE @toDate datetime;

— select payroll cycle
SELECT StartDate into @fromDate, EndDate into @toDate,
FROM PayrollCycles
WHERE RequestID = 2555

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s