sql插入值无法绑定多部分标识符

发布于 2024-10-26 06:55:56 字数 949 浏览 4 评论 0原文

我正在尝试运行这个命令,它应该附加 80 行..但我明白了。

消息 4104,16 级,状态 1,第 1 行 无法绑定多部分标识符“Frame.Guid”。

 INSERT  INTO  studentrecords(recordGuid, studentGuid, courseGuid, licenseGuid, repeatflag, frameGuid, coredata, framescore, timeinframe, locked, daterefreshed, dateinserted)
 VALUES     (NEWID(), '25d6e1d9-e5ce-42dd-bd6a-5956ec7cb047', '54dffd58-1af9-44cf-982e-ea0e8930878e', '00000000-1111-1111-0000-000000000000', 0, Frame.Guid,  '<flags><flag1>1</flag1> <flag2>1</flag2> <flag3>1</flag3> <flag4>1</flag4> <flag5>1</flag5><flag6>1</flag6></flags><StudentAnswer> <CorrectionHistory></CorrectionHistory> </StudentAnswer>', 0, 55860, 1, GETDATE(), GETDATE())
 Select Frame.Guid FROM Frame
 WHERE  (Frame.Course = '54dffd58-1af9-44cf-982e-ea0e8930878e') AND (Frame.Template <> '7d3a3b40-86e3-43f4-a4ca-039afdd0b7a3')

I am trying to run this command which shoulld append 80 rows.. but i get.

Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Frame.Guid" could not be bound.

 INSERT  INTO  studentrecords(recordGuid, studentGuid, courseGuid, licenseGuid, repeatflag, frameGuid, coredata, framescore, timeinframe, locked, daterefreshed, dateinserted)
 VALUES     (NEWID(), '25d6e1d9-e5ce-42dd-bd6a-5956ec7cb047', '54dffd58-1af9-44cf-982e-ea0e8930878e', '00000000-1111-1111-0000-000000000000', 0, Frame.Guid,  '<flags><flag1>1</flag1> <flag2>1</flag2> <flag3>1</flag3> <flag4>1</flag4> <flag5>1</flag5><flag6>1</flag6></flags><StudentAnswer> <CorrectionHistory></CorrectionHistory> </StudentAnswer>', 0, 55860, 1, GETDATE(), GETDATE())
 Select Frame.Guid FROM Frame
 WHERE  (Frame.Course = '54dffd58-1af9-44cf-982e-ea0e8930878e') AND (Frame.Template <> '7d3a3b40-86e3-43f4-a4ca-039afdd0b7a3')

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

泪眸﹌ 2024-11-02 06:55:56
INSERT INTO studentrecords (
                            recordGuid, studentGuid, courseGuid, licenseGuid, 
                            repeatflag, frameGuid, coredata, 
                            framescore, timeinframe, locked, 
                            daterefreshed, dateinserted
                           ) 
   SELECT NEWID(), 
          '25d6e1d9-e5ce-42dd-bd6a-5956ec7cb047', 
          '54dffd58-1af9-44cf-982e-ea0e8930878e', 
          '00000000-1111-1111-0000-000000000000', 
          0, Frame.Guid, '1 1 1 1 11 ', 0, 55860, 1, 
          GETDATE(), GETDATE() 
     FROM Frame 
    WHERE Frame.Course = '54dffd58-1af9-44cf-982e-ea0e8930878e'
          AND Frame.Template <> '7d3a3b40-86e3-43f4-a4ca-039afdd0b7a3';
INSERT INTO studentrecords (
                            recordGuid, studentGuid, courseGuid, licenseGuid, 
                            repeatflag, frameGuid, coredata, 
                            framescore, timeinframe, locked, 
                            daterefreshed, dateinserted
                           ) 
   SELECT NEWID(), 
          '25d6e1d9-e5ce-42dd-bd6a-5956ec7cb047', 
          '54dffd58-1af9-44cf-982e-ea0e8930878e', 
          '00000000-1111-1111-0000-000000000000', 
          0, Frame.Guid, '1 1 1 1 11 ', 0, 55860, 1, 
          GETDATE(), GETDATE() 
     FROM Frame 
    WHERE Frame.Course = '54dffd58-1af9-44cf-982e-ea0e8930878e'
          AND Frame.Template <> '7d3a3b40-86e3-43f4-a4ca-039afdd0b7a3';
归途 2024-11-02 06:55:56

我不明白你希望这里的“插入”和“选择”查询如何相关——它们在语法上都是完整的,但没有以任何方式链接。您期望第一个查询中的“Frame.Guid”以某种方式来自第二个查询,但我不太明白如何实现。无论如何,这就是错误消息所说的全部内容;它无法准确地告诉您 Frame.Guid 的含义。

I can't see how you want the "insert" and "select" queries here to be related -- they're both syntactically complete but not linked in any way. You're expecting "Frame.Guid" in the first query to come from the second query, somehow, but I can't quite get how. In any case, that's all that the error message is saying; it can't tell what you mean by Frame.Guid, exactly.

流云如水 2024-11-02 06:55:56

您在插入语句中引用了 Frame.Guid,但没有定义。我怀疑您想将该值选择到变量中,然后在插入语句中使用该变量。

DECLARE @frameGUID GUID

SET @frameGUID = (Select Frame.Guid FROM Frame
WHERE  (Frame.Course = '54dffd58-1af9-44cf-982e-ea0e8930878e')
   AND (Frame.Template <> '7d3a3b40-86e3-43f4-a4ca-039afdd0b7a3'))

INSERT  INTO  studentrecords(recordGuid, studentGuid, courseGuid, licenseGuid, repeatflag, frameGuid, coredata, framescore, timeinframe, locked, daterefreshed, dateinserted)
VALUES  (
    NEWID(),
    '25d6e1d9-e5ce-42dd-bd6a-5956ec7cb047',
    '54dffd58-1af9-44cf-982e-ea0e8930878e',
    '00000000-1111-1111-0000-000000000000',
    0,
    @frameGUID,
    '<flags><flag1>1</flag1> <flag2>1</flag2> <flag3>1</flag3> <flag4>1</flag4> <flag5>1</flag5><flag6>1</flag6></flags><StudentAnswer> <CorrectionHistory></CorrectionHistory> </StudentAnswer>',
    0,
    55860,
    1,
    GETDATE(),
    GETDATE())

You're referencing Frame.Guid in the insert statement, but there isn't one defined. I suspect you want to select that value into a variable, then use the variable in the insert statement.

DECLARE @frameGUID GUID

SET @frameGUID = (Select Frame.Guid FROM Frame
WHERE  (Frame.Course = '54dffd58-1af9-44cf-982e-ea0e8930878e')
   AND (Frame.Template <> '7d3a3b40-86e3-43f4-a4ca-039afdd0b7a3'))

INSERT  INTO  studentrecords(recordGuid, studentGuid, courseGuid, licenseGuid, repeatflag, frameGuid, coredata, framescore, timeinframe, locked, daterefreshed, dateinserted)
VALUES  (
    NEWID(),
    '25d6e1d9-e5ce-42dd-bd6a-5956ec7cb047',
    '54dffd58-1af9-44cf-982e-ea0e8930878e',
    '00000000-1111-1111-0000-000000000000',
    0,
    @frameGUID,
    '<flags><flag1>1</flag1> <flag2>1</flag2> <flag3>1</flag3> <flag4>1</flag4> <flag5>1</flag5><flag6>1</flag6></flags><StudentAnswer> <CorrectionHistory></CorrectionHistory> </StudentAnswer>',
    0,
    55860,
    1,
    GETDATE(),
    GETDATE())
绝影如岚 2024-11-02 06:55:56

你那里有两个陈述。 INSERT 语句无法知道您是否希望字段 Frame.Guid 脱离 SELECT 语句。

您需要将其重构为一条语句。您可以通过将所有常量放入 SELECT 语句中(在 SELECTFROM 之间)并删除 VALUES 来实现此目的> 条款。那么这将是一个声明。

You have two statements there. The INSERT statement has no way of knowing that you want the field Frame.Guid out of the SELECT statement.

You need to refactor it into one statement. You can do that by putting all the constants into the SELECT statement (between SELECT and FROM) and deleting the VALUES clause. Then it will be one statement.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文