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 7695117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:28:32+00:00 2026-05-31T21:28:32+00:00

I am trying to alter column datatype of a primary key to tinyint from

  • 0

I am trying to alter column datatype of a primary key to tinyint from int.This column is a foreign key in other tables.So,I get the following error:


Msg 5074, Level 16, State 1, Line 1 The object ‘PK_User_tbl’ is
dependent on column ‘appId’. Msg 5074, Level 16, State 1, Line 1 The
object ‘FK_Details_tbl_User_tbl’ is dependent on column ‘appId’. Msg
5074, Level 16, State 1, Line 1 The object ‘FK_Log_tbl_User_tbl’ is
dependent on column ‘appId’. Msg 4922, Level 16, State 9, Line 1 ALTER
TABLE ALTER COLUMN appId failed because one or more objects access
this column.


Is there any other way other than to delete dependencies and recreate them?

  • 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-05-31T21:28:33+00:00Added an answer on May 31, 2026 at 9:28 pm

    I believe that you will have to drop the foreign key constraints first. Then update all of the appropriate tables and remap them as they were.

    ALTER TABLE [dbo.Details_tbl] DROP CONSTRAINT [FK_Details_tbl_User_tbl];
    -- Perform more appropriate alters
    ALTER TABLE [dbo.Details_tbl] ADD FOREIGN KEY (FK_Details_tbl_User_tbl) 
        REFERENCES User_tbl(appId);
    -- Perform all appropriate alters to bring the key constraints back
    

    However, unless memory is a really big issue, I would keep the identity as an INT. Unless you are 100% positive that your keys will never grow past the TINYINT restraints. Just a word of caution 🙂

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

Sidebar

Related Questions

I'm trying to drop a primary key constraint from a table using the following
I'm trying to change the datatype of a column in SQL Server from tinyint
I got the following error while trying to alter a column's data type and
I'm trying to change the datatype of a column to varchar but get the
I am trying to alter a datatype for a derby db column. The current
I'm trying to alter a column on a table with this syntax: ALTER TABLE
How do I create a foreign key from table tGeoAnswers column 'locationId' to table
I’m trying to modify a table to make its primary key column AUTO_INCREMENT after
I'm trying to alter 2000 tables by adding a column to each. I achieve
I am trying to rename the column datatype from text to ntext but getting

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.