Jen C
Jen C

Reputation: 7

SQL Update considering Null values

I am trying to update notes in a table to archive some files. I've generated the SQL script and am having a problem because of the accounts which have a Null value in the notes. I would like my note update to take place whether there is a Note or a Null in the current note field. Below is my SQL statement:

update dbo.CaseTable 
set Quick = 'Case files have been archived. To have file access restored,  please enter a helpdesk ticket with the full case name.  '  
            + convert(varchar(255),Quick) 
where CaseID = 1

Upvotes: 1

Views: 88

Answers (3)

Jande
Jande

Reputation: 1705

You can use CONCAT function. Null values are implicitly converted to an empty string.

Try this:

  update dbo.CaseTable 
  set Quick = CONCAT('Case files have been archived. To have file access restored, please enter a helpdesk ticket with the full case name. ' , CAST(Quick AS varchar(255)))
  where CaseID = 1

Upvotes: 1

Update dbo.Case table Set quick='case files has been archived. To have files access restored,please enter Helpdesk ticket with the fullcase name.' +convert(varchar(255),ISNULL(Quick,")) Where caseID=1

Upvotes: 0

JJ32
JJ32

Reputation: 1034

Try this:

update dbo.CaseTable 
set Quick = 'Case files have been archived. To have file access restored, please enter a helpdesk ticket with the full case name. '
+ convert(varchar(255), ISNULL(Quick, '')) 
where CaseID = 1

Upvotes: 2

Related Questions