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
 Insert Records

Author  Topic 

dr223
Constraint Violating Yak Guru

444 Posts

Posted - 2012-06-12 : 10:48:05
Hi,

I have a query called QryExtract as;

SELECT     GPRDTech.gprdsql.TblPracDetails.prac_no, GPRDTech.gprdsql.TblPracDetails.practice_name, GPRDTech.gprdsql.TblPracDetails.prac_status, 
dbo.TblPracExclude.prac_enabled
FROM GPRDTech.gprdsql.TblPracDetails LEFT OUTER JOIN
dbo.TblPracExclude ON GPRDTech.gprdsql.TblPracDetails.prac_no = dbo.TblPracExclude.prac_no


Results

prac_no Practice_name prac_status prac_enabled

1 A Active True
2 B Old False
3 C Active False
4 D Active NULL

Ok -

prac_no 1 = the practice is active and enabled
prac_no 2 = the practice is old and disabled
prac_no 3 = the practice is active but disabled
prac_no 4 = the practice is Active but has no status ( new practice)

The prac_enabled is updated from a form in VB.Net.

But as far as this query is concerened can I enforce all OLD practices to be set as FALSE.

Secondly, can I change any NULL value to TRUE by default.

Thanks

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2012-06-12 : 12:28:13
You should be able to use a case expression inplace of prac_enabled:
CASE 
WHEN prac_status = 'old' THEN 'False'
ELSE COALESCE(prac_enabled, 'True')
END
Go to Top of Page
   

- Advertisement -