简体   繁体   中英

T-SQL equivalent of PL/SQL %TYPE?

Is there any equivalent to %TYPE in MSSQL2005?

CREATE TABLE TEST (ID NUMBER(5));

DECLARE
myVar TEST.ID%TYPE;
BEGIN
................
END;

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).

The closest you could get would be to create a user-defined type, and then use it in the table and the code.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM