From: Ginny Caughey on 15 Jun 2010 10:14 You must get SSMS. I can't imagine writing for SQL Server without it, and it's free. -- Ginny Caughey www.wasteworks.com
From: Ginny Caughey on 15 Jun 2010 10:21 I create all my tables programmatically like this: public const string CreateOriginString = "CREATE TABLE [dbo].[Origin](" + "[ORIGIN] [varchar] (25) NOT NULL DEFAULT('')," + "[WIZARDKEY] [varchar] (10) NOT NULL DEFAULT('')," + "[GROUPTYPE] [varchar] (10) NOT NULL DEFAULT('')," + "[SURCHGPCT] [int] NOT NULL DEFAULT(0), " + "[CreationDate] [datetime] default getutcdate()," + "[LastEditDate] [datetime] default getutcdate()," + "[Guid] [uniqueidentifier] ROWGUIDCOL NOT NULL DEFAULT (newsequentialid())," + "[SyncOriginator] [int] not null default(0), " + " CONSTRAINT [PK_Origin] PRIMARY KEY CLUSTERED ([ORIGIN] ASC) " + "WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]"+ ") ON [PRIMARY]"; public void CreateOriginTable() { SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = CreateOriginString; cmd.ExecuteNonQuery(); } This happens to be C# code that creates the table, but you can do essentially the same in VO. -- Ginny Caughey www.wasteworks.com
From: Kevin on 15 Jun 2010 11:35 Ginny, I have SSMS installed now and the SQL runs there and now also runs in SQL Master as well. I must have missed something earlier but I can't see what it was. I have the program creating SQL tables through an ADOCommand but all the columns don't have default values. I had been wondering how to change the properties of a column without having to rebuild the table. Thanks for the pointers. Kevin "Ginny Caughey" <ginny.caughey.online(a)wasteworks.com> wrote in message news:4c178bb8$0$16151$c3e8da3(a)news.astraweb.com: > I create all my tables programmatically like this: > > public const string CreateOriginString = > "CREATE TABLE [dbo].[Origin](" + > "[ORIGIN] [varchar] (25) NOT NULL DEFAULT('')," + > "[WIZARDKEY] [varchar] (10) NOT NULL DEFAULT('')," + > "[GROUPTYPE] [varchar] (10) NOT NULL DEFAULT('')," + > "[SURCHGPCT] [int] NOT NULL DEFAULT(0), " + > "[CreationDate] [datetime] default getutcdate()," + > "[LastEditDate] [datetime] default getutcdate()," + > "[Guid] [uniqueidentifier] ROWGUIDCOL NOT NULL DEFAULT > (newsequentialid())," + > "[SyncOriginator] [int] not null default(0), " + > " CONSTRAINT [PK_Origin] PRIMARY KEY CLUSTERED ([ORIGIN] ASC) " + > "WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]"+ > ") ON [PRIMARY]"; > > public void CreateOriginTable() > { > SqlCommand cmd = conn.CreateCommand(); > cmd.CommandText = CreateOriginString; > cmd.ExecuteNonQuery(); > } > > > This happens to be C# code that creates the table, but you can do > essentially the same in VO. > > -- > > Ginny Caughey > www.wasteworks.com
From: Ginny Caughey on 15 Jun 2010 11:46 Kevin, You can add defaults with script: ALTER TABLE [dbo].[Origin] ADD DEFAULT ('') FOR [Origin] Easy way to learn this stuff: create a new little table with NOT NULL and defaults. Then right-click on that table in SSMS and select Script Table as Create to New Query Editor window and look at the code. -- Ginny Caughey www.wasteworks.com
From: Kevin on 15 Jun 2010 12:38 Ginny, I had found the code alright, not using SSMS but a web page. Thanks again. Kevin "Ginny Caughey" <ginny.caughey.online(a)wasteworks.com> wrote in message news:4c179f94$0$1320$c3e8da3(a)news.astraweb.com: > Kevin, > > You can add defaults with script: > > ALTER TABLE [dbo].[Origin] ADD DEFAULT ('') FOR [Origin] > > Easy way to learn this stuff: create a new little table with NOT NULL and > defaults. Then right-click on that table in SSMS and select Script Table as > Create to New Query Editor window and look at the code. > > -- > > Ginny Caughey > www.wasteworks.com
First
|
Prev
|
Pages: 1 2 3 4 5 6 Prev: Structure from OleAutoObject control Next: Experience with simple bugtracking/change mgt tools |