我曾在SQL Server數據庫。現在我必須處理一個Sybase數據庫(使用Squirrel客戶端)。此查詢不工作:爲什麼此查詢在Sybase中不起作用?
DECLARE @tableName VARCHAR(500);
DECLARE my_cursor CURSOR FOR
SELECT name
FROM sysobjects
WHERE type = 'U';
OPEN my_cursor;
FETCH NEXT FROM my_cursor INTO @tableName;
WHILE @@FETCH_STATUS = 0
BEGIN
//Do something here
FETCH NEXT FROM my_cursor;
END
CLOSE my_cursor;
DEALLOCATE CURSOR my_cursor;
它給出了一個錯誤 - Incorrect syntax near the keyword 'FROM'. SQLState: ZZZZZ ErrorCode: 156 Error occured in: FETCH NEXT FROM my_cursor INTO @table_Name
現在能正常工作的SQL Server數據庫(我的最後一行改爲DEALLOCATE my_cursor
後,誰能告訴我,我錯了
@Mitch是的,因爲所有其他查詢工作正常。這真讓我抓狂! – Mayank 2011-02-28 06:29:51
哪個版本的SyBase? – 2011-02-28 06:34:29
@Mitch Adaptive Server Enterprise/12.5.3/EBF 12156/P/ia64/HP-UX B.11.23/ase125x/1883/64位/ FBO/Thu Nov 18 10:53:44 2004 – Mayank 2011-02-28 06:41:06