Dear all,
I want to convert the day range from two variable into records. So, I use a
While-loop to do so
while @.CountDate <= @.TWorkDate
begin
.
.
.
-- CountDate = CountDate add one day
select @.CountDate = DATEADD(day, 1, @.CountDate)
END
When I try to run, it shows the following error:
Server: Msg 141, Level 15, State 1, Procedure sp7006_2, Line 64
A SELECT statement that assigns a value to a variable must not be combined
with data-retrieval operations.
Help... The error should related to the DATEADD function but I dunno how to
handle.
IvanPlease post the entire query definition, since the error does not originate
from any of the lines that you have posted.
Look for a SELECT statement in which both a variable assignment and a result
set declaration are present. This is forbidden in a single SELECT statement.
ML
http://milambda.blogspot.com/|||This statement:
select @.CountDate = DATEADD(day, 1, @.CountDate)
does NOT create an error.
Please post the complete DDL and code so that we may have all the
information necessary to help you.
Arnie Rowland, YACE*
"To be successful, your heart must accompany your knowledge."
*Yet Another certification Exam
"Ivan" <ivan@.microsoft.com> wrote in message
news:eoU6REcmGHA.856@.TK2MSFTNGP03.phx.gbl...
> Dear all,
> I want to convert the day range from two variable into records. So, I use
> a While-loop to do so
> while @.CountDate <= @.TWorkDate
> begin
> .
> .
> .
> -- CountDate = CountDate add one day
> select @.CountDate = DATEADD(day, 1, @.CountDate)
> END
> When I try to run, it shows the following error:
> Server: Msg 141, Level 15, State 1, Procedure sp7006_2, Line 64
> A SELECT statement that assigns a value to a variable must not be combined
> with data-retrieval operations.
> Help... The error should related to the DATEADD function but I dunno how
> to handle.
> Ivan
>sql
No comments:
Post a Comment