Q:

SQL Server : stored procedure IFNULL check

Solution_id (Primary key, Int)
Col1 (varchar)
Col2 (varchar)
Col3 (varchar)
Col4 (varchar)
Col5 (varchar)

I am writing a stored procedure to update this table.  There are 6 input parameters for the above 6 columns. 
@Attached_File1 VARCHAR(MAX),
@Attached_File2 VARCHAR(MAX),
@Attached_File3 VARCHAR(MAX),
@Attached_File4 VARCHAR(MAX),
@Attached_File5 VARCHAR(MAX),
@Ticket_ID BIGINT

I want to write a SQL query which will update the table with the values specified in the input parameters.  BUT I must not overwrite the attachment columns with null.  I mean I need to use only those parameters which contains data. 
For example, if the table has a row
[10, "aaa", "bbb", "efg", null, null] 

and the input parameters are 
(10, null, null, "mno", "ddd", null) 

then after the update the row will become 
[10, "aaa", "bbb", "mno", "ddd", null]

How to check for null/empty strings and generate the update query accordingly to achieve this? 

A:

Is this something like you're after? 
UPDATE mytable
SET Col1 = ISNULL(@Attached_File1, Col1),
    Col2 = ISNULL(@Attached_File2, Col2),
    Col3 = ISNULL(@Attached_File3, Col3),
    Col4 = ISNULL(@Attached_File4, Col4),
    Col5 = ISNULL(@Attached_File5, Col5)
WHERE Solution_id = @Ticket_ID

ISNULL takes two values, if the first one is not null then it is used, otherwise the 2nd value is used. 
See MSDN for more information on ISNULL

Update
I've just noticed your comment at the end, which talks about empty strings...

How to check for null/empty strings and generate the update query accordingly to achieve this? 

In which case, you could do the following...
UPDATE mytable
SET Col1 = ISNULL(NULLIF(@Attached_File1,''), Col1),
    Col2 = ISNULL(NULLIF(@Attached_File2,''), Col2),
    Col3 = ISNULL(NULLIF(@Attached_File3,''), Col3),
    Col4 = ISNULL(NULLIF(@Attached_File4,''), Col4),
    Col5 = ISNULL(NULLIF(@Attached_File5,''), Col5)
WHERE Solution_id = @Ticket_ID

This uses the NULLIF statement which takes two values, if the first value is the same as the second value, then NULL is returned, otherwise it returns the first value. 
See MSDN for more information on NULLIF

