开发者

How do I insert a row in T-SQL where there are only auto-generated columns?

开发者 https://www.devze.com 2023-04-11 10:51 出处:网络
I have a table like this: CREATE TABLE [dbo].[TRACEABLE]( [TRACEABLE_ID] [uniqueidentifier] NOT NULL CONSTRAINT [DF_TRACEABLE_TRACEABLE_ID]DEFAULT (newsequentialid()),

I have a table like this:

CREATE TABLE [dbo].[TRACEABLE](
        [TRACEABLE_ID] [uniqueidentifier] NOT NULL 
              CONSTRAINT [DF_TRACEABLE_TRACEABLE_ID]  DEFAULT (newsequentialid()),
 CONSTRAINT [PK_TRACEABLE] PRIMARY KEY CLUSTERED 
(
    [TRACEABLE_ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

How do I insert a row into this table? This doesn't work:

INSERT INTO TRACEABLE() VALUES开发者_如何学JAVA()

It errors on the VALUES() clause (Incorrect syntax near ')'). Taking out the brackets doesn't work either.


INSERT INTO TRACEABLE DEFAULT VALUES;

or

INSERT INTO TRACEABLE VALUES (DEFAULT);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号