Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. how to write a query change the datatype for primary key coulm in atable using sqlserver 2008.

how to write a query change the datatype for primary key coulm in atable using sqlserver 2008.

Scheduled Pinned Locked Moved Database
databasetutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Ch Gayatri Subudhi
    wrote on last edited by
    #1

    how to write a query change the datatype for primary key coulm in atable using sqlserver 2008. Thnaks In advance Ch.Gayatri

    M 1 Reply Last reply
    0
    • C Ch Gayatri Subudhi

      how to write a query change the datatype for primary key coulm in atable using sqlserver 2008. Thnaks In advance Ch.Gayatri

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      use ALTER TABLE, you might also consider this[^].

      Never underestimate the power of human stupidity RAH

      C 1 Reply Last reply
      0
      • M Mycroft Holmes

        use ALTER TABLE, you might also consider this[^].

        Never underestimate the power of human stupidity RAH

        C Offline
        C Offline
        Ch Gayatri Subudhi
        wrote on last edited by
        #3

        i tired but its did not worked ou becoz my primary key is used as Fkey in so many tables.

        M 1 Reply Last reply
        0
        • C Ch Gayatri Subudhi

          i tired but its did not worked ou becoz my primary key is used as Fkey in so many tables.

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          Then you have a serious design problem, what are the data type changes you want to affect? You could do this right by: Identify and drop all the FK referencing the table use alter table to change the data type on the redacted table change the data types on all the fk fields recreate the fk you identified and dropped.

          Never underestimate the power of human stupidity RAH

          L 1 Reply Last reply
          0
          • M Mycroft Holmes

            Then you have a serious design problem, what are the data type changes you want to affect? You could do this right by: Identify and drop all the FK referencing the table use alter table to change the data type on the redacted table change the data types on all the fk fields recreate the fk you identified and dropped.

            Never underestimate the power of human stupidity RAH

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            You are in big problem, just drop refference and recreate them. Thanks

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups