SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Insert Records
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

dr223
Constraint Violating Yak Guru

359 Posts

Posted - 06/12/2012 :  10:48:05  Show Profile  Reply with Quote
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

Edited by - dr223 on 06/12/2012 10:59:25

Lamprey
Flowing Fount of Yak Knowledge

3821 Posts

Posted - 06/12/2012 :  12:28:13  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000