Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Parameter datatypes linked to underlying table column datatype Expand / Collapse
Posted Thursday, June 5, 2014 1:04 PM


Group: General Forum Members
Last Login: Tuesday, September 16, 2014 6:33 PM
Points: 16, Visits: 56

In Oracle when i create any procedure i define parameter datatype linked to under lying table.
For ex
create procedure testprocedure
param2 customer.salary%type )

Here i have defined param1 and param2 with datatype of name and salary of customer table respectively.
This way i do not need to worry about modifying param1 and param2 datatypes when datatypes of name & salary of customer table changes in future.

How can i accomplish this in SQL server.
I appreciate your response.
Post #1578027
Posted Thursday, June 5, 2014 2:10 PM



Group: General Forum Members
Last Login: Yesterday @ 5:46 AM
Points: 13,752, Visits: 28,148
Lookup the data types of the underlying columns and then manually set them. That's the only way.

"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1578050
Posted Friday, June 6, 2014 3:22 PM


Group: General Forum Members
Last Login: Yesterday @ 5:04 PM
Points: 2,102, Visits: 3,164
Sadly, you can't do that directly in SQL Server.

The only way to simulate that would be to use alias data types -- lots of aliases.

SQL DBA,SQL Server MVP('07, '08, '09)

"We came in spastic, Like tameless horses /
We left in plastic, As numbered corpses / ...
Remember Charlie, Remember Baker /
They left their childhood On every acre /
And who was wrong? And who was right? /
It didn't matter in the thick of the fight." : the inimitable Mr. Billy Joel, about the Vietnam War
Post #1578531
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse