MSSMS 2008 rs error

Go To StackoverFlow.com

0

This is my current table.

USE [PS_GameData]
GO

/****** Object:  Table [dbo].[Guilds]    Script Date: 04/04/2012 11:58:35 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Guilds](
    [RowID] [int] IDENTITY(1,1) NOT NULL,
    [GuildID] [int] NOT NULL,
    [GuildName] [varchar](30) NOT NULL,
    [MasterUserID] [varchar](12) NOT NULL,
    [MasterCharID] [int] NOT NULL,
    [MasterName] [varchar](30) NOT NULL,
    [Country] [tinyint] NOT NULL,
    [TotalCount] [smallint] NOT NULL,
    [GuildPoint] [int] NOT NULL,
    [Del] [tinyint] NOT NULL,
    [CreateDate] [datetime] NOT NULL,
    [DeleteDate] [datetime] NULL,
 CONSTRAINT [PK_Guilds] PRIMARY KEY CLUSTERED 
(
    [GuildID] ASC
) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS =   ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Guilds] ADD  CONSTRAINT [DF_Guilds_Del]  DEFAULT ((0)) FOR [Del]
GO

I am trying to change it to this.

USE [PS_GameData]
GO
/****** Object: Table [dbo].[Guilds] Script Date: 09/29/2011 06:36:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Guilds](
    [RowID] [int] IDENTITY(1,1) NOT NULL,
    [GuildID] [int] NOT NULL,
    [GuildName] [varchar](30) COLLATE Chinese_PRC_Stroke_CI_AI NOT NULL,
    [MasterUserID] [varchar](12) COLLATE Chinese_PRC_Stroke_CI_AI NOT NULL,
    [MasterCharID] [int] NOT NULL,
    [MasterName] [varchar](30) COLLATE Chinese_PRC_Stroke_CI_AI NOT NULL,
    [Country] [tinyint] NOT NULL,
    [TotalCount] [smallint] NOT NULL,
    [GuildPoint] [int] NOT NULL,
    [Del] [tinyint] NOT NULL CONSTRAINT [DF_Guilds_Del] DEFAULT (0),
    [CreateDate] [datetime] NOT NULL,
    [DeleteDate] [datetime] NULL,
CONSTRAINT [PK_Guilds] PRIMARY KEY CLUSTERED 
(
    [GuildID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF  

This is my error:

Msg 2714, Level 16, State 6, Line 2
There is already an object named 'Guilds' in the database.
Msg 1781, Level 16, State 1, Line 2
Column already has a DEFAULT bound to it.
Msg 1750, Level 16, State 0, Line 2
Could not create constraint. See previous errors.

I have already dropped table Guilds and tried to create another table named guilds and insert the script but the script stays the same or it says Guilds is already in database.

2012-04-04 17:19
by Trish Bijeaux


0

Try explicitly dropping the table at the beginning of your new DDL:

USE [PS_GameData]
GO
if exists(
    select 1
    from sys.objects o
    inner join sys.schemas s on s.schema_id=o.schema_id
    where o.[type]='U'
    and s.name='dbo'
    and o.name='Guilds'
)
drop table [dbo].[Guilds];
go

/****** Object: Table [dbo].[Guilds] Script Date: 09/29/2011 06:36:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Guilds](
    [RowID] [int] IDENTITY(1,1) NOT NULL,
    [GuildID] [int] NOT NULL,
    [GuildName] [varchar](30) COLLATE Chinese_PRC_Stroke_CI_AI NOT NULL,
    [MasterUserID] [varchar](12) COLLATE Chinese_PRC_Stroke_CI_AI NOT NULL,
    [MasterCharID] [int] NOT NULL,
    [MasterName] [varchar](30) COLLATE Chinese_PRC_Stroke_CI_AI NOT NULL,
    [Country] [tinyint] NOT NULL,
    [TotalCount] [smallint] NOT NULL,
    [GuildPoint] [int] NOT NULL,
    [Del] [tinyint] NOT NULL CONSTRAINT [DF_Guilds_Del] DEFAULT (0),
    [CreateDate] [datetime] NOT NULL,
    [DeleteDate] [datetime] NULL,
CONSTRAINT [PK_Guilds] PRIMARY KEY CLUSTERED 
(
    [GuildID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
2012-04-05 01:11
by John Dewey
Ads