Is there any equivalent to %TYPE in MSSQL2005?
在MSSQL2005中有没有相当于%TYPE?
CREATE TABLE TEST (ID NUMBER(5));
DECLARE
myVar TEST.ID%TYPE;
BEGIN
................
END;
2 个解决方案
#1
No, there isn't any way to inherit the type of a table column when declaring variables in SQL Server 2005 (or 2008, for that matter).
不,在SQL Server 2005(或2008年)中声明变量时,没有任何方法可以继承表列的类型。
The closest you could get would be to create a user-defined type, and then use it in the table and the code.
您可以获得的最接近的是创建用户定义的类型,然后在表和代码中使用它。
#2
It's amazing to me that there isn't an enormous amount of complaint about this. The absence of this capability makes SQL Server code maintainability miserable. What a waste of everyone's time.
令我惊讶的是,对此没有太多的抱怨。缺少此功能会使SQL Server代码的可维护性变得很糟糕。多么浪费每个人的时间。
#1
No, there isn't any way to inherit the type of a table column when declaring variables in SQL Server 2005 (or 2008, for that matter).
不,在SQL Server 2005(或2008年)中声明变量时,没有任何方法可以继承表列的类型。
The closest you could get would be to create a user-defined type, and then use it in the table and the code.
您可以获得的最接近的是创建用户定义的类型,然后在表和代码中使用它。
#2
It's amazing to me that there isn't an enormous amount of complaint about this. The absence of this capability makes SQL Server code maintainability miserable. What a waste of everyone's time.
令我惊讶的是,对此没有太多的抱怨。缺少此功能会使SQL Server代码的可维护性变得很糟糕。多么浪费每个人的时间。