Script for data in tables with computed columns

Topics: Database Publishing Wizard
Dec 3, 2006 at 6:29 AM
In Database Publishing Wizard CTP 2 (Release 0.2.0.0 Beta), the script for inserting data in tables with computed columns is incorrectly generated. For example, create a table and insert some data in it, using the following script:

CREATE DATABASE TestDatabase
GO
USE TestDatabase

CREATE TABLE T (
A int,
B int,
C AS A+B
)

INSERT INTO T VALUES (1,2)

The Database Publishing Wizard CTP 2 generates the following script:

/****** Object: Table dbo.T Script Date: 12/03/2006 09:24:18 ******/
IF EXISTS (SELECT * FROM sys.objects WHERE objectid = OBJECTID(N'dbo.T') AND type in (N'U'))
DROP TABLE dbo.T
GO
/****** Object: Table dbo.T Script Date: 12/03/2006 09:24:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE objectid = OBJECTID(N'dbo.T') AND type in (N'U'))
BEGIN
CREATE TABLE dbo.T(
Aint NULL,
Bint NULL,
C AS (A+B)
) ON PRIMARY
END
GO
INSERT dbo.T (A, B, C) VALUES (1, 2, 3)

which fails with the error:

Msg 271, Level 16, State 1, Line 1
The column "C" cannot be modified because it is either a computed column or is the result of a UNION operator.

Razvan
Dec 6, 2006 at 3:23 AM
Thanks for the report. We are looking into this.

alex
Dec 12, 2006 at 5:14 PM
Wanted to let you know that we have fixed this in our upcoming release.

Thanks,
alex