|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How do I Convert this Statement to T-SQL Code?hello am a newbie here... i hope you could help me..
foxpro code goes like this, select id from employee into cursor CurEmployee * Select id from AppTable where id In (Select id from CurEmployee) in short am still studying on how to make a cursor using T-SQL your help is highly appreciated. Why do you want to use an <evil> cursor </evil> ?
Cursors are not efficient, think in terms of sets instead this join should work for you Select id from AppTable a inner join CurEmployeec on a.id = c.id Denis the SQL Menace http://sqlservercode.blogspot.com/ EdSh***@gmail.com wrote: Show quote > hello am a newbie here... i hope you could help me.. > > foxpro code goes like this, > > select id from employee into cursor CurEmployee > > * Select id from AppTable where id In (Select id from CurEmployee) > > in short am still studying on how to make a cursor using T-SQL > > your help is highly appreciated. read up on cusrsors in BOL.
This is the example for using a cursor from MS. DECLARE Employee_Cursor CURSOR FOR SELECT LastName, FirstName FROM Northwind.dbo.Employees WHERE LastName like 'B%' OPEN Employee_Cursor FETCH NEXT FROM Employee_Cursor WHILE @@FETCH_STATUS = 0 BEGIN FETCH NEXT FROM Employee_Cursor END CLOSE Employee_Cursor DEALLOCATE Employee_Cursor <EdSh***@gmail.com> wrote in message Show quote news:1158330310.958664.296890@i3g2000cwc.googlegroups.com... > hello am a newbie here... i hope you could help me.. > > foxpro code goes like this, > > select id from employee into cursor CurEmployee > > * Select id from AppTable where id In (Select id from CurEmployee) > > in short am still studying on how to make a cursor using T-SQL > > your help is highly appreciated. > |
|||||||||||||||||||||||