Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2007-03-09 : 09:35:33
|
| What's wrong with this sp ? I get the error 'Incorrect syntax near the keyword where.' If I use between instead like this it works --MaxDateOut between @strStartDate and @strEndDatebut I want to include the start and end dates. MaxDateOut finds the latest date in a view which groups the data. I have also tried taking the 'and' out before the 'where' and same error.CREATE PROCEDURE spRMU_GetChaseFiles@strStartDate datetime,@strEndDate datetime,@strDepartment nvarchar(100),@strDivision nvarchar(100) ASSELECT *FROM vweChaseFilesOutWHEREDept like '%'+@strDepartment+'%' andDivision like '%'+@strDivision+'%' andwhere MaxDateOut >= @strStartDate and <= @strEndDateorder by MaxDateOut ascGO |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-03-09 : 09:38:08
|
quote: Originally posted by Pinto What's wrong with this sp ? I get the error 'Incorrect syntax near the keyword where.' If I use between instead like this it works --MaxDateOut between @strStartDate and @strEndDatebut I want to include the start and end dates. MaxDateOut finds the latest date in a view which groups the data. I have also tried taking the 'and' out before the 'where' and same error.CREATE PROCEDURE spRMU_GetChaseFiles@strStartDate datetime,@strEndDate datetime,@strDepartment nvarchar(100),@strDivision nvarchar(100) ASSELECT *FROM vweChaseFilesOutWHEREDept like '%'+@strDepartment+'%' andDivision like '%'+@strDivision+'%' andwhere MaxDateOut >= @strStartDate and <= @strEndDateorder by MaxDateOut ascGO
Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2007-03-09 : 09:40:13
|
| Thanks - I had to change the last bit too and add MaxDateOut before the last parameter.MaxDateOut >= @strStartDate and MaxDateOut <= @strEndDate |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-03-09 : 09:42:36
|
You can as well write:MaxDateOut between @strStartDate and @strEndDate Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2007-03-09 : 10:05:38
|
| I had that first but I wanted to include the start and end dates. |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2007-03-09 : 10:08:03
|
| it should include both unless you have a time value and start and end date are equal--------------------keeping it simple... |
 |
|
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2007-03-09 : 10:32:05
|
| Tried it again and yes, it is including start and end dates. I was getting confused.......I think it was because I was having problems with Crystal XI and its date parameters. |
 |
|
|
|
|
|