Mssqlserver rename method createprockillspid (@ dbnamevarchar (20) & nbsp; as & nbsp; & nbsp; begin & nbsp; & nb mssql server rename Method
Create proc killspid (@ dbname varchar (20 ))
As
Begin
Declare @ SQL nvarchar (500), @ temp varchar (1000)
Declare @ spid int
Set @ SQL = 'Clare getspid cursor
Select spid from sysprocesses where dbid = db_id
(
Exec (@ SQL)
Open getspid
Fetch next from getspid into @ spid
While @ fetch_status = 0
Begin
Set @ temp = 'Kill '+ rtrim (@ spid)
Exec (@ temp)
Fetch next from getspid into @ spid
End
Close getspid
Deallocate & nb
Next let's take a look at renaming a database.
When you Rename an ACCESS or SQL Server database table name, you can open the database and rename the table. Use now
The following code allows you to rename a table on the Web page through Access and SQL Server databases. Code:
1. ACCESS
<%
Dim Conn, ConnStr, oCat, oTbl
ConnStr = "Provider = Microsoft. Jet. OLEDB.4.0; Data Source =" & Server. MapPath
("Test. mdb ")
Set oCat = Server. CreateObject ("ADOX. Catalog ")
OCat. ActiveConnection = ConnStr
Set oTbl = Server. CreateObject ("ADOX. Table ")
Set oTbl = oCat. Tables ("test") 'name of the table to be renamed: OldTableName
OTbl. Name = "NewTableName" 'New table Name
Set oCat = Nothing
Set oTbl = Nothing
Response. Write ("name duplicate! ")
%>
My databases and files are placed in the same folder.
The database uses a virtual path. The above code is implemented: In the "test. mdb" database, change the name of the "test" table
"NewTableName ".
2. SQL Server
The Code is as follows:
<%
Dim conn
Set conn = CreateObject ("ADODB. Connection ")
Conn. Open
("Provider = SQLOLEDB; Server = 127.0.0.1; Database = test; UID = sa; PWD = QQ40623660 ")
SQL = "sp_rename 'oldtablename', 'newtablename', 'object '"
Conn.exe cute (SQL)
Conn. close
Set conn = nothing
Response. Write ("name duplicate! ")
%>