Replace In Update Sql Statement Null

Shizuka Kudo 20th Anniversary The Best Rar Program. Run the following query: SELECT 'UPDATE yourtable SET ' + name + ' = NULL WHERE ' + name + ' = '';' FROM syscolumns WHERE id = object_id('yourtable') AND isnullable = 1; The output of this query will be a chunk of SQL script like this: UPDATE yourtable SET column1 = NULL WHERE column1 = '; UPDATE yourtable SET column2 = NULL WHERE column2 = '; UPDATE yourtable SET column3 = NULL WHERE column3 = '; -- etc. Copy and paste that SQL script into a new query and run it to update all your columns. I actually use Robert N's answer above daily when I'm importing flat file data sets, so I put it into a stored procedure that I could pass a table name to. It just populates a temp table with the update statements, then executes each row in the table.

Laddu4700 (9/16/2010) Actually I need to export the data to excel file. Some the coulumns data have NULL values. I have used ISNULL function and wrote a below T-SQL statement, but not getting 0 in place of NULL where as I am looking for a empty space Just wondering whether SQL does't support empty space or is there any other ways to get it done.

SQL does support empty space. Just not for numerics. Download Free Fundamentals Of Esthetics Rufenacht Pdf here. You'll need to convert your numerics to something character based so you can replace nulls with an empty string. Excel will take it all in stride during the import. --Jeff Moden RBAR is pronounced ree-bar and is a Modenism for Row- By- Agonizing- Row. First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row.

See More On StackoverflowInsert Sql Statement

Think, instead, of what you want to do to a column. If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair Helpful Links. Laddu4700 (9/16/2010) Actually I need to export the data to excel file.

Some the coulumns data have NULL values. I have used ISNULL function and wrote a below T-SQL statement, but not getting 0 in place of NULL where as I am looking for a empty space Just wondering whether SQL does't support empty space or is there any other ways to get it done. SQL does support empty space. Just not for numerics. You'll need to convert your numerics to something character based so you can replace nulls with an empty string. Excel will take it all in stride during the import.