Is there any equivalent to %TYPE in MSSQL2005?
CREATE TABLE TEST (ID NUMBER(5));
DECLARE
myVar TEST.ID%TYPE;
BEGIN
................
END;
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.