代碼我有一個字符串,它是SqlCommand
這樣一個CommandText
:字符串的Sql背後
string SqlCopySyntax = "insert into Question ([Body], [O1], [O2], [O3], [O4], [ocorrect], [oselected], [time],[bookrange], [UserID], [CourseID], [code]) select [Body], [O1], [O2], [O3], [O4], [ocorrect], [oselected], [time],[bookrange], @userid, [CourseID], [code] from Question where UserID = 9999999999 and [email protected]";
我現在我想用一個新的選擇命令替換選擇部分。 這是新的選擇命令:
with q as (select q.*, row_number() over (partition by [Bookrange], [level] order by newid()) as seqnum from Question q) select * from q where UserID = 9999999999 and [email protected];
我應該如何替換?
你是什麼意思?所選列應與您要插入的表格匹配。 – OldProgrammer
第二個代碼的結果與第一個代碼中的select命令相同。我只是不知道如何複製 –
WITH在你的第二個查詢中返回一個額外的列--seqnum--所以下面的select * fromq有一個額外的列。你似乎沒有對seqnum做任何事情? – MartW