こんにちは私は私に私の希望の結果を与える次のクエリを持っていますが、1つを除いて。
MyQuery:
(SELECT
(SELECT
'3' as '@CategoryDepth',
'CIMtrek_SelectedPage' as '@SelectedPage',
'CIMtrek_ParentID' as '@ParentID',
'CIMtrek_LstParm' as '@LstParm',
'CIMtrek_SearchParm' as '@SearchParm',
'CIMtrek_Search_No' as '@isSearch',
'CIMtrek_CDS1' as '@ViewName'
FOR XML PATH('AppConfig'), TYPE ),
(SELECT
RES.Header as '@Header'
FROM (
SELECT 'Date' AS Header
UNION ALL
SELECT 'MY MENU' AS Header
) AS RES
FOR XML PATH('ColumnHeader'), TYPE ),
(SELECT
RES.Param as '@Param'
FROM (
SELECT 'CIMtrek_daily_shipdate' AS Param
UNION ALL
SELECT 'MY PARM' AS Param
) AS RES
FOR XML PATH('Params'), TYPE ),
(SELECT
RES.Search as '@Search'
FROM (
SELECT 'Date|[T1].[CIMtrek_daily_shipdate] ' AS Search
UNION ALL
SELECT 'Department|[T1].[CIMtrek_daily_PackingMethod] ' AS Search
UNION ALL
SELECT 'Rush|[T1].[CIMtrek_daily_Rush] ' AS Search
UNION ALL
SELECT 'Customer Name|[T1].[CIMtrek_daily_CustomerName_1] ' AS Search
UNION ALL
SELECT 'Schedule Name|[T1].[CIMtrek_daily_schedule_name] ' AS Search
UNION ALL
SELECT 'Carrier|[T1].[CIMtrek_daily_carrier] ' AS Search
UNION ALL
SELECT 'Order|[T1].[CIMtrek_daily_order] ' AS Search
UNION ALL
SELECT 'Load #|[T1].[CIMtrek_daily_load] ' AS Search
UNION ALL
SELECT 'Pieces|[T1].[CIMtrek_daily_pieces] ' AS Search
UNION ALL
SELECT 'Cases|[T1].[CIMtrek_daily_cases] ' AS Search
UNION ALL
SELECT 'Weight|[T1].[CIMtrek_daily_weight] ' AS Search
UNION ALL
SELECT 'Cube|[T1].[CIMtrek_daily_cube] ' AS Search
UNION ALL
SELECT 'MY SEARCH|Search' AS Search
) AS RES
FOR XML PATH('Search'), TYPE ),
(SELECT
(
SELECT COUNT(*) FROM (
SELECT
ISNULL([T1].[CIMtrek_daily_shipdate],'') AS CIMtrek_daily_shipdate
FROM
[CIMtrek_SystemTable_DatawareHouse] [T1] WHERE LEN(LTRIM(RTRIM(ISNULL(LTRIM(RTRIM([T1].[CIMtrek_daily_shipdate])),'')))) != 0 AND
1 = 1
AND [T1].[CIMtrek_form] in ('Compliance Daily Shipments')
AND [T1].[CIMtrek_daily_status] not in ('Complete')
AND [T1].[CIMtrek_Archive] not in ('Archived')
GROUP BY
ISNULL([T1].[CIMtrek_daily_shipdate],'')
) AS COUNTS1
) AS '@CIMtrek_COUNT' ,
'1' AS '@CIMtrek_COUNT_Level',
(SELECT
[T1].[ROW] AS '@Row'
,newid() AS '@UnqCimID'
<!--
changed this to format date to be DD/MM/YYYY
, [T1].[CIMtrek_daily_shipdate] AS '@CIMtrek_daily_shipdate'
-->
,CONVERT(VARCHAR(10),[T1].[CIMtrek_daily_shipdate],106) AS '@CIMtrek_daily_shipdate'
FROM (SELECT
ROW_NUMBER() OVER(ORDER BY ISNULL([T1].[CIMtrek_daily_shipdate],'')
ASC) ROW
, ISNULL([T1].[CIMtrek_daily_shipdate],'') AS CIMtrek_daily_shipdate
FROM
[CIMtrek_SystemTable_DatawareHouse] [T1] WHERE LEN(LTRIM(RTRIM(ISNULL(LTRIM(RTRIM([T1].[CIMtrek_daily_shipdate])),'')))) != 0 AND
1 = 1
AND [T1].[CIMtrek_form] in ('Compliance Daily Shipments')
AND [T1].[CIMtrek_daily_status] not in ('Complete')
AND [T1].[CIMtrek_Archive] not in ('Archived')
GROUP BY
ISNULL([T1].[CIMtrek_daily_shipdate],'')
) T1
WHERE [T1].ROW BETWEEN 1 and 10
order by convert(date,[T1].[CIMtrek_daily_shipdate],103)
FOR XML PATH('Data'), TYPE
)FOR XML PATH('Data'), TYPE) )FOR XML PATH('Root')
上記のクエリで、私は以下の行にコメントしました:
<!--
changed this to format date to be DD/MM/YYYY
, [T1].[CIMtrek_daily_shipdate] AS '@CIMtrek_daily_shipdate'
-->
次の行を入れます
,CONVERT(VARCHAR(10),[T1].[CIMtrek_daily_shipdate],106) AS '@CIMtrek_daily_shipdate'
これは:01-Nov-12 12:00:00 AM
toのような日付を変換し01-Nov-12
、それも問題ありませんが、場合によっては日付01-Nov-12 12:45:21 AM
を取得します。この場合、日付と時刻を表示する必要があります。
したがって、実際には、日時 01-Nov-12 12:00:00 AM
を表示したり、日時を表示したりするべきではありません01-Nov-12 12:45:21 AM
。
クエリ自体でこれを処理する方法は?
親切にこれを手に入れるのを手伝ってください。
よろしく