Can I do something like this?
create table #tbl_tmp (col1 int)
insert into #tbl_tmp select 3
exec sp_rename '#tbl_tmp','tbl_new'
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No.
If you are running this from a database other than
tempdbyou getWhich is not surprising as all the data pages etc. are in the
tempdbdata files so you wouldn’t be able to rename this to suddenly become a permanent table in an other database.If you are running this from
tempdbyou getIf you do
EXEC sp_helptext sp_renameand look at the definition the relevant bit of code disallowing this isWhy wouldn’t you just create a permanent table in the first place then do the rename?