Я wirtten ниже сценарий, но когда я пытаюсь выполнить это Приводим ERR -Неправильный синтаксис около '=' рядом WHILE LOOP
Msg 102, Level 15, State 1, Line 6 Неправильный синтаксис около знак равно
declare @PostDate date
declare @PostID int
DECLARE @count INT
DECLARE @updatecounter INT
WHILE exists (select top 1 @PostDate = postdate from dateTemp order by postdate desc)
BEGIN
PRINT @PostDate
SELECT @count = COUNT(*) from cs_posts_bkup20160209 where CONVERT(date,Postdate) = @PostDate
print @COUNT
SET @updatecounter = 1
WHILE (@count>=1)
BEGIN
select top 1 @PostID = PostId from cs_posts_bkup20160209 where CONVERT(date,Postdate) = @PostDate and Postorder IS NULL order by postdate desc
pRINT @POSTID
--update cs_posts_bkup20160209 set PostOrder = @updatecounter where postid= @PostID
SET @updatecounter = @updatecounter + 1
SET @count = @count - 1
Print @updatecounter
Print @count
END
DELETE from dateTemp where Postdate = @PostDate
END
GO
, что я здесь отсутствует ...
пожалуйста, помогите !!
Вы должны указать, что WHILE существует (выберите верх 1 1 из dateTemp, где @PostDate = postdate order by postdate desc) – StackUser
Вы не можете выполнить задание внутри проверки EXISTS. Кроме того, я думаю, что подход WHILE - это не путь. SQL работает с наборами данных, поэтому вы можете выполнить обновление в одном запросе. –