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)
 Declare without data type

Author  Topic 

u2envy1
Yak Posting Veteran

77 Posts

Posted - 2008-10-31 : 02:34:47
Does any1 know if SQL can do this like ORACLE ?
**ORACLE**
DECLARE
My_Val Table.Column%TYPE

**SQL**
DECLARE
My_Val int

Oracle gets the data type from the table & column. So if you change the data type in future you dont have to change every sp.
Is this possible in SQL ?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-10-31 : 02:47:05
No, in T-SQL it's not possible.

Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

u2envy1
Yak Posting Veteran

77 Posts

Posted - 2008-10-31 : 02:52:22
Thx webfred.
Is it still not possible in SQL server 2008 ?
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-10-31 : 05:07:27
Yes it's still NOT possible in SQL Server 2008.
But there it's new to declare and define in one:
declare @myvar vachar(10) = 'Webfred'

instead of
declare @myvar vachar(10)
set @myvar = 'Webfred'


Greetings
Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2008-10-31 : 06:52:38
I guess the closest in sql server is a user defined datatype, but it really isn't the same thing.

- Lumbago
Go to Top of Page

u2envy1
Yak Posting Veteran

77 Posts

Posted - 2008-11-03 : 01:45:46
Thx peeps.
Its always a pleasure to talk to experts on this forum.
Go to Top of Page
   

- Advertisement -