Home All Groups Group Topic Archive Search About

how to rename a temp table

Author
1 Sep 2005 12:56 PM
Sam
EXEC sp_rename '#customers', '#custs'
result with error :Invalid object name '#customers'.

how to rename a temp table?

Author
1 Sep 2005 12:10 PM
Uri Dimant
Sam
sp_rename
Changes the name of a user-created object (for example, table, column, or
user-defined data type) in the current database.







Show quote
"Sam" <focu***@zahav.net.il> wrote in message
news:ecE3BxurFHA.2008@TK2MSFTNGP10.phx.gbl...
> EXEC sp_rename '#customers', '#custs'
> result with error :Invalid object name '#customers'.
>
> how to rename a temp table?
>
>
>
>
Author
1 Sep 2005 12:21 PM
Dan Guzman
Uri, I believe sp_rename disallows renaming temp objects.

--
Hope this helps.

Dan Guzman
SQL Server MVP

Show quote
"Uri Dimant" <u***@iscar.co.il> wrote in message
news:OziOz4urFHA.240@tk2msftngp13.phx.gbl...
> Sam
> sp_rename
> Changes the name of a user-created object (for example, table, column, or
> user-defined data type) in the current database.
>
>
>
>
>
>
>
> "Sam" <focu***@zahav.net.il> wrote in message
> news:ecE3BxurFHA.2008@TK2MSFTNGP10.phx.gbl...
>> EXEC sp_rename '#customers', '#custs'
>> result with error :Invalid object name '#customers'.
>>
>> how to rename a temp table?
>>
>>
>>
>>
>
>
Author
1 Sep 2005 12:36 PM
Uri Dimant
Hi, Dan
>> Changes the name of a user-created object (for example, table, column, or
>> user-defined data type) in the current database.

That was exactly may point.

Show quote
"Dan Guzman" <guzmanda@nospam-online.sbcglobal.net> wrote in message
news:OpFv7%23urFHA.2540@TK2MSFTNGP09.phx.gbl...
> Uri, I believe sp_rename disallows renaming temp objects.
>
> --
> Hope this helps.
>
> Dan Guzman
> SQL Server MVP
>
> "Uri Dimant" <u***@iscar.co.il> wrote in message
> news:OziOz4urFHA.240@tk2msftngp13.phx.gbl...
>> Sam
>> sp_rename
>> Changes the name of a user-created object (for example, table, column, or
>> user-defined data type) in the current database.
>>
>>
>>
>>
>>
>>
>>
>> "Sam" <focu***@zahav.net.il> wrote in message
>> news:ecE3BxurFHA.2008@TK2MSFTNGP10.phx.gbl...
>>> EXEC sp_rename '#customers', '#custs'
>>> result with error :Invalid object name '#customers'.
>>>
>>> how to rename a temp table?
>>>
>>>
>>>
>>>
>>
>>
>
>
Author
1 Sep 2005 1:01 PM
Dan Guzman
Uri, I didn't get your point from the BOL excerpt.  Even if one sets the
database context to tempdb, the temp table can't be renamed even though it
is a 'user-created' object.  Examining the sp_rename text, I see the
following comment:

-- Disallow renaming object to or from a temp name (starts with #)

--
Hope this helps.

Dan Guzman
SQL Server MVP

Show quote
"Uri Dimant" <u***@iscar.co.il> wrote in message
news:OMlCMHvrFHA.3440@TK2MSFTNGP10.phx.gbl...
> Hi, Dan
>>> Changes the name of a user-created object (for example, table, column,
>>> or user-defined data type) in the current database.
>
> That was exactly may point.
>
> "Dan Guzman" <guzmanda@nospam-online.sbcglobal.net> wrote in message
> news:OpFv7%23urFHA.2540@TK2MSFTNGP09.phx.gbl...
>> Uri, I believe sp_rename disallows renaming temp objects.
>>
>> --
>> Hope this helps.
>>
>> Dan Guzman
>> SQL Server MVP
>>
>> "Uri Dimant" <u***@iscar.co.il> wrote in message
>> news:OziOz4urFHA.240@tk2msftngp13.phx.gbl...
>>> Sam
>>> sp_rename
>>> Changes the name of a user-created object (for example, table, column,
>>> or user-defined data type) in the current database.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> "Sam" <focu***@zahav.net.il> wrote in message
>>> news:ecE3BxurFHA.2008@TK2MSFTNGP10.phx.gbl...
>>>> EXEC sp_rename '#customers', '#custs'
>>>> result with error :Invalid object name '#customers'.
>>>>
>>>> how to rename a temp table?
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
1 Sep 2005 1:15 PM
Uri Dimant
Dan


>> Changes the name of a user-created object (for example, table, column, or
>> user-defined data type) in the current database.
It says table........... and nothing about  temporary table. ( At least I
understand from this description)
As I see it is not documented well.


> Uri, I didn't get your point from the BOL excerpt.  Even if one sets the
> database context to tempdb, the temp table can't be renamed even though it
> is a 'user-created' object.  Examining the sp_rename text, I see the
> following comment:

Yes , does not matter if you are in tempdb you can't rename a temp. table.



Show quote
"Dan Guzman" <guzmanda@nospam-online.sbcglobal.net> wrote in message
news:%23KTL%23UvrFHA.2064@TK2MSFTNGP09.phx.gbl...
> Uri, I didn't get your point from the BOL excerpt.  Even if one sets the
> database context to tempdb, the temp table can't be renamed even though it
> is a 'user-created' object.  Examining the sp_rename text, I see the
> following comment:
>
> -- Disallow renaming object to or from a temp name (starts with #)
>
> --
> Hope this helps.
>
> Dan Guzman
> SQL Server MVP
>
> "Uri Dimant" <u***@iscar.co.il> wrote in message
> news:OMlCMHvrFHA.3440@TK2MSFTNGP10.phx.gbl...
>> Hi, Dan
>>>> Changes the name of a user-created object (for example, table, column,
>>>> or user-defined data type) in the current database.
>>
>> That was exactly may point.
>>
>> "Dan Guzman" <guzmanda@nospam-online.sbcglobal.net> wrote in message
>> news:OpFv7%23urFHA.2540@TK2MSFTNGP09.phx.gbl...
>>> Uri, I believe sp_rename disallows renaming temp objects.
>>>
>>> --
>>> Hope this helps.
>>>
>>> Dan Guzman
>>> SQL Server MVP
>>>
>>> "Uri Dimant" <u***@iscar.co.il> wrote in message
>>> news:OziOz4urFHA.240@tk2msftngp13.phx.gbl...
>>>> Sam
>>>> sp_rename
>>>> Changes the name of a user-created object (for example, table, column,
>>>> or user-defined data type) in the current database.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> "Sam" <focu***@zahav.net.il> wrote in message
>>>> news:ecE3BxurFHA.2008@TK2MSFTNGP10.phx.gbl...
>>>>> EXEC sp_rename '#customers', '#custs'
>>>>> result with error :Invalid object name '#customers'.
>>>>>
>>>>> how to rename a temp table?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
1 Sep 2005 1:19 PM
Sam
so how  can i rename the temp table?


Show quote
"Uri Dimant" <u***@iscar.co.il> wrote in message
news:OziOz4urFHA.240@tk2msftngp13.phx.gbl...
> Sam
> sp_rename
> Changes the name of a user-created object (for example, table, column, or
> user-defined data type) in the current database.
>
>
>
>
>
>
>
> "Sam" <focu***@zahav.net.il> wrote in message
> news:ecE3BxurFHA.2008@TK2MSFTNGP10.phx.gbl...
>> EXEC sp_rename '#customers', '#custs'
>> result with error :Invalid object name '#customers'.
>>
>> how to rename a temp table?
>>
>>
>>
>>
>
>
Author
1 Sep 2005 12:25 PM
Brian Lawton
select * into #NewName from #OldName
drop table #OldName

--
--Brian
(Please reply to the newsgroups only.)


Show quote
"Sam" <focu***@zahav.net.il> wrote in message
news:uBSEB%23urFHA.1168@TK2MSFTNGP11.phx.gbl...
> so how  can i rename the temp table?
>
>
> "Uri Dimant" <u***@iscar.co.il> wrote in message
> news:OziOz4urFHA.240@tk2msftngp13.phx.gbl...
>> Sam
>> sp_rename
>> Changes the name of a user-created object (for example, table, column, or
>> user-defined data type) in the current database.
>>
>>
>>
>>
>>
>>
>>
>> "Sam" <focu***@zahav.net.il> wrote in message
>> news:ecE3BxurFHA.2008@TK2MSFTNGP10.phx.gbl...
>>> EXEC sp_rename '#customers', '#custs'
>>> result with error :Invalid object name '#customers'.
>>>
>>> how to rename a temp table?
>>>
>>>
>>>
>>>
>>
>>
>
>
Author
1 Sep 2005 12:18 PM
David Gugick
Sam wrote:
> EXEC sp_rename '#customers', '#custs'
> result with error :Invalid object name '#customers'.
>
> how to rename a temp table?

I'm not sure you can rename a temporary table. Why do you need to do
this?

--
David Gugick
Quest Software
www.imceda.com
www.quest.com
Author
1 Sep 2005 12:21 PM
David Portas
I don't think there's a documented way to do it.

Why would you ever want to rename a temp table? This seems especially
pointless with a local temp table, which after all is intended
precisely to give you a locally-scoped name for the table. I'm sure if
you explain your requirement we can suggest a better solution to avoid
doing this.

--
David Portas
SQL Server MVP
--
Author
1 Sep 2005 12:33 PM
Chandra
sp_rename renames the table in the current database. a temp table is created
in tempdb database and tempdb doesnt have sp_rename stored procedure.

the table gets deleted immediately after the session is closed, so why do u
want to
rename it

--
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.SQLResource.com/
---------------------------------------



Show quote
"Sam" wrote:

> EXEC sp_rename '#customers', '#custs'
> result with error :Invalid object name '#customers'.
>
> how to rename a temp table?
>
>
>
>
>
Author
1 Sep 2005 12:57 PM
Aaron Bertrand [SQL Server MVP]
> how to rename a temp table?

What would be the point?
Author
1 Sep 2005 2:14 PM
Hari Prasad
Sam,

Why do you want to rename a # table. It just exits in that particular
session and got cleared of automatically. So instead of
renaming while creating give a name which suits for you :)

Thanks
Hari
SQL Server MVP


Show quote
"Sam" <focu***@zahav.net.il> wrote in message
news:ecE3BxurFHA.2008@TK2MSFTNGP10.phx.gbl...
> EXEC sp_rename '#customers', '#custs'
> result with error :Invalid object name '#customers'.
>
> how to rename a temp table?
>
>
>
>

AddThis Social Bookmark Button