SQL: .. 包含对对象的未解析引用
SQL: .. contains an unresolved reference to an object
完整消息
Parameter: [DbName].[SpName].@timeout contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [dbo].[TIME]
我知道,此消息已存在几个问题。但在我的例子中,这个发生的原因特别是因为 TIME Sql 类型。
我有 StoredProcedure(在 Visual Studio Sql 数据库项目中),它看起来像这样。
CREATE PROCEDURE [dbo].[my_sp]
@name VARCHAR(255),
@timeout TIME
AS
...
我没有名字为 TIME 的 table。当我将类型 TIME 更改为其他类型时,它可以正常工作,否则它会以 TIME 类型和编译时错误显示此消息。
TIME 我试图用 SQL 替代 C# 的 TimeSpan。
您不能将 time
与 SQL Server 2005 一起使用,因为它在 SQL Server 2008 之前不存在。
相反,考虑存储时间间隔的数字表示(最终,time
是 无论如何 - 只是:你会明确地这样做而不是自动)。典型示例是将时间间隔表示的秒数或毫秒数存储为 int
。
方便地,TimeSpan
有一个 TotalSeconds
和 TotalMilliseconds
属性 映射到这个(只是:将它转换为整数),并且有 FromSeconds(...)
和 FromMilliseconds(...)
方法去另一个方向。
根据评论,听起来您还需要将时间合并(添加)到日期的功能;这也很简单:
DATEADD(second, {interval as seconds}, {some datetime})
或
DATEADD(millisecond, {interval as milliseconds}, {some datetime})
完整消息
Parameter: [DbName].[SpName].@timeout contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects: [dbo].[TIME]
我知道,此消息已存在几个问题。但在我的例子中,这个发生的原因特别是因为 TIME Sql 类型。
我有 StoredProcedure(在 Visual Studio Sql 数据库项目中),它看起来像这样。
CREATE PROCEDURE [dbo].[my_sp]
@name VARCHAR(255),
@timeout TIME
AS
...
我没有名字为 TIME 的 table。当我将类型 TIME 更改为其他类型时,它可以正常工作,否则它会以 TIME 类型和编译时错误显示此消息。
TIME 我试图用 SQL 替代 C# 的 TimeSpan。
您不能将 time
与 SQL Server 2005 一起使用,因为它在 SQL Server 2008 之前不存在。
相反,考虑存储时间间隔的数字表示(最终,time
是 无论如何 - 只是:你会明确地这样做而不是自动)。典型示例是将时间间隔表示的秒数或毫秒数存储为 int
。
方便地,TimeSpan
有一个 TotalSeconds
和 TotalMilliseconds
属性 映射到这个(只是:将它转换为整数),并且有 FromSeconds(...)
和 FromMilliseconds(...)
方法去另一个方向。
根据评论,听起来您还需要将时间合并(添加)到日期的功能;这也很简单:
DATEADD(second, {interval as seconds}, {some datetime})
或
DATEADD(millisecond, {interval as milliseconds}, {some datetime})