locked
create table script RRS feed

  • Question

  • Hi

    I need a create table script (see bottom), where a field-description will be placed beside every field. In addition the field timestamp should contain the defaultvalue of the current time.

    Thanks for your hint.

    Patrick

    CREATE

     

    TABLE dbo.Example

    (

    ID

    INT IDENTITY(1,1) PRIMARY KEY,

    ContentID

    NVARCHAR(255),

    TimeStamp SMALLDATETIME

    )

    GO

    Tuesday, November 2, 2010 2:51 PM

Answers

  • CREATE TABLE [dbo].[Example](
    [ID] [int] IDENTITY(1,1) NOT NULL Primary key,
    [ContentID] [nvarchar](255) NULL,
    [TimeStamp] [smalldatetime] NULL CONSTRAINT [DF_Example_TimeStamp] DEFAULT (getdate())
    )
    GO
    EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'DESC0' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Example', @level2type=N'COLUMN',@level2name=N'ID'
    GO
    EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'DESCR1' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Example', @level2type=N'COLUMN',@level2name=N'ContentID'
    GO
    EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'DESC2' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Example', @level2type=N'COLUMN',@level2name=N'TimeStamp'

     

     

     


    Best regards

     

    • Proposed as answer by Naomi N Tuesday, November 2, 2010 6:48 PM
    • Marked as answer by Kalman Toth Monday, November 8, 2010 8:51 AM
    Tuesday, November 2, 2010 2:57 PM

All replies

  • CREATE TABLE [dbo].[Example](
    [ID] [int] IDENTITY(1,1) NOT NULL Primary key,
    [ContentID] [nvarchar](255) NULL,
    [TimeStamp] [smalldatetime] NULL CONSTRAINT [DF_Example_TimeStamp] DEFAULT (getdate())
    )
    GO
    EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'DESC0' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Example', @level2type=N'COLUMN',@level2name=N'ID'
    GO
    EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'DESCR1' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Example', @level2type=N'COLUMN',@level2name=N'ContentID'
    GO
    EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'DESC2' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Example', @level2type=N'COLUMN',@level2name=N'TimeStamp'

     

     

     


    Best regards

     

    • Proposed as answer by Naomi N Tuesday, November 2, 2010 6:48 PM
    • Marked as answer by Kalman Toth Monday, November 8, 2010 8:51 AM
    Tuesday, November 2, 2010 2:57 PM
  • To ALL:

    Do use INSERT CODE BLOCK when posting code.

    Thanks.


    Kalman Toth, SQL Server & Business Intelligence Training; SQL 2008 GRAND SLAM
    Monday, November 8, 2010 8:54 AM