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 with IF
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

eljapo4
Yak Posting Veteran

United Kingdom
98 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
52317 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
Yak Posting Veteran

United Kingdom
98 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
52317 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  
 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