根据列类型声明变量类型
在 Oracle 的 PL-SQL 中,您可以声明一个变量并根据表列定义其类型:
declare var1 table.column%TYPE;
Is it possible to do some things in MS SQL Server?
In Oracle's PL-SQL, you can declare a variable and define its type based on a table column:
declare var1 table.column%TYPE;
Is it possible to do something similar in MS SQL Server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,你不能这样做。最接近的等效项是
用户定义的数据类型
。这将为您提供一个可能有帮助的抽象层,但它与从列派生类型不同。No you can't do this. The closest equivalent is
User-Defined Data Types
. This will give you a layer of abstraction that may help, but it is not the same as deriving a type from a column.“欺骗”一点。
它可能会回避真正的问题,但您可以通过“将自动创建一个包含具有正确数据类型的所有列的临时表”来
It may skirt the real issue, but you can "cheat" a little bit by
Will automatically create a temp table with all columns with correct data types.