Add to columns to a table then check the table structure : Add Column « Table « SQL Server / T-SQL

SQL Server / T-SQL
1. Aggregate Functions
2. Analytical Functions
3. Constraints
4. Cursor
5. Data Set
6. Data Type
7. Database
8. Date Timezone
9. Index
10. Insert Delete Update
11. Math Functions
12. Select Query
13. Sequence
14. Store Procedure Function
15. String Functions
16. Subquery
17. System
18. Table
19. Table Joins
20. Transact SQL
21. Transaction
22. Trigger
23. View
24. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
SQL Server / T-SQL » Table » Add Column 
Add to columns to a table then check the table structure

 

3>
4>
5>    CREATE TABLE Employees
6>    (
7>       EmployeeID       int           IDENTITY  NOT NULL,
8>       FirstName        varchar(25)             NOT NULL,
9>       MiddleInitial    char(1)                 NULL,
10>       LastName         varchar(25)             NOT NULL,
11>       Title            varchar(25)             NOT NULL,
12>       SSN              varchar(11)             NOT NULL,
13>       Salary           money                   NOT NULL,
14>       PriorSalary      money                   NOT NULL,
15>       LastRaise AS Salary - PriorSalary,
16>       HireDate         smalldatetime           NOT NULL,
17>       TerminationDate  smalldatetime           NULL,
18>       ManagerEmpID     int                     NOT NULL,
19>       Department       varchar(25)             NOT NULL
20>    )
21>    GO
1>
2>
3> EXEC sp_help Employees
4> GO
Name                                                                                                                             Owner
                                                          Type                            Created_datetime
-------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------
--------------------------------------------------------- ------------------------------- -----------------------
Employees                                                                                                                        dbo
                                                          user table                      2008-08-17 13:06:15.063


Column_name                                                                                                                      Type
                                                          Computed                            Length      Prec  Scale Nullable                            TrimTrailingBlanks                  FixedLenNu
llInSource                Collation
-------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------
--------------------------------------------------------- ----------------------------------- ----------- ----- ----- ----------------------------------- ----------------------------------- ----------
------------------------- --------------------------------------------------------------------------------------------------------------------------------
EmployeeID                                                                                                                       int
                                                          no                                            4 10    0     no                                  (n/a)                               (n/a)
                          NULL
FirstName                                                                                                                        varchar
                                                          no                                           25             no                                  no                                  no
                          SQL_Latin1_General_CP1_CI_AS
MiddleInitial                                                                                                                    char
                                                          no                                            1             yes                                 no                                  yes
                          SQL_Latin1_General_CP1_CI_AS
LastName                                                                                                                         varchar
                                                          no                                           25             no                                  no                                  no
                          SQL_Latin1_General_CP1_CI_AS
Title                                                                                                                            varchar
                                                          no                                           25             no                                  no                                  no
                          SQL_Latin1_General_CP1_CI_AS
SSN                                                                                                                              varchar
                                                          no                                           11             no                                  no                                  no
                          SQL_Latin1_General_CP1_CI_AS
Salary                                                                                                                           money
                                                          no                                            8 19    4     no                                  (n/a)                               (n/a)
                          NULL
PriorSalary                                                                                                                      money
                                                          no                                            8 19    4     no                                  (n/a)                               (n/a)
                          NULL
LastRaise                                                                                                                        money
                                                          yes                                           8 19    4     yes                                 (n/a)                               (n/a)
                          NULL
HireDate                                                                                                                         smalldatetime
                                                          no                                            4             no                                  (n/a)                               (n/a)
                          NULL
TerminationDate                                                                                                                  smalldatetime
                                                          no                                            4             yes                                 (n/a)                               (n/a)
                          NULL
ManagerEmpID                                                                                                                     int
                                                          no                                            4 10    0     no                                  (n/a)                               (n/a)
                          NULL
Department                                                                                                                       varchar
                                                          no                                           25             no                                  no                                  no
                          SQL_Latin1_General_CP1_CI_AS

Identity                                                                                                                         Seed                                     Increment
           Not For Replication
-------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------- ------------------------------
---------- -------------------
EmployeeID                                                                                                                                                              1
         1                   0

RowGuidCol
--------------------------------------------------------------------------------------------------------------------------------
No rowguidcol column defined.

Data_located_on_filegroup
--------------------------------------------------------------------------------------------------------------------------------
PRIMARY

The object 'Employees' does not have any indexes, or you do not have permissions.

No constraints are defined on object 'Employees', or you do not have permissions.

No foreign keys reference table 'Employees', or you do not have permissions on referencing tables.
Table is referenced by views
--------------------------------------------------------------------------------------------------------------------------------
1>    ALTER TABLE Employees
2>       ADD
3>          DateOfBirth     datetime   NULL,
4>          LastRaiseDate   datetime   NOT NULL
5>             DEFAULT '2000-01-01'
6>
7> GO
1>
2> EXEC sp_help Employees
3> GO
Name                                                                                                                             Owner
                                                          Type                            Created_datetime
-------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------
--------------------------------------------------------- ------------------------------- -----------------------
Employees                                                                                                                        dbo
                                                          user table                      2008-08-17 13:06:15.063


Column_name                                                                                                                      Type
                                                          Computed                            Length      Prec  Scale Nullable                            TrimTrailingBlanks                  FixedLenNu
llInSource                Collation
-------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------
--------------------------------------------------------- ----------------------------------- ----------- ----- ----- ----------------------------------- ----------------------------------- ----------
------------------------- --------------------------------------------------------------------------------------------------------------------------------
EmployeeID                                                                                                                       int
                                                          no                                            4 10    0     no                                  (n/a)                               (n/a)
                          NULL
FirstName                                                                                                                        varchar
                                                          no                                           25             no                                  no                                  no
                          SQL_Latin1_General_CP1_CI_AS
MiddleInitial                                                                                                                    char
                                                          no                                            1             yes                                 no                                  yes
                          SQL_Latin1_General_CP1_CI_AS
LastName                                                                                                                         varchar
                                                          no                                           25             no                                  no                                  no
                          SQL_Latin1_General_CP1_CI_AS
Title                                                                                                                            varchar
                                                          no                                           25             no                                  no                                  no
                          SQL_Latin1_General_CP1_CI_AS
SSN                                                                                                                              varchar
                                                          no                                           11             no                                  no                                  no
                          SQL_Latin1_General_CP1_CI_AS
Salary                                                                                                                           money
                                                          no                                            8 19    4     no                                  (n/a)                               (n/a)
                          NULL
PriorSalary                                                                                                                      money
                                                          no                                            8 19    4     no                                  (n/a)                               (n/a)
                          NULL
LastRaise                                                                                                                        money
                                                          yes                                           8 19    4     yes                                 (n/a)                               (n/a)
                          NULL
HireDate                                                                                                                         smalldatetime
                                                          no                                            4             no                                  (n/a)                               (n/a)
                          NULL
TerminationDate                                                                                                                  smalldatetime
                                                          no                                            4             yes                                 (n/a)                               (n/a)
                          NULL
ManagerEmpID                                                                                                                     int
                                                          no                                            4 10    0     no                                  (n/a)                               (n/a)
                          NULL
Department                                                                                                                       varchar
                                                          no                                           25             no                                  no                                  no
                          SQL_Latin1_General_CP1_CI_AS
DateOfBirth                                                                                                                      datetime
                                                          no                                            8             yes                                 (n/a)                               (n/a)
                          NULL
LastRaiseDate                                                                                                                    datetime
                                                          no                                            8             no                                  (n/a)                               (n/a)
                          NULL

Identity                                                                                                                         Seed                                     Increment
           Not For Replication
-------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------- ------------------------------
---------- -------------------
EmployeeID                                                                                                                                                              1
         1                   0

RowGuidCol
--------------------------------------------------------------------------------------------------------------------------------
No rowguidcol column defined.

Data_located_on_filegroup
--------------------------------------------------------------------------------------------------------------------------------
PRIMARY

The object 'Employees' does not have any indexes, or you do not have permissions.

constraint_type                                                                                                                                    constraint_name
                                                                            delete_action update_action status_enabled status_for_replication constraint_keys











-------------------------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------
--------------------------------------------------------------------------- ------------- ------------- -------------- ---------------------- ----------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------
DEFAULT on column LastRaiseDate                                                                                                                    DF__Employees__LastR__0F0E1094
                                                                            (n/a)         (n/a)         (n/a)          (n/a)                  ('2000-01-01')












No foreign keys reference table 'Employees', or you do not have permissions on referencing tables.
Table is referenced by views
--------------------------------------------------------------------------------------------------------------------------------
1>    drop table Employees;
2>    GO
1>

 
Related examples in the same category
1. Alter table to add column
2. Add columns to a table
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.