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 2005 Forums
 Transact-SQL (2005)
 Select query

Author  Topic 

cool.mugil
Starting Member

32 Posts

Posted - 2009-01-10 : 01:27:10
Hi,
We have a table for document approval process as follows,
Name Under MustApprove
A - yes
B A Yes
C A No
D B No
E B Yes
F C No
G C Yes

like wise it can grow with any number of levels.
The scenario is, if 'A' logs in he can approve the documents approved by 'B', and documents may or may not be approved by 'C'.An interesting point comes here, in the case of 'C' the must approve bit is set to false.So, what we have to do now is we have to check who are all coming under 'C' and repeat the process to get the document for approval to 'A'.

Is it possible to write a select query with out temp tables or cursor for this.

Please help me.

Thanks in advance.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-10 : 02:07:00
yup. its possible. read about common table expressions in sql 2005

http://msdn.microsoft.com/en-us/library/ms186243.aspx
Go to Top of Page

cool.mugil
Starting Member

32 Posts

Posted - 2009-01-10 : 02:42:08
thanks for the link.
Go to Top of Page
   

- Advertisement -