Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there an Oracle like '%type' variable in SQL Server

Status
Not open for further replies.

darwin101

Programmer
Mar 7, 2001
156
0
0
US
Hi all

Is there a way to declare a SQL Server variable that is similar to the %type in Oracle?

Thanks
 
Hi darwin101,

I have read about '%type' there: ( because I don't know Oracle )
You can use [schema.]object%TYPE to define variables based on actual object datatypes.

Now I know what '%type' means.
But don't now if there is some way to declare variable like this in MSSQL.

It is based on for what you are want this, for example, in MSSQL there is datatype 'sql_variant'
( A data type that stores values of various SQL Server-supported data types, except text, ntext, image, timestamp, and sql_variant )

So, can you explain closer, what you are trying to do ?

Zhavic

---------------------------------------------------------------
In the 1960s you needed the power of two Comodore64s to get a rocket to the moon. Now you need a machine which is a vast number of times more powerful just to run the most popular GUI.
 

In Oracle procedure, when you declare a variable for a column in a table, you do

variable_name tble_name.column_name%type;

The variable will inherit the data type/size of the column in the table. If you need to change the column type/size in the future, you don't need to change all the variables you've declared related to the column - avoid code maintainence.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top