sqlserver 2008 修改时间

这是在网上搜的修改2005的系统时间
--修改前时间
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 2013-08-8';

exec master..xp_cmdshell 'time 20:04:00';

--修改后时间
SELECT getdate();

执行后不成功 报错
The system cannot accept the date entered.
Enter the new date: (mm-dd-yy)

NULL
A required privilege is not held by the client.

求助,怎么修改数据库时间,web服务器和sqlserver服务器没有在同一台机器上,需要校时。怎么解决

这个问题可能是由于你尝试修改的日期格式不正确或者是系统权限不足导致的。


首先,检查你使用的日期格式是否正确,例如在美国的格式是 "mm-dd-yy",而在其他国家的格式可能是 "dd-mm-yy" 或 "yy-mm-dd"。确保你使用了正确的格式。


其次, 通过配置 xp_cmdshell 的权限问题导致, 可以通过在 SQL Server 中创建一个存储过程或脚本来执行所需的命令,以便在不需要特权的情况下执行。


最后, web服务器和sqlserver服务器没有在同一台机器上,校时可以让数据库服务器同步时间, 或者在两台机器的网络服务器上都配置同步时间。