根据列类型声明变量类型 [英] Declaring variable type based on a column type

查看:44
本文介绍了根据列类型声明变量类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Oracle的PL-SQL中,您可以声明变量并根据表列定义其类型:

In Oracle's PL-SQL, you can declare a variable and define its type based on a table column:

declare var1 table.column%TYPE;

是否可以在MS SQL Server中执行类似的操作?

Is it possible to do something similar in MS SQL Server?

推荐答案

否,您不能这样做。最接近的等效项是 用户定义的数据类型 。这将为您提供一层可能有所帮助的抽象层,但它与从列中派生类型不同。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆