教您如何修改sql server時(shí)間
sql server里的時(shí)間和sql server所在計(jì)算機(jī)的時(shí)間并不是一致的,下面就叫您修改sql server時(shí)間的方法,希望對您能有幫助。
--修改前時(shí)間 print getdate()
--打開高級系統(tǒng)控制選項(xiàng)
EXEC master.dbo.sp_configure 'show advanced options', 1 RECONFIGURE
--修改執(zhí)行權(quán)限,這樣就可以執(zhí)行修改時(shí)間的命令了
EXEC master.dbo.sp_configure 'xp_cmdshell', 1 RECONFIGURE
--修改系統(tǒng)時(shí)間
exec master..xp_cmdshell 'date 2009-06-23'
exec master..xp_cmdshell 'time 19:40:00'
--修改后時(shí)間 print getdate()
--與數(shù)據(jù)庫所在計(jì)算機(jī)的時(shí)間同步 exec master.dbo.xp_cmdshell 'net time \\. /set /y'
--同步后時(shí)間 print getdate()
要注意,修改系統(tǒng)時(shí)間的時(shí)候,會(huì)連sql server所在計(jì)算機(jī)的時(shí)間一起修改了,所以如果想要變回準(zhǔn)確的時(shí)間,需要先用計(jì)算機(jī)的時(shí)間同步更新功能更新一下時(shí)間,然后在把sql server時(shí)間和計(jì)算機(jī)時(shí)間同步. 但反過來,如果用雙擊時(shí)間出現(xiàn)的"日期和時(shí)間屬性面板"中修改了計(jì)算機(jī)時(shí)間,是不會(huì)修改到sql server時(shí)間的。
【編輯推薦】