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
|