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
 Transact-SQL (2008)
 Update Help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

tooba
Posting Yak Master

106 Posts

Posted - 09/14/2012 :  11:49:36  Show Profile  Reply with Quote
Hi guys,

Quick question, how i can use case statment in update statement or i can use or not, below is my code

Update Mytable
Set Book = (Select top 1 'Book' +' '+isnull(e.book, 'No Book')
From Table2
Case
When isnull(e.book, 'No Book') like %No Book% then '<font Color = Red>' +e.Book + '</font>' else
'<font Color=Green>'+ e.book + '</font>'
)

Thank You...

visakh16
Very Important crosS Applying yaK Herder

India
47101 Posts

Posted - 09/14/2012 :  16:33:31  Show Profile  Reply with Quote
can you explain what you're trying to do here

i cant make out much from code

which table has column book. whats e?
how are tables related?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

tooba
Posting Yak Master

106 Posts

Posted - 09/15/2012 :  00:52:09  Show Profile  Reply with Quote
Sorry it was typo mistake here is my final Query

Update Mytable
Set Book = (Select top 1 'Book' +' '+isnull(book, 'No Book')
From Table2
Case
When isnull(book, 'No Book') like %No Book% then '<font Color = Red>' +e.Book + '</font>' else
'<font Color=Green>'+ book + '</font>'
)

I am updating field Book , IN case Statement i am saying if there is no Book then on front end Color change to Red if there is book Color change to Green. Please let me know if my question is not clear, I want to use this case statement in Update statement.

Thank YOu.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47101 Posts

Posted - 09/15/2012 :  01:38:25  Show Profile  Reply with Quote
why do you need to do formatting in t-sql? it should be done at front end not in t-sql


you have not yet provided the columns by which tables are related

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

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