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)
 Passing parameter to CURSOR

Author  Topic 

7siva7
Starting Member

28 Posts

Posted - 2011-11-25 : 04:43:27
Hi all,


i foudn this code written in oracle

declare cursor c_emp (cin_No NUMBER)
is
select count(*)
from employee
where id = cin_No;


how can we do this in sql server?

thanks in advacne

HI

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-11-25 : 05:18:59
Have a look at the examlpes in bol. Should be almost the same.
Not that a cursor would be any use in this case


declare c_emp cursor
for
select cin_No NUMBER = count(*)
from employee
where id = @cin_No


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

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-11-25 : 05:21:25
ORACLE procedures mostly depend on Cursors. Do not try to simulate them in SQL Server. Post what you want to get

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

7siva7
Starting Member

28 Posts

Posted - 2011-11-27 : 23:42:03
what is replacement of cursors in SQL SERVER

HI
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-11-27 : 23:47:30
quote:
Originally posted by 7siva7

what is replacement of cursors in SQL SERVER

HI



It depends. You'll need to provide us an example first.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

7siva7
Starting Member

28 Posts

Posted - 2011-11-27 : 23:50:57
How to send private message to you ?

can you give me your email address?

HI
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-11-27 : 23:52:35
No. Post your example here.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

7siva7
Starting Member

28 Posts

Posted - 2011-11-27 : 23:55:32
...............
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-11-28 : 05:36:08
for this example it would maybe be

declare @i int
select @i = count(*)
from employee
where id = @cin_No;



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

- Advertisement -