use master
GO
declare @oldname varchar(50) = 'LldName'
declare @newname varchar(50) = 'newName'
exec ('Alter database '+ @oldname+ ' set single_user')
exec ('sp_renamedb ' + @oldname + ' , '+ @newname )
exec ('alter database ' + @newname+ ' set multi_user')
Rename the database name sql
最新推荐文章于 2022-04-14 09:24:31 发布