|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
sp_executesql and datetimeHello all,
I have this code and I do not know why I have this error. EXECUTE sp_executesql N'SELECT * FROM TABLE WHERE T_ID = @level and timestamp = @timestamp', N'@timestamp datetime', N'@level int', @level = '1' and @timestamp between '2006-03-01' and '2006-03-31'; I thank in advanced Ina Try this:
EXECUTE sp_executesql N'SELECT * FROM TABLE WHERE T_ID = @level and timestamp between @timestamp and @timestamp2', N'@timestamp datetime, @timestamp2 datetime, @level int', @level = '1' , @timestamp = '2000-11-24' , @timestamp2 = '2005-01-01' -- Show quoteRaymond Yap "ina" <roberta.inal***@gmail.com> wrote in message news:1144428316.066769.218440@e56g2000cwe.googlegroups.com... > Hello all, > > I have this code and I do not know why I have this error. > > EXECUTE sp_executesql > N'SELECT * FROM TABLE > WHERE T_ID = @level and timestamp = @timestamp', > N'@timestamp datetime', > N'@level int', > @level = '1' and @timestamp between '2006-03-01' and '2006-03-31'; > > I thank in advanced > > Ina > You are combining an EQUALITY with a BETWEENS. It just doesn't work.
Change the code to have a Start TimeStamp range and a Stop TimeStamp range,. -- Show quoteArnie Rowland, YACE* "To be successful, your heart must accompany your knowledge." *Yet Another Certification Exam "ina" <roberta.inal***@gmail.com> wrote in message news:1144428316.066769.218440@e56g2000cwe.googlegroups.com... > Hello all, > > I have this code and I do not know why I have this error. > > EXECUTE sp_executesql > N'SELECT * FROM TABLE > WHERE T_ID = @level and timestamp = @timestamp', > N'@timestamp datetime', > N'@level int', > @level = '1' and @timestamp between '2006-03-01' and '2006-03-31'; > > I thank in advanced > > Ina > |
|||||||||||||||||||||||