Vo2Ado Sql Server Adding Constraint

This is a discussion on Vo2Ado Sql Server Adding Constraint within the Clipper forums in Programming Languages category; 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) ...

Go Back   Application Development Forum > Programming Languages > Clipper

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-08-2008, 07:40 AM
Ian
Guest
 
Default Vo2Ado Sql Server Adding Constraint

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


Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 01:16 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.