Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8366991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:03:06+00:00 2026-06-09T13:03:06+00:00

Basically the logic I want in my constraint goes something like this … IF([AssetTypeId]

  • 0

Basically the logic I want in my constraint goes something like this …

IF([AssetTypeId] = 1) 
THEN
    [FileId] IS NOT NULL AND [Url] IS NULL 
END

IF([AssetTypeId] = 0) 
THEN
   [FileId] IS NULL AND [Url] IS NOT NULL)
END

AssetTypeId is a FK reference / constraint on the current table.
The error I get suggests syntax error no mater how I word this with one exception, when I do this …

([AssetTypeId] = 1) AND [FileId] IS NOT NULL AND [Url] IS NULL 
OR
([AssetTypeId] = 0)  AND [FileId] IS NULL AND [Url] IS NOT NULL

It gives me this error:

'Asset (dbo)' table
- Unable to add constraint 'CK_Asset_FileIdOrUrlRequiredNotBoth'.  
The ALTER TABLE statement conflicted with the CHECK constraint "CK_Asset_FileIdOrUrlRequiredNotBoth". The conflict occurred in database "MyDb", table

“dbo.Asset”.

I can’t seem to figure out why SQL wont let me do this.
Any ideas guys?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:03:07+00:00Added an answer on June 9, 2026 at 1:03 pm

    When the message, during creation of a constraint, indicates that that same constraint is being violated:

    'Asset (dbo)' table
    - Unable to add constraint 'CK_Asset_FileIdOrUrlRequiredNotBoth'.  
    The ALTER TABLE statement conflicted with the CHECK constraint "CK_Asset_FileIdOrUrlRequiredNotBoth". The conflict occurred in database "MyDb", table
    

    It means that there is existing data in that table that doesn’t conform to your desired constraint. The constraint is syntactically valid, or it wouldn’t have gotten this far.

    You need to find the bad data and correct it before you can implement your constraint.

    E.g.

    SELECT * from Asset where
    ([AssetTypeId] = 1) AND ([FileId] IS NULL OR [Url] IS NOT NULL )
    OR
    ([AssetTypeId] = 0)  AND ([FileId] IS NOT NULL OR [Url] IS NULL)
    

    Should find the bad data

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ultimate Goal Is to make something like Magento offers - basically a logic builder,
Basically, I want my model to have its own validation logic while having the
I want to have a table with columns: id, user_id1, and user_id2. basically this
I am slightly stuck on the javascript logic to accomplish this. Basically If I
I have some php conditional logic...basically I want to use jQuery to show or
I'm trying to write some beforeSave logic in CakePHP 2.0 beta. Basically I want
I got this logic in a control to create a correct url for an
Is this how we still handle control break logic in sql cursors Basically, what
I basically want the following logic in my XML obj must be ((MASTER ||
Basically, what I want is to use an alternative to the login cookies as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.