<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Fix : Error : Msg 2714, Level 16, State 6 &#8211; There is already an object named &#8216;#temp&#8217; in the database</title>
	<atom:link href="http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Thu, 09 Feb 2012 19:36:10 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-191495</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 09 Nov 2011 10:03:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-191495</guid>
		<description><![CDATA[drop table tempdb..#your_temp_table]]></description>
		<content:encoded><![CDATA[<p>drop table tempdb..#your_temp_table</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harsha Bhagat</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-190900</link>
		<dc:creator><![CDATA[Harsha Bhagat]]></dc:creator>
		<pubDate>Tue, 08 Nov 2011 14:26:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-190900</guid>
		<description><![CDATA[Hi Pinal,

In my TempDB, I have got some temp tables #T______________HexNumbers. 
Some of them have been created back in September 2011, but were not dropped.  I have found the procedures also where they were used, but they had dropped statements . Still the table are present .
How will I drop these tables?
The table names in tempdb..sysobjects are 
#T__________________________________________________________________________________________________________________000000002450
#T__________________________________________________________________________________________________________________00000000268B
#T__________________________________________________________________________________________________________________0000000029E2
#T__________________________________________________________________________________________________________________00000000205D
#T__________________________________________________________________________________________________________________00000000219A

Thanks,
Harsha]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>In my TempDB, I have got some temp tables #T______________HexNumbers.<br />
Some of them have been created back in September 2011, but were not dropped.  I have found the procedures also where they were used, but they had dropped statements . Still the table are present .<br />
How will I drop these tables?<br />
The table names in tempdb..sysobjects are<br />
#T__________________________________________________________________________________________________________________000000002450<br />
#T__________________________________________________________________________________________________________________00000000268B<br />
#T__________________________________________________________________________________________________________________0000000029E2<br />
#T__________________________________________________________________________________________________________________00000000205D<br />
#T__________________________________________________________________________________________________________________00000000219A</p>
<p>Thanks,<br />
Harsha</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kstr79</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-178110</link>
		<dc:creator><![CDATA[Kstr79]]></dc:creator>
		<pubDate>Wed, 12 Oct 2011 22:04:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-178110</guid>
		<description><![CDATA[This code works. Sourced from: http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/02c6da90-954d-487d-a823-e24b891ec1b0/

Code Snippet
if exists (
	select * from tempdb.dbo.sysobjects o
	where o.xtype in (&#039;U&#039;) 
	and o.id = object_id(N&#039;tempdb..#tempTable&#039;)
)
BEGIN
  DROP TABLE #tempTable; 
END]]></description>
		<content:encoded><![CDATA[<p>This code works. Sourced from: <a href="http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/02c6da90-954d-487d-a823-e24b891ec1b0/" rel="nofollow">http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/02c6da90-954d-487d-a823-e24b891ec1b0/</a></p>
<p>Code Snippet<br />
if exists (<br />
	select * from tempdb.dbo.sysobjects o<br />
	where o.xtype in (&#8216;U&#8217;)<br />
	and o.id = object_id(N&#8217;tempdb..#tempTable&#8217;)<br />
)<br />
BEGIN<br />
  DROP TABLE #tempTable;<br />
END</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-140190</link>
		<dc:creator><![CDATA[Alex]]></dc:creator>
		<pubDate>Fri, 10 Jun 2011 07:45:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-140190</guid>
		<description><![CDATA[@Abhijit

I&#039;ve tried your code and it works, but it fail when there&#039;s a 2byte character (e.g. Korean) in the name of temporary table.

So, to avoid an exception, I think it will be good to use &quot;IF EXISTS&quot; statement instead.

Example:
IF EXISTS(SELECT * FROM tempdb.dbo.sysobjects WHERE ID = OBJECT_ID(N&#039;[TempDB]..[#NewNEW_PROCESS_mbr엔티티]&#039;))
         DROP TABLE [#NewNEW_PROCESS_mbr엔티티]

-Alex

============================================

Just ignore my above comments, since I just identified that there&#039;s no problem with Abhijit&#039;s query even though there&#039;s a 2 byte character in the temporary table.
The reason why I had a problem is that I missed N before the table name :)

Incorrect:
  IF OBJECT_ID(&#039;[TempDB]..[#NewNEW_PROCESS_mbr엔티티]&#039;)) IS NOT NULL

Correct:
  IF OBJECT_ID(N&#039;[TempDB]..[#NewNEW_PROCESS_mbr엔티티]&#039;)) IS NOT NULL]]></description>
		<content:encoded><![CDATA[<p>@Abhijit</p>
<p>I&#8217;ve tried your code and it works, but it fail when there&#8217;s a 2byte character (e.g. Korean) in the name of temporary table.</p>
<p>So, to avoid an exception, I think it will be good to use &#8220;IF EXISTS&#8221; statement instead.</p>
<p>Example:<br />
IF EXISTS(SELECT * FROM tempdb.dbo.sysobjects WHERE ID = OBJECT_ID(N&#8217;[TempDB]..[#NewNEW_PROCESS_mbr엔티티]&#8216;))<br />
         DROP TABLE [#NewNEW_PROCESS_mbr엔티티]</p>
<p>-Alex</p>
<p>============================================</p>
<p>Just ignore my above comments, since I just identified that there&#8217;s no problem with Abhijit&#8217;s query even though there&#8217;s a 2 byte character in the temporary table.<br />
The reason why I had a problem is that I missed N before the table name :)</p>
<p>Incorrect:<br />
  IF OBJECT_ID(&#8216;[TempDB]..[#NewNEW_PROCESS_mbr엔티티]&#8216;)) IS NOT NULL</p>
<p>Correct:<br />
  IF OBJECT_ID(N&#8217;[TempDB]..[#NewNEW_PROCESS_mbr엔티티]&#8216;)) IS NOT NULL</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-140186</link>
		<dc:creator><![CDATA[Alex]]></dc:creator>
		<pubDate>Fri, 10 Jun 2011 07:37:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-140186</guid>
		<description><![CDATA[@Abhijit

I&#039;ve tried your code and it works, but it fail when there&#039;s a 2byte character (e.g. Korean) in the name of temporary table.

So, to avoid an exception, I think it will be good to use &quot;IF EXISTS&quot; statement instead.

Example:
IF EXISTS(SELECT * FROM tempdb.dbo.sysobjects WHERE ID = OBJECT_ID(N&#039;[TempDB]..[#NewNEW_PROCESS_mbr엔티티]&#039;))
         DROP TABLE [#NewNEW_PROCESS_mbr엔티티]

-Alex]]></description>
		<content:encoded><![CDATA[<p>@Abhijit</p>
<p>I&#8217;ve tried your code and it works, but it fail when there&#8217;s a 2byte character (e.g. Korean) in the name of temporary table.</p>
<p>So, to avoid an exception, I think it will be good to use &#8220;IF EXISTS&#8221; statement instead.</p>
<p>Example:<br />
IF EXISTS(SELECT * FROM tempdb.dbo.sysobjects WHERE ID = OBJECT_ID(N&#8217;[TempDB]..[#NewNEW_PROCESS_mbr엔티티]&#8216;))<br />
         DROP TABLE [#NewNEW_PROCESS_mbr엔티티]</p>
<p>-Alex</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manu</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-139720</link>
		<dc:creator><![CDATA[Manu]]></dc:creator>
		<pubDate>Wed, 08 Jun 2011 15:49:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-139720</guid>
		<description><![CDATA[Hello i found this post and I hope that I can find a solution asap. I am working on an ASP.net project on Visual Studio 2010, I am trying to set up a testing environment from an existing database and then I will try to restore all the data with a .bak file. Anyway when I try to run the script to create a table it gives me the same error that Rakesh got:
Msg 2714, Level 16, State 6, Line 1
There is already an object named &#039;Applicants&#039; in the database.

This is the code that I am trying to run and I validate it before running it:

CREATE TABLE [dbo].[Applicants](
	[APPLICANT_ID] [int] IDENTITY(1,1) NOT NULL,
	[FIRST_NAME] [varchar](50) NOT NULL,
	[MIDDLE] [varchar](50) NULL,
	[LAST_NAME] [varchar](50) NOT NULL,
	[EMAIL] [varchar](50) NULL,
	[PHONE] [varchar](30) NULL,
	[STREET] [varchar](100) NULL,
	[CITY] [varchar](50) NULL,
	[STATE] [varchar](20) NULL,
	[ZIP] [varchar](20) NULL,
	[APPLICANT_DATETIME] [datetime] NOT NULL,
 CONSTRAINT [PK_Applicants] PRIMARY KEY CLUSTERED 
(
	[APPLICANT_ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

This is part of a bigger script that completely fails when I validate saying that the database does not exist, but the database is there and I am connected.

Please let me know if you see anything wrong with the code, or if I have to do something else before I run the script, I am a newbie at this.

Thanks.

Manu]]></description>
		<content:encoded><![CDATA[<p>Hello i found this post and I hope that I can find a solution asap. I am working on an ASP.net project on Visual Studio 2010, I am trying to set up a testing environment from an existing database and then I will try to restore all the data with a .bak file. Anyway when I try to run the script to create a table it gives me the same error that Rakesh got:<br />
Msg 2714, Level 16, State 6, Line 1<br />
There is already an object named &#8216;Applicants&#8217; in the database.</p>
<p>This is the code that I am trying to run and I validate it before running it:</p>
<p>CREATE TABLE [dbo].[Applicants](<br />
	[APPLICANT_ID] [int] IDENTITY(1,1) NOT NULL,<br />
	[FIRST_NAME] [varchar](50) NOT NULL,<br />
	[MIDDLE] [varchar](50) NULL,<br />
	[LAST_NAME] [varchar](50) NOT NULL,<br />
	[EMAIL] [varchar](50) NULL,<br />
	[PHONE] [varchar](30) NULL,<br />
	[STREET] [varchar](100) NULL,<br />
	[CITY] [varchar](50) NULL,<br />
	[STATE] [varchar](20) NULL,<br />
	[ZIP] [varchar](20) NULL,<br />
	[APPLICANT_DATETIME] [datetime] NOT NULL,<br />
 CONSTRAINT [PK_Applicants] PRIMARY KEY CLUSTERED<br />
(<br />
	[APPLICANT_ID] ASC<br />
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]<br />
) ON [PRIMARY]</p>
<p>This is part of a bigger script that completely fails when I validate saying that the database does not exist, but the database is there and I am connected.</p>
<p>Please let me know if you see anything wrong with the code, or if I have to do something else before I run the script, I am a newbie at this.</p>
<p>Thanks.</p>
<p>Manu</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karan</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-135215</link>
		<dc:creator><![CDATA[Karan]]></dc:creator>
		<pubDate>Thu, 19 May 2011 09:26:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-135215</guid>
		<description><![CDATA[Hi Pinal,
Here is one interesting error i am continue to receive.
I am using sql server 2005. I am trying to create one new table but whenever i ran the below script i am getting the following error.
Msg 2714, Level 16, State 4, Line 1
There is already an object named &#039;TV_BookEMPDMAP_BKP_PROD&#039; in the database.
I make sure there is no such table exists in the database and i even tried to change the name of table but still no luck.

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TV_BookEMPDMAP_BKP_PROD](
	[BOOK] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[EMPLOYEE [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 CONSTRAINT [TV_BookEMPDMAP_BKP_PROD] PRIMARY KEY CLUSTERED 
(
	[BOOK] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

I used below query to verify such table does not exists.
select * from sys.tables where name LIKE &#039;TV_BookEMPDMAP_BKP_PROD%&#039;]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,<br />
Here is one interesting error i am continue to receive.<br />
I am using sql server 2005. I am trying to create one new table but whenever i ran the below script i am getting the following error.<br />
Msg 2714, Level 16, State 4, Line 1<br />
There is already an object named &#8216;TV_BookEMPDMAP_BKP_PROD&#8217; in the database.<br />
I make sure there is no such table exists in the database and i even tried to change the name of table but still no luck.</p>
<p>SET ANSI_NULLS ON<br />
GO<br />
SET QUOTED_IDENTIFIER ON<br />
GO<br />
SET ANSI_PADDING ON<br />
GO<br />
CREATE TABLE [dbo].[TV_BookEMPDMAP_BKP_PROD](<br />
	[BOOK] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,<br />
	[EMPLOYEE [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,<br />
 CONSTRAINT [TV_BookEMPDMAP_BKP_PROD] PRIMARY KEY CLUSTERED<br />
(<br />
	[BOOK] ASC<br />
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]<br />
) ON [PRIMARY]</p>
<p>GO<br />
SET ANSI_PADDING OFF</p>
<p>I used below query to verify such table does not exists.<br />
select * from sys.tables where name LIKE &#8216;TV_BookEMPDMAP_BKP_PROD%&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul O</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-132267</link>
		<dc:creator><![CDATA[Paul O]]></dc:creator>
		<pubDate>Sun, 01 May 2011 11:54:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-132267</guid>
		<description><![CDATA[After further review, this doesn&#039;t appear to work either.]]></description>
		<content:encoded><![CDATA[<p>After further review, this doesn&#8217;t appear to work either.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul O</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-132266</link>
		<dc:creator><![CDATA[Paul O]]></dc:creator>
		<pubDate>Sun, 01 May 2011 11:49:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-132266</guid>
		<description><![CDATA[Unfortunately I haven&#039;t been able to get this to work. I had to settle for the following which drops the temp table and ignores the error. SS 2008 R2

DECLARE @NOTHINGVAR VARCHAR(10)
DROP TABLE #result
IF @@ERROR 0
BEGIN
	SET @NOTHINGVAR = &#039;&#039;
END]]></description>
		<content:encoded><![CDATA[<p>Unfortunately I haven&#8217;t been able to get this to work. I had to settle for the following which drops the temp table and ignores the error. SS 2008 R2</p>
<p>DECLARE @NOTHINGVAR VARCHAR(10)<br />
DROP TABLE #result<br />
IF @@ERROR 0<br />
BEGIN<br />
	SET @NOTHINGVAR = &#8221;<br />
END</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: blah</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-90446</link>
		<dc:creator><![CDATA[blah]]></dc:creator>
		<pubDate>Fri, 01 Oct 2010 06:54:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-90446</guid>
		<description><![CDATA[nevermind.. i tried killing the connection - it only dropped the temp table, not the named constraint]]></description>
		<content:encoded><![CDATA[<p>nevermind.. i tried killing the connection &#8211; it only dropped the temp table, not the named constraint</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: blah</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-90436</link>
		<dc:creator><![CDATA[blah]]></dc:creator>
		<pubDate>Fri, 01 Oct 2010 05:55:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-90436</guid>
		<description><![CDATA[@DOUG FL,
u can try to find the connection that is still using that temp table, then kill it.
sp_who2 spid
dbcc inputbuffer (spid)
kill spid]]></description>
		<content:encoded><![CDATA[<p>@DOUG FL,<br />
u can try to find the connection that is still using that temp table, then kill it.<br />
sp_who2 spid<br />
dbcc inputbuffer (spid)<br />
kill spid</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manoj Pandey</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-84698</link>
		<dc:creator><![CDATA[Manoj Pandey]]></dc:creator>
		<pubDate>Fri, 20 Aug 2010 04:11:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-84698</guid>
		<description><![CDATA[Hi Pinal,
How about this scenario:

create procedure proc1 (@a int)
as
begin
  if @a=1
     create table #temp(a1 int)
   else
      create table #temp(a1 int)
drop table #temp
end

I also get this error : &quot;There is already an object named &#039;#temp&#039; in the database.&quot;

I know this is due to parsing or a kind of bug... but know the exact reason, please clarify?]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,<br />
How about this scenario:</p>
<p>create procedure proc1 (@a int)<br />
as<br />
begin<br />
  if @a=1<br />
     create table #temp(a1 int)<br />
   else<br />
      create table #temp(a1 int)<br />
drop table #temp<br />
end</p>
<p>I also get this error : &#8220;There is already an object named &#8216;#temp&#8217; in the database.&#8221;</p>
<p>I know this is due to parsing or a kind of bug&#8230; but know the exact reason, please clarify?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pragati</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-79797</link>
		<dc:creator><![CDATA[pragati]]></dc:creator>
		<pubDate>Sun, 11 Jul 2010 15:23:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-79797</guid>
		<description><![CDATA[Msg 2714, Level 16, State 6, Line 4
There is already an object named &#039;employee&#039; in the database.
when i fire the qury it does not give the proper answer plz give me answer soon
whatt is the solution on that type error]]></description>
		<content:encoded><![CDATA[<p>Msg 2714, Level 16, State 6, Line 4<br />
There is already an object named &#8216;employee&#8217; in the database.<br />
when i fire the qury it does not give the proper answer plz give me answer soon<br />
whatt is the solution on that type error</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve J</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-62558</link>
		<dc:creator><![CDATA[Steve J]]></dc:creator>
		<pubDate>Tue, 09 Mar 2010 23:58:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-62558</guid>
		<description><![CDATA[Thanks, This article helped answer my questions about this error.]]></description>
		<content:encoded><![CDATA[<p>Thanks, This article helped answer my questions about this error.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Srividhya</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-62530</link>
		<dc:creator><![CDATA[Srividhya]]></dc:creator>
		<pubDate>Tue, 09 Mar 2010 15:10:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-62530</guid>
		<description><![CDATA[hello,
I would like to send you couple of my stored procedures where i have some strange problem. The code is really long can i get your email id so that i can attach them for you to have a look?
thanks
Srividhya Sundaram]]></description>
		<content:encoded><![CDATA[<p>hello,<br />
I would like to send you couple of my stored procedures where i have some strange problem. The code is really long can i get your email id so that i can attach them for you to have a look?<br />
thanks<br />
Srividhya Sundaram</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stu</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-58772</link>
		<dc:creator><![CDATA[Stu]]></dc:creator>
		<pubDate>Thu, 17 Dec 2009 16:30:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-58772</guid>
		<description><![CDATA[Pinal, 
I recently changed to a DB developer, having only worked with &quot;Select&quot; for Access and .NET in the past. In this time I have used your solutions more time than I can tell you. This just saved my skin again. Thank you!]]></description>
		<content:encoded><![CDATA[<p>Pinal,<br />
I recently changed to a DB developer, having only worked with &#8220;Select&#8221; for Access and .NET in the past. In this time I have used your solutions more time than I can tell you. This just saved my skin again. Thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madeshwaran</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-53760</link>
		<dc:creator><![CDATA[Madeshwaran]]></dc:creator>
		<pubDate>Thu, 16 Jul 2009 12:21:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-53760</guid>
		<description><![CDATA[Hi pinal

I need solution for this fix 

Fix : Error : Msg 2714, Level 16, State 6 – There is already an object named ‘#temp’ in the database]]></description>
		<content:encoded><![CDATA[<p>Hi pinal</p>
<p>I need solution for this fix </p>
<p>Fix : Error : Msg 2714, Level 16, State 6 – There is already an object named ‘#temp’ in the database</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hitesh Ladva</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-53370</link>
		<dc:creator><![CDATA[Hitesh Ladva]]></dc:creator>
		<pubDate>Wed, 01 Jul 2009 09:53:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-53370</guid>
		<description><![CDATA[Hi,

I get the Msg 2714, Level 16, State 3 error message when running a script using SQLCMD, if i run the script directly in SQL Server 2008 it works without any problems.

The script file contains the following
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N&#039;[dbo].[usp_GetLoanBalanceHistory]&#039;) AND type in (N&#039;P&#039;, N&#039;PC&#039;))
DROP PROCEDURE [dbo].[usp_GetLoanBalanceHistory]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N&#039;[dbo].[usp_GetLoanBalanceHistory]&#039;) AND type in (N&#039;P&#039;, N&#039;PC&#039;))
BEGIN
EXEC dbo.sp_executesql @statement = N&#039;CREATE PROCEDURE [dbo].[usp_GetLoanBalanceHistory](@TransactionId int)
	
AS
BEGIN
	SET NOCOUNT ON;
	
	SELECT [LoanBalanceSnapShotId]
    FROM [dbo].[LoanBalanceSnapShot]
    WHERE [TransactionId] = @TransactionId;
    
END

&#039; 
END
GO

Also, sometimes the script will NOT generate an error but the proc still doesn&#039;t appear in the database. 

A couple of the My DBAs have had a look at this and they are baffled as to the cause. 

Thank you for your time and assitance.
Hitesh]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I get the Msg 2714, Level 16, State 3 error message when running a script using SQLCMD, if i run the script directly in SQL Server 2008 it works without any problems.</p>
<p>The script file contains the following<br />
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N&#8217;[dbo].[usp_GetLoanBalanceHistory]&#8216;) AND type in (N&#8217;P', N&#8217;PC&#8217;))<br />
DROP PROCEDURE [dbo].[usp_GetLoanBalanceHistory]<br />
GO</p>
<p>SET ANSI_NULLS ON<br />
GO</p>
<p>SET QUOTED_IDENTIFIER ON<br />
GO</p>
<p>IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N&#8217;[dbo].[usp_GetLoanBalanceHistory]&#8216;) AND type in (N&#8217;P', N&#8217;PC&#8217;))<br />
BEGIN<br />
EXEC dbo.sp_executesql @statement = N&#8217;CREATE PROCEDURE [dbo].[usp_GetLoanBalanceHistory](@TransactionId int)</p>
<p>AS<br />
BEGIN<br />
	SET NOCOUNT ON;</p>
<p>	SELECT [LoanBalanceSnapShotId]<br />
    FROM [dbo].[LoanBalanceSnapShot]<br />
    WHERE [TransactionId] = @TransactionId;</p>
<p>END</p>
<p>&#8216;<br />
END<br />
GO</p>
<p>Also, sometimes the script will NOT generate an error but the proc still doesn&#8217;t appear in the database. </p>
<p>A couple of the My DBAs have had a look at this and they are baffled as to the cause. </p>
<p>Thank you for your time and assitance.<br />
Hitesh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anthony</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-52004</link>
		<dc:creator><![CDATA[Anthony]]></dc:creator>
		<pubDate>Mon, 18 May 2009 11:53:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-52004</guid>
		<description><![CDATA[In sql 2005 or sql 2008, i use a try..catch loop to try and drop the table before creating it

begin try
	drop table #temp
end try
begin catch

end catch

create table #temp (
	col1 int
)]]></description>
		<content:encoded><![CDATA[<p>In sql 2005 or sql 2008, i use a try..catch loop to try and drop the table before creating it</p>
<p>begin try<br />
	drop table #temp<br />
end try<br />
begin catch</p>
<p>end catch</p>
<p>create table #temp (<br />
	col1 int<br />
)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug FL</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-50693</link>
		<dc:creator><![CDATA[Doug FL]]></dc:creator>
		<pubDate>Wed, 08 Apr 2009 22:24:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-50693</guid>
		<description><![CDATA[So can you forceably drop those tables? When I try to, I get the &quot;Cannot drop the table ‘#temp’, because it does not exist or you do not have permission&quot; error that the commentor above mentioned.  

I also have a constraint that I added to the temp table in the stored procedure. That constraint is now viewable in tempdb..sysobjects but I can not access it! The name of the constraint does not have the &quot;_______hex&quot; suffix on it. Because of this my sproc now fails because it tries to create the constraint but it already exists - although I can&#039;t get to it to drop it!

Yes I can check if it exists and not add it, but the constraint is attached to a &quot;dead&quot; temp table that I can not drop.

Thanks!]]></description>
		<content:encoded><![CDATA[<p>So can you forceably drop those tables? When I try to, I get the &#8220;Cannot drop the table ‘#temp’, because it does not exist or you do not have permission&#8221; error that the commentor above mentioned.  </p>
<p>I also have a constraint that I added to the temp table in the stored procedure. That constraint is now viewable in tempdb..sysobjects but I can not access it! The name of the constraint does not have the &#8220;_______hex&#8221; suffix on it. Because of this my sproc now fails because it tries to create the constraint but it already exists &#8211; although I can&#8217;t get to it to drop it!</p>
<p>Yes I can check if it exists and not add it, but the constraint is attached to a &#8220;dead&#8221; temp table that I can not drop.</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rakesh</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-50177</link>
		<dc:creator><![CDATA[Rakesh]]></dc:creator>
		<pubDate>Sun, 29 Mar 2009 19:19:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-50177</guid>
		<description><![CDATA[Pinal,
Few weeks ago, you have posted how to insert image in sql server. And i&#039;m still waiting for your answer for how to retrive image from sql server . I&#039;m wondering is there any way we can retreive without using .NET CLR coding. 

Thanks,
Rakesh]]></description>
		<content:encoded><![CDATA[<p>Pinal,<br />
Few weeks ago, you have posted how to insert image in sql server. And i&#8217;m still waiting for your answer for how to retrive image from sql server . I&#8217;m wondering is there any way we can retreive without using .NET CLR coding. </p>
<p>Thanks,<br />
Rakesh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rakesh</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-50176</link>
		<dc:creator><![CDATA[Rakesh]]></dc:creator>
		<pubDate>Sun, 29 Mar 2009 19:17:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-50176</guid>
		<description><![CDATA[Thanks a lot for the reply pinal. 
And also the above code should run on tempdb database . As temp tables are created in tempdb database.]]></description>
		<content:encoded><![CDATA[<p>Thanks a lot for the reply pinal.<br />
And also the above code should run on tempdb database . As temp tables are created in tempdb database.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michal</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-50175</link>
		<dc:creator><![CDATA[Michal]]></dc:creator>
		<pubDate>Sun, 29 Mar 2009 18:50:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-50175</guid>
		<description><![CDATA[Abhijit,

I think that using OBJECT_ID(’tempdb..#temp’) IS NOT NULL is one and only reasonable way in these two cases. 

#temp table exists in current session, so when you use OBJECT_ID you will get ID (or not, if not exists) of your own object from current session.

Executing:

IF EXISTS (SELECT * FROM tempdb.sys.tables WHERE name LIKE &#039;#temp%&#039;)
DROP TABLE #temp

you may get:

Msg 3701, Level 11, State 5, Line 2
Cannot drop the table &#039;#temp&#039;, because it does not exist or you do not have permission.

...there might be temporary table(s) with name &#039;#temp&#039; but not in your current session.]]></description>
		<content:encoded><![CDATA[<p>Abhijit,</p>
<p>I think that using OBJECT_ID(’tempdb..#temp’) IS NOT NULL is one and only reasonable way in these two cases. </p>
<p>#temp table exists in current session, so when you use OBJECT_ID you will get ID (or not, if not exists) of your own object from current session.</p>
<p>Executing:</p>
<p>IF EXISTS (SELECT * FROM tempdb.sys.tables WHERE name LIKE &#8216;#temp%&#8217;)<br />
DROP TABLE #temp</p>
<p>you may get:</p>
<p>Msg 3701, Level 11, State 5, Line 2<br />
Cannot drop the table &#8216;#temp&#8217;, because it does not exist or you do not have permission.</p>
<p>&#8230;there might be temporary table(s) with name &#8216;#temp&#8217; but not in your current session.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Abhijit</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-50172</link>
		<dc:creator><![CDATA[Abhijit]]></dc:creator>
		<pubDate>Sun, 29 Mar 2009 16:16:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-50172</guid>
		<description><![CDATA[Hi Pinal,
It can be also work with below code...

IF OBJECT_ID(&#039;tempdb..#temp&#039;) IS NOT NULL
DROP TABLE #temp

CREATE TABLE #temp....



-Abhijit&#039;]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,<br />
It can be also work with below code&#8230;</p>
<p>IF OBJECT_ID(&#8216;tempdb..#temp&#8217;) IS NOT NULL<br />
DROP TABLE #temp</p>
<p>CREATE TABLE #temp&#8230;.</p>
<p>-Abhijit&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rvYaFin</title>
		<link>http://blog.sqlauthority.com/2009/03/29/sql-server-fix-error-msg-2714-level-16-state-6-there-is-already-an-object-named-temp-in-the-database/#comment-50164</link>
		<dc:creator><![CDATA[rvYaFin]]></dc:creator>
		<pubDate>Sun, 29 Mar 2009 07:26:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4070#comment-50164</guid>
		<description><![CDATA[Luci explanation, thanks.

But this reminds me of the incomprehensable error messages that sql server produces: what do the Level, State and Line in the error message mean?  And is there any way to relate these items to the SQL code that produced them?]]></description>
		<content:encoded><![CDATA[<p>Luci explanation, thanks.</p>
<p>But this reminds me of the incomprehensable error messages that sql server produces: what do the Level, State and Line in the error message mean?  And is there any way to relate these items to the SQL code that produced them?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

