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 2000 Forums
 Transact-SQL (2000)
 Embedded Cursors

Author  Topic 

Tethys
Starting Member

3 Posts

Posted - 2005-11-09 : 12:38:43
I've searched on the posts here concerning cursors and am not finding what I'm looking for. Perhaps someone here can supply some insite.

Problem:
- I need to understand how to include a cursor within a 2nd select select statement

Example:
- Please append to this as needed, thanks:

SELECT
Var1,
Var2,
(SELECT Var4 FROM tblExample) AS Var3,
Var4
FROM ...
WHERE ...


Thanks in advance.
-Tethys

: Ah. I should probably add that I've successfully placed a cursor around the outermost SELECT, but when trying to mimic this on the inner SELECT, it doesn't take.

X002548
Not Just a Number

15586 Posts

Posted - 2005-11-09 : 13:02:06
Sure you even need a cursor?

Why don't you post what you've got, and also, read the hint link below



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2005-11-09 : 15:25:17
You mean in a subquery.
Cursors cannot be used there.

==========================================
Cursors are useful if you don't know sql.
DTS 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 - 2005-11-10 : 00:39:14
SELECT
Var1,
Var2,
(SELECT Var4 FROM tblExample) AS Var3,
Var4
FROM ...
WHERE ...

will work only if

SELECT Var4 FROM tblExample

returns single row

Madhivanan

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

- Advertisement -