开发者

Avoid NULL columns using DEFAULT Empty String

how can I create a Column with the 开发者_开发技巧default value being an empty string?

thanks guys!


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


Something like:

CREATE TABLE foobar (string_column VARCHAR(100) NOT NULL DEFAULT '')


In SQL server you can set "Column properties > Default value or binding" section to (''). NOTE: It includes single quotation and parenthesis

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜