Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | 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 with IF
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

eljapo4
Posting Yak Master

United Kingdom
100 Posts

Posted - 09/27/2012 :  10:17:50  Show Profile  Reply with Quote
is this possible:

UPDATE [DR_HeatPumpCalc].[dbo].[tbl_lkupHeatPumps]
  if @Filetype <> '' SET [ImageFilename] ='heatpump-' + Convert(varchar(50),@NewHeatPumpID) + @Filetype,
  else SET [ImageFilename] = NULL
  if @PDFFiletype <>'' [PDFDatasheetPath] = 'heatpump-' + Convert(varchar(50),@NewHeatPumpID) + @PDFFiletype
  else [PDFDatasheetPath] = NULL
WHERE [HeatPumpID] = @NewHeatPumpID	

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 09/27/2012 :  10:21:59  Show Profile  Reply with Quote
it should be CASE ...WHEN


UPDATE [DR_HeatPumpCalc].[dbo].[tbl_lkupHeatPumps]
  SET [ImageFilename] =CASE WHEN @Filetype <> '' THEN 'heatpump-' + Convert(varchar(50),@NewHeatPumpID) + @Filetype ELSE NULL END,
[PDFDatasheetPath] = CASE WHEN @PDFFiletype <>''  THEN 'heatpump-' + Convert(varchar(50),@NewHeatPumpID) + @PDFFiletype ELSE NULL END
WHERE [HeatPumpID] = @NewHeatPumpID	


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

Go to Top of Page

eljapo4
Posting Yak Master

United Kingdom
100 Posts

Posted - 09/27/2012 :  10:31:06  Show Profile  Reply with Quote
thank you this is just what I was doing after a bit of thought
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 09/27/2012 :  10:33:12  Show Profile  Reply with Quote
welcome

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

Go to Top of Page
  Previous Topic Topic Next 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