我有一个游标,它从一组表中生成一条 JSON 文本记录。光标一直在使 SSMS 崩溃。该脚本运行了一段时间,然后 SSMS 失败。下面是我编写的导致崩溃的代码。
DECLARE @ROW_ID int -- Here we create a variable that will contain the ID of each row.
DECLARE JSON_CURSOR CURSOR -- Here we prepare the cursor and give the select statement to iterate through
FOR
SELECT -- Our select statement (here you can do whatever work you wish)
ROW_NUMBER() OVER (ORDER BY NAME_2-1,NAME_2-2,FIELD_1-1,FIELD_1-2) AS ROWID
FROM
(
SELECT
FIELD_1-1
,FIELD_1-2
,NAME_1-1
,NAME_1-2
FROM
(
SELECT FIELD_1-1,FIELD_1-2,NAME,VALUE
FROM TABLE_1
WHERE NAME IN ('NAME_1-1','NAME_1-2')
) …Run Code Online (Sandbox Code Playgroud)