0
嘗試運行下面的查詢時,出現'db_cursor'附近的錯誤語法錯誤。有人可以告訴我爲什麼和我的腳本錯誤在哪裏?提前致謝!「db_cursor」附近的語法不正確
declare @Sort varchar(4000)
declare @OpenDate datetime
declare @ret int;
set @Sort = 'All'
set @OpenDate = '1/1/2015'
IF (@Sort = 'All')
BEGIN
declare @Organization varchar(2500)
declare @OrgEmp int
Set @OrgEmp = 0
Set @ret = 0
declare db_cursor CURSOR FOR
SELECT distinct RTrim(Organization) + '|' as Oganization,
(select rpt.ufnGetEmployeePopulation(RTrim(Organization) + '|', @OpenDate)) as NumberofEmployee FROM dbo.CorpStartEndDates where EndDate >= @OpenDate
OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @Organization, @OrgEmp
WHILE @@FETCH_STATUS = 0
BEGIN
Set @ret = @ret + @OrgEmp
FETCH NEXT FROM db_cursor INTO @Organization, @OrgEmp
END
CLOSE db_cursor
DEALLOCATE db_cursor
哪個RDBMS是這樣的?請添加一個標籤來指定您是使用'mysql','postgresql','sql-server','oracle'還是'db2' - 或者其他的東西。 –