Showing posts with label clause. Show all posts
Showing posts with label clause. Show all posts

Sunday, 11 March 2012

Connect By Clause

Hi,
We have "Connect By Clause" as in Oracle. Do we have the same or equivalent in MS-SQL Server 2000?
Thanks with Regards.
-MohitCan you give some explaination about "Connect By Clause" in Oracle?|||There is no connect by equivalent in SQL 2000. It has been promised for SQL Yukon.

Connect by is a way of selecting a hierarchy of records from a table. If you have a table like

empID int
empName varchar(10)
MgrID int

You can select a manager, and all of his sub-employees (and their sub-employees, and so on..) by using a connect by query.|||It's an iterative process in sql server...

you need a loop..and you need to determine how many levels you need to go...

Sunday, 12 February 2012

Configuring a SQLDatasource control

When I configure a SQLDataSource control I want the following where clause...

WHERE (RegionID = @.RegionID AND DistrictID IS NULL AND CampusID IS NULL) OR
(DistrictID = @.DistrictID AND CampusID IS NULL ) OR
(CampusID = @.CampusID AND UserRole = 'CampusAdmin') OR
(CampusID = @.CampusID)

but it gets reformated as...

WHERE (RegionID = 'Region10') AND (DistrictID IS NULL) AND (CampusID IS NULL) OR
(DistrictID = 2) AND (CampusID IS NULL) OR
(CampusID = '999999103') AND (UserRole = 'CampusAdmin') OR
(CampusID = '999999103')

I don't think these are functionaly equivelant, are they?
If not how do I stop the 'wizard' from reformatting the SQL where clause?

Thanks

Interestingly enough, both WHERE clauses are identical because the AND takes precedence over the OR operator.|||Yes, they are identical (Although I *HATE* that). Hey SQL Builder, leave my SQL alone, thank you!|||

Thanks alot. That is what I was hoping. Anyway, I wish they would leave it alone too!