Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 5th, 2005, 12:16 AM
Authorized User
 
Join Date: Aug 2003
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to rename a table in SQL Server

Hi all,
I searched google and tried all syntaxes to rename a table but none worked.
Can anyone tell me the syntax to rename a table in SQL Server 2000.

I opted to use stored proc 'sp_rename" to rename table in my asp code.
But the thing is it also gives error. Can anyone pls enlighten me whether we can call system stored proc thru ASP.

My code is:

conn.ConnectionString="Provider=SQLOLEDB;Data Source=(local);Database=mydb;UID=sa;PWD=;"
    conn.open

    '************ Rename Table *****************
    oldtable="student_registration"
    newtable="student_registration_old"

    dim cmd
    Set cmd = Server.CreateObject("ADODB.Command")
    Set cmd.ActiveConnection = conn
    cmd.CommandText = "sp_rename"
    cmd.CommandType = adCmdStoredProc 'Line 18

    cmd.Parameters.Append cmd.CreateParameter("@oldtable", adVarchar,adParamInput,30,oldtable)
    cmd.Parameters.Append cmd.CreateParameter("@newtable", adVarchar,adParamInput,30,newtable)
    cmd.Execute()

    '************ End Rename Table *****************

The following error is on line 18:
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.


Is it due to the fact that the connection string refers to "mydb" database while sp_rename is in "master" database ?


regards

Vinay


 
Old January 5th, 2005, 12:48 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

I too think so .. but not sure as its long since I worked with ASP! Btw check out this http://vadivel.thinkingms.com/Catego...6-b255e22e47c3

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Rename a Column using SQL pipelineconsulting Classic ASP Databases 7 September 21st, 2017 04:16 PM
Rename Field using SQL spazband Access 5 May 20th, 2011 06:20 AM
SQL Rename a Field? seananderson BOOK: Beginning SQL 2 May 20th, 2011 06:19 AM
Rename a table through SQL in SQL Server pankaj_daga SQL Server 2000 5 June 27th, 2008 03:31 AM
Rename table collie Access 1 February 23rd, 2005 02:49 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.