更改 Getdate 的输出 [英] Changing the output of Getdate

查看:35
本文介绍了更改 Getdate 的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以欺骗 SQL Server 在 GetDate() 返回不同的日期而不实际更改机器日期?
这会很棒,因为我们有一个包含旧数据的数据库,我正在尝试测试一些使用 getdate() 的查询.
我可以更改我的机器日期,但这会给其他应用程序带来一些其他问题...
有什么提示吗?
谢谢!

Is it possible to deceive SQL Server to return a different date on GetDate() without actually changing the machine date?
This would be great, since we have a database with old data and I'm trying to test some queries that use getdate().
I can change my machine date but that brings some other problems with other applications...
Any tips?
Thanks!

推荐答案

根据 getdate() 的文档:

这个值是从计算机的操作系统在SQL Server 的实例是哪个运行.

This value is derived from the operating system of the computer on which the instance of SQL Server is running.

由于它是从操作系统派生的,我认为您不能单独更改它.

Since it's derived from the OS, I don't think you can change it separately.

这篇关于更改 Getdate 的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆