Friday, March 30, 2012

how to rename a temp table

EXEC sp_rename '#customers', '#custs'
result with error :Invalid object name '#customers'.
how to rename a temp table?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" <focus10@.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?
>
>|||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|||so how can i rename the temp table?
"Uri Dimant" <urid@.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" <focus10@.zahav.net.il> wrote in message
> news:ecE3BxurFHA.2008@.TK2MSFTNGP10.phx.gbl...
>|||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
--|||Uri, I believe sp_rename disallows renaming temp objects.
Hope this helps.
Dan Guzman
SQL Server MVP
"Uri Dimant" <urid@.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" <focus10@.zahav.net.il> wrote in message
> news:ecE3BxurFHA.2008@.TK2MSFTNGP10.phx.gbl...
>|||select * into #NewName from #OldName
drop table #OldName
--Brian
(Please reply to the newsgroups only.)
"Sam" <focus10@.zahav.net.il> wrote in message
news:uBSEB%23urFHA.1168@.TK2MSFTNGP11.phx.gbl...
> so how can i rename the temp table?
>
> "Uri Dimant" <urid@.iscar.co.il> wrote in message
> news:OziOz4urFHA.240@.tk2msftngp13.phx.gbl...
>|||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/
---
"Sam" wrote:

> EXEC sp_rename '#customers', '#custs'
> result with error :Invalid object name '#customers'.
> how to rename a temp table?
>
>
>|||Hi, Dan
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" <urid@.iscar.co.il> wrote in message
> news:OziOz4urFHA.240@.tk2msftngp13.phx.gbl...
>|||> how to rename a temp table?
What would be the point?

No comments:

Post a Comment