Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15694

Need assistance with Unique constraint

$
0
0

Hi,

I came across issue when I tried to insert the entry in the table which has composite unique constraint

CREATE TABLE Temp_OtherHA_Data
(PHACode    VARCHAR(5),  
 ProgramSetting VARCHAR(8), 
CONSTRAINT U_Temp_OtherHA_Data UNIQUE ( phacode, ProgramSetting)

Now when I try to insert the following entries, it givees me error which is correct as per the constraint defination but in my case it should work.

Insert into Temp_OtherHA_Data(phacode, ProgramSetting) values ('CA',' ')

Insert into Temp_OtherHA_Data(phacode, ProgramSetting) values ('CA',' ')

I want constraint to allow these entries when "ProgramSetting" is blank (not Null).

Any idea?


Viewing all articles
Browse latest Browse all 15694

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>