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 2008 Forums
 Transact-SQL (2008)
 Parameters in Stored procedures

Author  Topic 

7siva7
Starting Member

28 Posts

Posted - 2011-11-21 : 22:32:00
Hi

Need help in stored procedures


CREATE PROCEDURE Proc_Name

@var1 INT,
@var2 INT,

AS



Here instead of giving Datatype (INT) Directly ,can we give like as follows(oracle)?

var1 IN Table_Name.Column%TYPE,
var2 IN Table_Name.Column%TYPE,

as we use in Oracle

please help me with correct syntax


Thanks


HI

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-11-21 : 23:01:36
Not possible. You have to specifically define the data type for each variable


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

johntech
Yak Posting Veteran

51 Posts

Posted - 2011-11-23 : 12:17:41
I'll give you a hint may help you
The %TYPE data type of Oracle, lets you create a variable and have that variable's data type be defined by a table or view column or a PL/SQL package variable.

There is no equivalent for Oracle's %TYPE datatype in T-SQL, but it can be simulated (not very conveniently though) using User Defined Data types (UDT). Here is an example:

EXEC sp_addtype 'MyType', 'smallint', NULL

CREATE TABLE MyTable (i MyType)

CREATE PROC MyProc
AS
BEGIN
DECLARE @i MyType
END

http://vyaskn.tripod.com/oracle_sql_server_differences_equivalents.htm
http://www.ispirer.com/doc/sqlways/Output/SQLWays-1-037.html
Go to Top of Page
   

- Advertisement -