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
 migration from oracle to sql server 2008

Author  Topic 

TajKazi
Posting Yak Master

101 Posts

Posted - 2014-11-07 : 07:12:19
please tell me how to write following query in ms sql server.. specially "connect by prior" and "start with"
here it is query..

select count(*)
into v_is_manager
from custom.ESS_USERS eu
where eue.IS_ACTIVE = 'Y'
connect by prior eue.PERSONID = eue.supervisor_personid
start with eue.supervisor_personid = p_person_id;

TajKazi
Posting Yak Master

101 Posts

Posted - 2014-11-07 : 07:50:13
also how to write following in sql server please anybody guide me............


querySelect := querySelect || ' SELECT * FROM RNR_VW_ALLREPORTDATA WHERE 1 = 1 ' ;

if((p_from is not null) and (p_to is not null)) then
querySelect := querySelect || ' and (NOMINATED_FOR >= '|| '''' || p_from || '''' ||' and NOMINATED_FOR <= '|| '''' || p_to ||'''' ||') ';
end if;
Go to Top of Page

Ifor
Aged Yak Warrior

700 Posts

Posted - 2014-11-07 : 12:55:52
To get any decent replies you will have to take the time to provide consumable sample data with the expected results.

Query1
The equivalent of CONNECT BY is a recursive CTE.

Query2
Variables start with @, so @queryselect, @p_from etc
String concatination uses + not ||.
IF ... END IF becomes IF BEGIN ... END
Go to Top of Page
   

- Advertisement -