SQL insert default value

Posted by Stan on Stack Overflow See other posts from Stack Overflow or by Stan
Published on 2010-05-27T18:11:25Z Indexed on 2010/05/27 18:21 UTC
Read the original article Hit count: 151

Filed under:

Say if I have a table like

CREATE TABLE [Message] (
    [MessageIdx] [int] IDENTITY (1, 1) NOT NULL ,
    [Message] [varchar] (1024) COLLATE Latin1_General_CI_AS NOT NULL ,
    [ValidUntil] [datetime] NULL ,
    CONSTRAINT [PK_Message] PRIMARY KEY  CLUSTERED 
    (
        [MessageIdx]
    ) WITH  FILLFACTOR = 90  ON [PRIMARY] 
) ON [PRIMARY]
GO

I am trying to insert value without specify column names explicitly. Below statement causes error. How can I do that? Thanks.

set identity_insert caconfig..fxmessage on;
insert into message values (DEFAULT,'blah',DEFAULT);
set identity_insert caconfig..fxmessage off;

© Stack Overflow or respective owner

Related posts about sql-server