Declaring variables in SQL
- by Tim Hibbard
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