views:

316

answers:

2

Is there any equivalent to %TYPE in MSSQL2005?

CREATE TABLE TEST (ID NUMBER(5));

DECLARE
myVar TEST.ID%TYPE;
BEGIN
................
END;
+3  A: 

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.

Peter
A: 

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.

Dave Ziffer
complainers switch to Oracle - and then no need to complain.. :)
Randy