Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
khufiamalik
Posting Yak Master
120 Posts |
Posted - 2008-12-31 : 04:25:55
|
| how can I Apply a Unique constraint in Update Query?Can any one give me a sample syntax.Thanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-31 : 04:29:12
|
| unique constraint is defined on table column. Didnt understand what you mean by apply unique constraint on update. once you already define constraint, it will check value while updation and if it finds a duplicate value, it raises an error saying violation of unique constraint. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-31 : 04:30:20
|
| alternatively, you can use an update trigger to enforce this unique value check without constraint creation, but performance will be poor. |
 |
|
|
Jai Krishna
Constraint Violating Yak Guru
333 Posts |
Posted - 2008-12-31 : 04:31:17
|
| I think we cannot apply a unique constraint in update queryJai Krishna |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-12-31 : 04:32:14
|
[code]-- Prepare sample dataDECLARE @Sample TABLE ( i INT PRIMARY KEY )INSERT @SampleSELECT 1-- Now try to break uniqueness on i columnINSERT @SampleSELECT 1INSERT @SampleSELECT 2 UNION ALLSELECT 2[/code] E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|