我在存储过程中创建了一个临时表:
CREATE TABLE #tbl (
[Id] INT,
[Correct] BIT
)
如何使用自动生成的Id和此数据的增加数字填充此表:
SELECT Correct FROM question
INNER JOIN answer
ON (question.questionId = answer.questionId)
WHERE question.questionid = 25
ORDER BY answer.answerId
答案 0 :(得分:1)
尝试以下格式:
CREATE TABLE #tbl (
[Id] INT IDENTITY(1,1),
[Correct] BIT
)
答案 1 :(得分:1)
CREATE TABLE #tbl(
ID int IDENTITY(1,1),
Correct bit
)
这将在您的表格中创建自动公司字段
答案 2 :(得分:1)
没有IDENTITY
你可以试试这个
SELECT ROW_NUMBER() OVER (ORDER BY answer.answerId) AS Id, Correct
FROM question INNER JOIN
answer ON (question.questionId = answer.questionId)
WHERE question.questionid = 25
ORDER BY answer.answerId