| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Hi All, I have produced a script from sql server 2008 to create the database and tables required by my app. I have then translated this into vo2ado commands to create the database and tables wjen the user first runs the app using the following eaxmple. cNewSql := " IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = ; OBJECT_ID(N'[dbo].[CLNTVIEWHEADER]') AND type in (N'U'))" cNewSql += " BEGIN" cNewSql += " CREATE TABLE [dbo].[CLNTVIEWHEADER](" cNewSql += " [RECID] [int] IDENTITY(1,1) NOT null," cNewSql += " [TRANSNUM] [char](9) null," cNewSql += " [LASTSAVE] [char](16) null," cNewSql += " [VIEWNAME] [char](50) NOT null," cNewSql += " [INUSEBY] [char](6) null" cNewSql += " ) ON [PRIMARY]" cNewSql += " end" AAdd(aSqlArray,cNewSql) cNewSql := " SET ANSI_NULLS ON" AAdd(aSqlArray,cNewSql) cNewSql := " SET QUOTED_IDENTIFIER ON" AAdd(aSqlArray,cNewSql) CreateSqlTables(aSqlArray,"",oDataConn) This works ok for all of the tables I need to create. The problem is thaat some tables require this from the sql script " CONSTRAINT [PK_CLNTVIEWHEADER] PRIMARY KEY CLUSTERED ( [VIEWNAME] ASC)with (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]" I have tried to add this in before and after the end statement but it always returns an error. I have tried to process it as an ALTER TABLE instruction after the create sqltables command but that returns an error also. Any ideas how I can add the CONSTRAINT instruction to the above code so it processes without error. Kind Regards, Ian |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.