Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2009
    Posts
    4

    Unanswered: how to rename table through query in sql server

    Hi ,i am trying to rename table by using sql query in sql server but could not get any perfect solution

    i got sp_rename command for that but it is not working as query.

  2. #2
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    what's the error? sp_rename is the way to do it.

  3. #3
    Join Date
    Sep 2009
    Posts
    4
    is there any query like oracle for renaming the table such as "rename old_tblnm to new_tablename "

    sp_rename is the stored procedure which returns false in recordset open function

  4. #4
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    post your code. it is likely wrong.

    post your error message if you have one.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    sp_rename does not return a recordset...
    George
    Home | Blog

  6. #6
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    What sort of recordset would Oracle return in response to the following command:
    Code:
    ALTER TABLE schema.table RENAME TO schema.table1
    hint: None at all.

  7. #7
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by ajitm (via PM)
    i am not saying about recordset
    i am using odbc and i have passed the query sp_rename 'old_table_name' , 'new_table_name' to open function of recordset .but it returns 0. Is there any query so i can rename the table by passing it tp open function.

    thanks in advance.
    Post the code you're working with to illustrate please.
    George
    Home | Blog

  8. #8
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    I think you want to look at the connection.execute method.

  9. #9
    Join Date
    Jun 2004
    Location
    Long Island
    Posts
    696
    You can get cheesy, and do a select name from sysobjects prior/post operation.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •