如何設(shè)置sql server2005的數(shù)據(jù)庫(kù)系統(tǒng)時(shí)間:
--修改前時(shí)間
select getdate()
--打開高級(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 2008-10-23'
exec master..xp_cmdshell 'time 11:30:15'
--修改后時(shí)間
select getdate()
--與數(shù)據(jù)庫(kù)所在計(jì)算機(jī)的時(shí)間同步
exec master.dbo.xp_cmdshell 'net time \\localhost /set /Y'
--同步后時(shí)間
select 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í)間的