0

I am working in SQL Server 2008. I have a table with many columns that will not have values (at least, for the given situation). So, they will have a NULL value when I query each of them. I would like to instead make these NULL values be empty strings (i.e., ''). What is the best way to achieve this? My current idea is to set a DEFAULT value of '' on each them at the time that the table is created. However, since there are so many of them, this will be very tedious.

2 Answers 2

1

You have 2 options:

  1. As you said, give it a default value of empty string for columns you don't want to be null when you create table/add new columns.
  2. When you select nullable columns from the table you can use IsNull(ColumnName,'') which means if ColumnName is null it'll return empty string ('').
Sign up to request clarification or add additional context in comments.

Comments

0
  1. Create a table with the same structure as your current table, with a different name, and the default value as ''.
  2. Insert into that table from your original table.
  3. Delete the original table.
  4. Change the name of the new table to the original table name.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.