Skip to content
Advertisement

Creating a table where UserPassword not equal to UserName, but the following code returning a error

In SQL Server:

I get this error:

Column check constraint for column ‘UserPassword’ references another column, table (Credentials).

Advertisement

Answer

You are defining column level constraints,

In a column level constraint, you can only define constraint for specific column.

For your requirement, you should go for table level constraints, from this you can define constraint for multiple columns, like:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement