Declaring variables in SQL

Posted by Tim Hibbard on Geeks with Blogs See other posts from Geeks with Blogs or by Tim Hibbard
Published on Mon, 07 Jun 2010 07:46:05 GMT Indexed on 2010/06/07 15:02 UTC
Read the original article Hit count: 206

Filed under:

I would like to blog more about the problems I encounter on a daily basis.  I find that taking 10 minutes or so to write a simple solution to my problems helps me retain that information.

I always forget the specific syntax to declaring variables in T-SQL. 

declare @startdate datetime;
declare @enddate datetime;
 
set @startdate = '04/01/2010';
set @enddate = '04/30/2010';
 
select count(id) from triphistory where tripdate between @startdate and @enddate

© Geeks with Blogs or respective owner