Need to extend length of PK

  • Lynn Pettis

    SSC Guru

    Points: 442116

    And, in your case, you don't need the CREATE TABLE statement(s) as the tables already exist.  All you need to write are the ALTER TABLE statements to change the correct column from NVARCHAR(5) or NVARCHAR(7) to NVARCHAR(10).

     

  • Steve Jones - SSC Editor

    SSC Guru

    Points: 714698

    You really shouldn't trust my code, or anyone's, without verifying it.

    You do need to learn how to do this,or get someone else to help you with this. While we can provide some guidance here, it's reckless for you to make these changes without someone there that understands this.

     

    I assume you're using SQL Server Manaagement Studio? SSMS? Then you would connect to a server, open a query window (New Query Window), and you can run my code. You would likely want to highlight each section between the Go statements and then click Execute.

    You can observe some changes then, but if you don't understand how SQL Server and T-SQL works, it's hard to explain.

    To actually make this work for your system, you ought to restore a backup in a test environment. Then you can just change my ALTER TABLE line to reference your table, your column, and set the appropriate size.

     

  • jdasilva

    Ten Centuries

    Points: 1056

    Totally understood Steve.  I do understand the code itself.  I have run a few SQL statements, thought it was not formally trained, so, over the months of not doing any other SQL, the knowledge slips away.  Unfortunately, there is no one here (or close here) that can mentor me on this, or has time.

    The key piece I needed was the New Query window.  I am talking with someone that transferred to our company that used to do SQL a long time ago now, so he can prevent me from breaking anything to severely  🙂

    Thanks again for all the assistance here.  I still think I'm a few days away from trying this out (test DB), as I want to make sure I am good with all that is going on.  But I have a starting  point that I feel safe to start testing with.

    Thanks all again.  I don't see any vote up/prestige/high five/etc. buttons anywhere here, but at least one to all of you.  Thanks.

  • Steve Jones - SSC Editor

    SSC Guru

    Points: 714698

    You are quite welcome. If you have more questions on this, post again. If there's something else,or you get lost in SSMS, just ask. We're happy to try and help.

Viewing 4 posts - 16 through 19 (of 19 total)

You must be logged in to reply to this topic. Login to reply