修改系统时间的时候,会连sql server所在计算机的时间一起修改了,所以如果想要变回准确的时间,需要先用计算机的时间同步更新功能更新一下时间,然后在把sql server的时间和计算机时间同步.
但反过来,如果用双击时间出现的”日期和时间属性面板”中修改了计算机时间,是不会修改到sql server时间的
代码如下 | 复制代码 |
–修改前时间 select getdate() –打开高级系统控制选项 EXEC master.dbo.sp_configure ‘show advanced options’, 1 RECONFIGURE –修改执行权限,这样就可以执行修改时间的命令了 EXEC master.dbo.sp_configure ‘xp_cmdshell’, 1 RECONFIGURE –修改系统时间 exec master..xp_cmdshell ‘date 2008-10-23’ exec master..xp_cmdshell ‘time 11:30:15’ –修改后时间 select getdate() –与数据库所在计算机的时间同步 exec master.dbo.xp_cmdshell ‘net ti本文来源gaodai$ma#com搞$$代**码)网8me \localhost /set /Y’ –同步后时间 select getdate() |