faqts : Computers : Databases : Microsoft SQL Server

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

3 of 3 people (100%) answered Yes
Recently 3 of 3 people (100%) answered Yes

Entry

Database:Microsoft SQLserver:SQL:Table:Operation:Create:How create table with primary key, manually?

Dec 22nd, 2003 13:06
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 22 December 2003 - 10:00 pm -------------------

Database:Microsoft SQLserver:SQL:Table:Operation:Create:How create 
table with primary key, manually?

---

For example, you want to create
one table with person information
and a primary key

---

Steps: Overview:

 1. -Possibly design your tables

      Table 1:

      ---

      Table 'Person'
      ----------------------------------------------------
      NAME                     PERSONKEY (=PRIMARY KEY)
      ----------------------------------------------------
      john doe                 1
      vanessa beau             2
      ----------------------------------------------------

 2. -Create your tables

     Steps: Overview:

      1. -Open Microsoft SQL server 'Enterprise Manager'

      2. -Expand 'Microsoft SQL Servers' in the left pane
          (by clicking on the '+')

      3. -Expand 'SQL Server Group' in the left pane
          (by clicking on the '+')

      4. -Expand the server of your choice
          (e.g. your (local) (Windows NT) server
          (by clicking on the '+')

      5. -Expand 'Databases' (click on the '+')

      6. -Expand the database in which you want to
         add a table
         (e.g. click on the '+' of 'mydatabase')

      7. -Right click on 'Tables' in the list

      8. -Select from list 'Design table'

      9. -Possibly change some information:

          1. Fill in your data for the first column

             1. Click on the column below 'Column Name'
                and fill in a name for the table

                e.g.

                 Name

             2. Choose the type from the list:

                e.g.

                 varchar

             3. Length

                e.g.

                 50

          2. Fill in your data for the second column

             1. Click on the column below 'Column Name',
                go to the next row,
                and fill in a name for the table

                e.g.

                 PersonKey

             2. Choose the type from the list:

                e.g.

                 int

             3. Length

                e.g. leave the default:

                 4

             4. Now right click on this row

                1. -select from list 'Set Primary key'

                    You should now see a yellow key
                    appearing on this row

     10. -Important: expand this windows in order to see the
          menu (otherwise this menu is not shown) by clicking
          in the right corner on the window expand button
          [] (as usual in a Microsoft Windows window).
          So maximize the window.

     11. -Save this table

          1. E.g. click on the floppy disk icon on the menu taskbar

          2. You are asked to supply a table name
             (if this table did not exist already)

     12. -Exit the program (e.g. click on the 'x' in the right corner
          of the window)

---
---

Internet: see also:

---

Database: Microsoft SQL server: SQL: Operation: Overview:Can you give 
an overview of SQL operations?
http://www.faqts.com/knowledge_base/view.phtml/aid/27560/fid/147

----------------------------------------------------------------------