Friday, March 9, 2012

msg : 2714

II am trying to create table through Query Analyzer. an error message appears
"Server: Msg 2714, Level 16, State 4, Line 1
There is already an object named 'ACTIVITY_TABLE' in the database."
the table does not exists in the DB I used following scripts to create table
create table dbo.ACTIVITY_TABLE (
ACTIVITY_DEPT_CODE numeric(10) not null,
ACTIVITY_CODE numeric(2) not null,
ACTIVITY_LOCAL_CODE numeric(9) null,
ACTIVITY_DESC varchar(200) null,
CORDINATOR_CODE varchar(50) null,
LASTUSERID varchar(8) not null,
LASTDATE datetime not null,
ACTIVITY_IND varchar(1) null,
constraint ACTIVITY_TABLE primary key (ACTIVITY_DEPT_CODE, ACTIVITY_CODE)
)
GoHi
Rename you constraint to something else. Only 1 object in a DB can have a
specific name. Your Table and your Constraint have the same name which is
not allowed
e.g.
constraint cons_ACTIVITY_TABLE primary key (ACTIVITY_DEPT_CODE,
ACTIVITY_CODE)
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Adel" <Adel@.discussions.microsoft.com> wrote in message
news:3FE4F90F-D387-4F81-9576-51C31C9D79C1@.microsoft.com...
> II am trying to create table through Query Analyzer. an error message
appears
> "Server: Msg 2714, Level 16, State 4, Line 1
> There is already an object named 'ACTIVITY_TABLE' in the database."
> the table does not exists in the DB I used following scripts to create
table
> create table dbo.ACTIVITY_TABLE (
> ACTIVITY_DEPT_CODE numeric(10) not null,
> ACTIVITY_CODE numeric(2) not null,
> ACTIVITY_LOCAL_CODE numeric(9) null,
> ACTIVITY_DESC varchar(200) null,
> CORDINATOR_CODE varchar(50) null,
> LASTUSERID varchar(8) not null,
> LASTDATE datetime not null,
> ACTIVITY_IND varchar(1) null,
> constraint ACTIVITY_TABLE primary key (ACTIVITY_DEPT_CODE,
ACTIVITY_CODE)
> )
> Go
>
>|||Many people use a postscript, or prescript kind of name,,, I would use
Activity_table_PK, so when names are sorted all of the activity-table stuff
sorts together..
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Adel" <Adel@.discussions.microsoft.com> wrote in message
news:3FE4F90F-D387-4F81-9576-51C31C9D79C1@.microsoft.com...
> II am trying to create table through Query Analyzer. an error message
> appears
> "Server: Msg 2714, Level 16, State 4, Line 1
> There is already an object named 'ACTIVITY_TABLE' in the database."
> the table does not exists in the DB I used following scripts to create
> table
> create table dbo.ACTIVITY_TABLE (
> ACTIVITY_DEPT_CODE numeric(10) not null,
> ACTIVITY_CODE numeric(2) not null,
> ACTIVITY_LOCAL_CODE numeric(9) null,
> ACTIVITY_DESC varchar(200) null,
> CORDINATOR_CODE varchar(50) null,
> LASTUSERID varchar(8) not null,
> LASTDATE datetime not null,
> ACTIVITY_IND varchar(1) null,
> constraint ACTIVITY_TABLE primary key (ACTIVITY_DEPT_CODE,
> ACTIVITY_CODE)
> )
> Go
>
>

No comments:

Post a Comment