August 25, 2005 at 9:57 am
and whats with the '' + ,
Is this part of a dynamic sql select?
executing this
SELECT *
FROM @a
WHERE CTimeStamp BETWEEN '' + @DateFrom + '' AND '' + @DateTo + '''
gives me Server: Msg 105, Level 15, State 1, Line 16
Unclosed quotation mark before the character string ''
'.
Server: Msg 170, Level 15, State 1, Line 16
Line 16: Incorrect syntax near ''
'.
August 25, 2005 at 10:04 am
I have went with the following SQL code from the first reply by Michael Du Bois:
CREATE PROCEDURE spGetDocuments
@DateFrom datetime,
@DateTo datetime,
AS
Declare @AddedDateTo datetime
Set @AddedDateTo= DateAdd(DD,+1,@DateTo)
SELECT RecID, Desc
FROM tblFiles
WHERE CTimeStamp BETWEEN ' + CHAR (39) + CONVERT (VARCHAR, @DateFrom, 101) + CHAR (39) + ' AND ' + CHAR (39) + CONVERT (VARCHAR, @AddedDateTo, 101) + CHAR (39)
GO
August 25, 2005 at 10:06 am
That's why it fails... just use the variables directly >>
where CTimeStamp >= @DateFrom and CTimeStamp < @AddedDateTo
August 25, 2005 at 10:11 am
Thanks Remi. That's what I was trying to get at.
This was VERY good to learn about BETWEEN. Thanks all.
I wasn't born stupid - I had to study.
August 25, 2005 at 10:15 am
BTW, the version I did is NOT the equivalent of BETWEEN (note the < instead of <=).
August 25, 2005 at 10:21 am
I saw that, but I figured Bendan had all the information needed... Just kind'a talkin'..., I was....
I wasn't born stupid - I had to study.
August 25, 2005 at 11:18 am
Cool, we have a replacement for Sushila's comments .
August 25, 2005 at 11:52 am
Nah! Her's are actually useful.
I wasn't born stupid - I had to study.
August 25, 2005 at 11:56 am
You got that right .
Viewing 9 posts - 16 through 23 (of 23 total)
You must be logged in to reply to this topic. Login to reply