Showing posts with label varchar. Show all posts
Showing posts with label varchar. Show all posts

Wednesday, March 7, 2012

DDL Primer?

Ent Manager is nice, but I need to make some DDL changes to a database
(convert a column from char to varchar, add a new column, etc) with
SQL. Is there a good primer for this? I'm sure it is not too hard, I
just have not had to do this. Thanks.
-JohnElementary cases are well presented in Books Online.
E.g. (to alter a table and/or columns):
http://msdn.microsoft.com/library/d...br />
3ied.asp
ML
http://milambda.blogspot.com/|||...and use Query Analyzer. I forgot to mention.
ML
http://milambda.blogspot.com/|||"John Baima" <john@.nospam.com> wrote in message
news:f17gq1l0e6cted806ef0ub0ab3tflqmlt4@.
4ax.com...
> Ent Manager is nice, but I need to make some DDL changes to a database
> (convert a column from char to varchar, add a new column, etc) with
> SQL. Is there a good primer for this? I'm sure it is not too hard, I
> just have not had to do this. Thanks.
> -John
EM is "nice" but does a lot of "unneccessary" stuff behind the scenes.
When you change a column from Char to Varchar, it actually:
-creates a new table with the new DDL
-copies the data from the original to the new table
-drops the old table
-renames the new table
-drops and recreates constaints
So do you your charges in Query Analyser, like ML suggests.|||Plus - QA won't "assist" you in "clicking up" a potential disaster. :)
ML
http://milambda.blogspot.com/

DDL Changes breaks cubes

Hi,

Lately I had to increase the size of a table varchar column.

This column is used in a cube dimension attribute.

After the change, cube processing ended-up in error.

I had to first refresh the dataview and then go manually change the KeyColumns Datasize property to increase it as well.

Is there a better way? I find this very dangerous.
As a minimum, a dependency check should include cubes using that metadata.

I notticed the same type of problems on the SSIS sides, metadata becomes out of synch. This is not a show stopper but these are missing link in the dependency food chain.

Sub-systems are not integrated, they are in a vacuum. A little less than with 2000 but still in a vacuum.

Philippe

Very valuable observation.

This is something we are going to take a look at for the next version :)

Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights.

ddl

CREATE TABLE [INTIMINGS] (
[EMPID] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[INTIME] [datetime] NOT NULL ,
[EFFECTIVE_DATE] [smalldatetime] NULL ,
[END_DATE] [smalldatetime] NULL ,
[ENTERED_BY] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
CONSTRAINT [PK_INTIMINGS] PRIMARY KEY CLUSTERED
(
[EMPID]
) ON [PRIMARY]
) ON [PRIMARY]
GO
Insert into timings values(‘1ab’,1899-12-30
09:00.00.00,2003-07-01,00:00:00,’’,jym)
CREATE TABLE [INTIMINGS_HISTORY] (
[EMPID] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[INTIME] [datetime] NOT NULL ,
[EFFECTIVE_DATE] [smalldatetime] NOT NULL ,
[END_DATE] [smalldatetime] NULL ,
[ENTERED_BY] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
CONSTRAINT [PK_INTIMINGS_HISTORY] PRIMARY KEY CLUSTERED
(
[EMPID],
[EFFECTIVE_DATE]
) ON [PRIMARY]
) ON [PRIMARY]
GO
Insert into [INTIMINGS_HISTORY(‘1CMN’, 1899-12-30 09:00.00.00,’
‘2005-03-01,00:00:00’, ‘2005-02-08,00:00:00’

CREATE TABLE [EMPLOYEE_TIMINGS] (
[ENTRYTIME] [datetime] NOT NULL ,
[EMPID] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[TIMETYPE] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[INOUT] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[IP_ADDRESS] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
CONSTRAINT [PK_EMPLOYEE_TIMINGS] PRIMARY KEY CLUSTERED
(
[ENTRYTIME]
) ON [PRIMARY]
) ON [PRIMARY]
GO
Insert into EMPLOYEE_TIMINGS(
2003-10-01 00:03:29.000, VVR, S, E, NULL)
2003-10-01 00:03:38.000 SM S E NULL
2003-10-01 00:25:11.000 NA S E NULL
2003-10-01 00:25:18.000 NA S E NULL
2003-10-01 00:25:25.000 AMB S E NULL
2003-10-01 00:38:08.000 KRK S E NULL
2003-10-01 00:51:25.000 KU S E NULL
2003-10-01 02:00:38.000 NZ S E NULL
2003-10-01 05:50:47.000 1FC B S NULL
2003-10-01 06:06:04.000 1IB S E NULL
2003-10-01 06:06:14.000 IH S E NULL
2003-10-01 06:06:21.000 TO S E NULL
2003-10-01 06:07:12.000 EE S S NULL
2003-10-01 06:08:22.000 QX S S NULLwhat is the problem. check quotes in insert
--
Regards
R.D
--Knowledge gets doubled when shared
"raghu veer" wrote:

> CREATE TABLE [INTIMINGS] (
> [EMPID] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
> [INTIME] [datetime] NOT NULL ,
> [EFFECTIVE_DATE] [smalldatetime] NULL ,
> [END_DATE] [smalldatetime] NULL ,
> [ENTERED_BY] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> CONSTRAINT [PK_INTIMINGS] PRIMARY KEY CLUSTERED
> (
> [EMPID]
> ) ON [PRIMARY]
> ) ON [PRIMARY]
> GO
> Insert into timings values(‘1ab’,1899-12-30
> 09:00.00.00,2003-07-01,00:00:00,’’,jym)
>
>
> CREATE TABLE [INTIMINGS_HISTORY] (
> [EMPID] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
> [INTIME] [datetime] NOT NULL ,
> [EFFECTIVE_DATE] [smalldatetime] NOT NULL ,
> [END_DATE] [smalldatetime] NULL ,
> [ENTERED_BY] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> CONSTRAINT [PK_INTIMINGS_HISTORY] PRIMARY KEY CLUSTERED
> (
> [EMPID],
> [EFFECTIVE_DATE]
> ) ON [PRIMARY]
> ) ON [PRIMARY]
> GO
>
> Insert into [INTIMINGS_HISTORY(‘1CMN’, 1899-12-30 09:00.00.00,’
> ‘2005-03-01,00:00:00’, ‘2005-02-08,00:00:00’
>
>
>
>
>
>
>
>
>
> CREATE TABLE [EMPLOYEE_TIMINGS] (
> [ENTRYTIME] [datetime] NOT NULL ,
> [EMPID] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
> [TIMETYPE] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
> [INOUT] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
> [IP_ADDRESS] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> CONSTRAINT [PK_EMPLOYEE_TIMINGS] PRIMARY KEY CLUSTERED
> (
> [ENTRYTIME]
> ) ON [PRIMARY]
> ) ON [PRIMARY]
> GO
> Insert into EMPLOYEE_TIMINGS(
> 2003-10-01 00:03:29.000, VVR, S, E, NULL)
> 2003-10-01 00:03:38.000 SM S E NULL
> 2003-10-01 00:25:11.000 NA S E NULL
> 2003-10-01 00:25:18.000 NA S E NULL
> 2003-10-01 00:25:25.000 AMB S E NULL
> 2003-10-01 00:38:08.000 KRK S E NULL
> 2003-10-01 00:51:25.000 KU S E NULL
> 2003-10-01 02:00:38.000 NZ S E NULL
> 2003-10-01 05:50:47.000 1FC B S NULL
> 2003-10-01 06:06:04.000 1IB S E NULL
> 2003-10-01 06:06:14.000 IH S E NULL
> 2003-10-01 06:06:21.000 TO S E NULL
> 2003-10-01 06:07:12.000 EE S S NULL
> 2003-10-01 06:08:22.000 QX S S NULL
>