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
 General SQL Server Forums
 New to SQL Server Programming
 convert oracle to sql server

Author  Topic 

karthikeyanc
Starting Member

1 Post

Posted - 2009-09-18 : 04:24:00
hi folks,

i have a follwing sp which i create in oracle but my client ask me to develop the same for ms sql server, since i have no idea about the sql server i need you peoples guidence to fullfill my client needs
the code is as follows...

CREATE OR REPLACE PROCEDURE validation
AS
TYPE t_t1 is table of NUMBER(2);
t_a t_t1;
i NUMBER ;
BEGIN
select Count(table1.user_name) BULK COLLECT INTO t_a
from table1 ,table2
where table1.user_name = table2.user_name;
IF t_a(1)>0 THEN
dbms_output.put_line('EXECUTION FAILS');
ELSE
dbms_output.put_line('SUCCESSFUL EXECUTION');
END IF;
END ;

thanks in advance
Karthikeyanc2003

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-09-18 : 10:23:06
Well I don't know Oracle but it looks like this may be an sql server equivalent:

if object_id('dbo.validation') > 0
drop proc dbo.validation
go

create proc dbo.validation
as

if exists (
select 0
from table1 t1
inner join table2 t2
on t2.[user_name] = t1.[user_name]
)
begin
print 'EXECUTION FAILS'
end
else
begin
print 'SUCCESSFUL EXECUTION'
end

go


Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -