How can I create a column with the default value being an empty string?
3 Answers
You can read up on the subject here
CREATE TABLE dbo.Test (ID INTEGER, EmptyString VARCHAR(32) DEFAULT '')
INSERT INTO dbo.Test (ID) VALUES (1)
INSERT INTO dbo.Test (ID) VALUES (2)
SELECT * FROM dbo.Test
DROP TABLE dbo.Test
4 Comments
Brian Hooper
What database is this? In Oracle, if you set a VARCHAR to '', it becomes NULL.
Lieven Keersmaekers
@Brian Hooper, OP said using MS SQL 2008. Nevertheless, good to know Oracle works differently, thanks.
Brian Hooper
Ah. Either some tags have appeared recently or I need new glasses. Sorry, chaps.
Lieven Keersmaekers
@Brian, don't worry, your eyes are fine. I changed the tags after your comment and removed the using MS SQL 2008 from the question.