SQL Server - 代码错误

时间:2018-01-03 11:35:57

标签: sql-server

我无法理解此代码有什么问题,我收到的列值错误无效。

CREATE PROCEDURE [UpdateLocation]
    (@uId varchar(50) = null,
     @currentloc varchar(256) = null,
     @lastloc varchar(256) = null,
     @loggeddate date,
     @loggedtime time)
AS
BEGIN
    IF EXISTS(SELECT UId FROM Location WHERE UId = @uId)
    BEGIN
        UPDATE Location 
        SET CurrentLocation = @currentloc,
            LastLocation = @lastloc,
            LoggedTime = @loggedtime,
            LoggedDate = @loggeddate
        WHERE UId = @uId
    END
    ELSE
    BEGIN
        INSERT INTO Location (CurrentLocation, LastLocation, LoggedTime, LoggedDate)
        VALUES (@currentloc, @lastloc, @loggedtime, @loggeddate)
    END
END

错误:

  

列名'CurrentLocation'无效。

表格

Location
Register
Report

表格中的列位置:

Id  int 4
UId varchar 50
CurrentLocation varchar 256
LastLocation    varchar 256
LoggedTime  time    5
LoggedDate  date    3

任何有解决方案的人?

0 个答案:

没有答案