Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8979

Check Constraint Question

$
0
0

Hi,

Is there a way to create a check constraint so that the value of a column will be unique depending on the value of another column?

More specifically, the value of column B can be different only if column A has a newer value.

Example,

Create table Ex (

[Id] INT NOT NULL IDENTITY,

[A] NVARCHAR(10) NOT NULL,

[Loc] NVARCHAR(10) NOT NULL,

[B] INT NOT NULL,

);

Id     A              Loc      B

1      ABC           20      1

2      ABC           30      1

3      CDF           40      1

4      GHI            40      2

5      GHI            70      2

6      GHI            80      2

Thank you.


Viewing all articles
Browse latest Browse all 8979

Latest Images

Trending Articles



Latest Images

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