English 中文(简体)
外交部
原标题:Convert date to NULL in SQL SEVER
  • 时间:2010-12-15 19:07:26
  •  标签:
  • sql-server

我有兴趣将日期改为服务器。 我在此简单地问:

SELECT 
ENTERED_DATE as DATE
ENTERED_DATE as NEXT_DATE
FROM SOMETABLE

DATE                          NEXT_DATE
12/1/2010 12:30:00 AM         12/1/2010 12:30:00 AM
12/1/2010 4:00:00 AM           12/1/2010 4:00:00 AM
12/1/2010 9:00:00 AM           12/1/2010 9:00:00 AM

我希望我取得这样的结果:

 DATE                          NEXT_DATE
 12/1/2010 12:30:00 AM         (null)
 12/1/2010 4:00:00 AM         (null)
 12/1/2010 9:00:00 AM         (null)

我如何能够这样做?

最佳回答

How about:

SELECT 
ENTERED_DATE as DATE
CONVERT(datetime, NULL) as NEXT_DATE
FROM SOMETABLE
问题回答
SELECT ENTERED_DATE as DATE, CAST(NULL AS DATETIME) as NEXT_DATE 
FROM SOMETABLE

如果我完全理解这个问题,你能否这样做?

拉丁美洲和加勒比国家:





相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

SQL server: Can NT accounts be mapped to SQL server accounts

In our database we have an SQL server account that has the correct roles to access some of the databases. We are now switching to windows authentication and I was wondering if we can create a NT user ...

SQL Server 2000, ADO 2.8, VB6

How to determine if a Transaction is active i.e. before issuing Begin Transaction I want to ensure that no previous transaction are open.. the platform is VB6, MS-SQL Server 2000 and ADO 2.8

热门标签