目录
一、连接字符串
【本地连接字符串】
sql
server = DESKTOP-FTH2P3S; Database = 【数据库名称】; Trusted_Connection = SSPI;
备注:可用.代替上面的主机名称
【远程连接字符串】
sql
Data Source=192.xxx.xx.xxx;Initial Catalog=数据库名称;Persist Security Info=True;User ID=数据库账号;Password=数据库密码;TrustServerCertificate=true
二、备份
第一步,找到你想备份的数据库-右键任务备份

第二步,选路径



然后点击确定,显示备份完成

去指定路径查看,发现已经备份成功:

三、还原
(1)还原数据库-bak、btn文件
先登录本地数据库

设置好安全性

把服务器身份验证改成SQL serve和windos身份验证模式

右键还原数据库


连接字符串参考(第一个名称 可以右键属性获得,第二个是数据库名 ,第三个是免密码验证)

请在SqlMap.config文件改连接字符串。
(2)附加数据库mdf文件


在SQLsever数据库中右键附加


四、SQL监视器的使用
(1)捕捉sql
第一步,打开数据库,点击profiler,连接好后设置显示的事件

例如我上面选择的是监听存储过程,如果想监听SQL,可以选择TSQL

第二步,选中对应的事件查看SQL,并且可将SQL复制黏贴进行查询

第三步,黏贴后需要对SQL做的处理:

@param0 等含@的占位符,要替换为对应的字符
''要替换为' (双引号替换为单引号)
(2)数据库执行时间计算
sql
declare @d datetime
set @d=getdate();
/*你的SQL开始*/
SELECT * FROM table
/*你的SQL结束*/
select [语句执行花费时间(毫秒)]=datediff(ms,@d,getdate())
