SQL Server更改数据库 [英] SQL Server Alter Database
问题描述
我遇到了数据库命名约定的问题。
我有两个名为MyDatabase和3MyDatabase的数据库(以数字开头)。
我想通过以下代码更改数据库。
ALTER DATABASE MyDatabase 使用ROLLBACK IMMEDIATE设置离线(它正常工作,因为数据库名称是MyDatabase)
ALTER DATABASE 3MyDatabase 设置离线并立即返回(显示错误)因为数据库名称是3个数据库,从数字开始)
数据库名称以数字开头时我遇到此问题。
如果数据库包含数字,但它不是从数字开始,然后没有问题。
请帮助。如何执行上面的脚本如果数据库名称与号码。
谢谢你,
普利文
您的命名召集必须符合数据库标识符 [ ^ ]
你可以试试这个:
ALTER DATABASE 跨度> [3MyDatabase] <跨度类= 代码关键字 > SET 跨度> OFFLINE <跨度类= 代码关键字 > WITH 跨度> <跨度类= 代码关键字> ROLLBACK 立即
- Amit
I have faced an issue with Database naming convention.
I hav two Database named "MyDatabase" and "3MyDatabase" (Starting with number).
I want to alter Database by below code.
ALTER DATABASE MyDatabase SET OFFLINE WITH ROLLBACK IMMEDIATE (Its working properly as DB name is MyDatabase)
ALTER DATABASE 3MyDatabase SET OFFLINE WITH ROLLBACK IMMEDIATE (showing error as DB name is 3MyDatabase, starting with number )
I am facing this issue when Database name is starting with number.
If Database contains number but it does not start with number then no issue.
Please help. How to execute above script if Database name starts with number.
Thanks,
Praveen
Your naming convenstion must comply with the rules of Database Identifiers[^]
You can try this:
ALTER DATABASE [3MyDatabase] SET OFFLINE WITH ROLLBACK IMMEDIATE
--Amit
这篇关于SQL Server更改数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!