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
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Derived transformation
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sqlfresher2k7
Aged Yak Warrior

583 Posts

Posted - 06/25/2012 :  15:52:42  Show Profile  Reply with Quote


Currently,I have below code in the derived column but i want to extend the below condition set the TED to 0 if it null or "No" and If it is "YES" then to 1.

TED == "Yes" ? 1 : 0  


When TED is null or ''  then 0
if "YES" = 1
if "No" = 0


tkizer
Almighty SQL Goddess

USA
35007 Posts

Posted - 06/25/2012 :  15:58:21  Show Profile  Visit tkizer's Homepage  Reply with Quote
Use a CASE statement.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

583 Posts

Posted - 06/25/2012 :  16:28:54  Show Profile  Reply with Quote
I did tried with below code in derived showing an error.
Please let me know what i missing..

CASE WHEN TED ="Yes" THEN 1
WHEN TED ="No" THEN 0
WHEN TED = "" THEN 0
WHEN TED is null THEN 0
ELSE TED END
Go to Top of Page

tkizer
Almighty SQL Goddess

USA
35007 Posts

Posted - 06/25/2012 :  16:36:47  Show Profile  Visit tkizer's Homepage  Reply with Quote
Use single quotes: 'Yes', 'No', ''. You may need to do a CONVERT too since you are going from varchar data to an int.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

583 Posts

Posted - 06/25/2012 :  16:54:29  Show Profile  Reply with Quote
I did updated with mentioned changes it is still showing the error..
Go to Top of Page

tkizer
Almighty SQL Goddess

USA
35007 Posts

Posted - 06/25/2012 :  17:02:52  Show Profile  Visit tkizer's Homepage  Reply with Quote
Show us, please.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

583 Posts

Posted - 06/25/2012 :  17:06:28  Show Profile  Reply with Quote
CASE WHEN TED ='Yes' THEN 1
WHEN TED ='No' THEN 0
WHEN TED = '' THEN 0
WHEN TED is null THEN 0
ELSE TED END
Go to Top of Page

tkizer
Almighty SQL Goddess

USA
35007 Posts

Posted - 06/25/2012 :  18:15:05  Show Profile  Visit tkizer's Homepage  Reply with Quote
Show us the error. It's likely due to needing to use CONVERT as I mentioned.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

583 Posts

Posted - 06/26/2012 :  11:45:19  Show Profile  Reply with Quote
Why conversion is required and does i need to use case statement to accomplish the desired results...
Go to Top of Page

tkizer
Almighty SQL Goddess

USA
35007 Posts

Posted - 06/26/2012 :  12:03:29  Show Profile  Visit tkizer's Homepage  Reply with Quote
Show us the error.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

583 Posts

Posted - 06/26/2012 :  12:45:36  Show Profile  Reply with Quote
Thanks for your help..
I was able to resolve the issue without any errors.

Go to Top of Page

tkizer
Almighty SQL Goddess

USA
35007 Posts

Posted - 06/26/2012 :  12:49:31  Show Profile  Visit tkizer's Homepage  Reply with Quote


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
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.08 seconds. Powered By: Snitz Forums 2000