This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing demonstration on how to add a default value to IMAGE or BLOB data type and what is the default value for a binary column in SQL Server?
The ‘0x00’ is a Binary Zeros and also uses as a string terminator. If you want to set any default value to a binary column, you can use ‘0x00’ which is safe and valid.
Check the below demonstration:
1 2 3 4 5 6 7 8 9 10 |
CREATE TABLE tbl_Students (StudID INT, StudName VARCHAR(15), StudPhoto IMAGE DEFAULT (0x00)) INSERT INTO tbl_Students(StudID,StudName) VALUES (1,'Anvesh') SELECT *FROM tbl_Students StudName StudPhoto ----------- --------------- ------- 1 Anvesh 0x00 |
Add default to an existing table:
1 2 |
ALTER TABLE tbl_Students ADD CONSTRAINT df_tbl_Studentse_StudPhoto DEFAULT (0x00) FOR StudPhoto |
Leave a Reply