Tim Hibbard

CEO for EnGraph software
posts - 626, comments - 1586, trackbacks - 459

My Links

News



Add to Google

Twitter












Tag Cloud

Article Categories

Archives

Post Categories

Image Galleries

EnGraph Blogs

Links

Other

Roll

Monday, June 07, 2010

Declaring variables in SQL

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

Posted On Monday, June 07, 2010 9:46 AM | Feedback (1) |

Powered by: