新聞中心
sql server里的時(shí)間和sql server所在計(jì)算機(jī)的時(shí)間并不是一致的,下面就叫您修改sql server時(shí)間的方法,希望對(duì)您能有幫助。

--修改前時(shí)間 print getdate()
--打開(kāi)高級(jí)系統(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ù)庫(kù)所在計(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í)間同步. 但反過(guò)來(lái),如果用雙擊時(shí)間出現(xiàn)的"日期和時(shí)間屬性面板"中修改了計(jì)算機(jī)時(shí)間,是不會(huì)修改到sql server時(shí)間的。
【編輯推薦】
Sql Server日期與時(shí)間函數(shù)簡(jiǎn)介
SQL Server時(shí)間算法大全
帶您學(xué)習(xí)SQL存儲(chǔ)過(guò)程
SQL數(shù)據(jù)庫(kù)操作授權(quán)
增加SQL用戶名的方法
本文題目:教您如何修改sql server時(shí)間
文章來(lái)源:http://www.5511xx.com/article/cogdhho.html


咨詢
建站咨詢
