Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 TYPE_NAME

Author  Topic 

vladimir.stokic
Starting Member

25 Posts

Posted - 2007-07-03 : 03:53:48
Hi,
In Oracle PL/SQL, there is a key word %TYPE. That means that whenever one writes a stored procedure, or trigger, or any piece of PL/SQL code, they do not have to remember the type of the field they want to use. For instance, one wants to create a trigger on a table (say, Table1), and within the trigger a temp table is needed that would be the same as the table the trigger is attached to. There would be no need for writing (for example):
CREATE TABLE #temp (
column1 int,
column2 varchar
), but instead:

CREATE TABLE #temp (
column1 Table1.column1%TYPE
column2 Table1.column2%TYPE
)
could be written.

Using this, chances for errors are reduced, because the types are not hard coded.

Is there anything like that in Transact-SQL 2005?
Is TYPE_NAME function the equivalent?

I have the same question for the Oracle key word %ROW
Thank you


Being a genius has its advantages...

nr
SQLTeam MVY

12543 Posts

Posted - 2007-07-03 : 07:21:54
select column1, column2 into #temp from existingtable where 1=0

or create a user defined type.


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2007-07-03 : 07:25:11
http://vyaskn.tripod.com/oracle_sql_server_differences_equivalents.htm

gee, i like pasting this link lately.

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -