开发者

how to pass date array as xml to store procedure

开发者 https://www.devze.com 2023-03-03 00:12 出处:网络
Bcz when u parse that string into date that开发者_运维技巧 will not parse properly. for that u have to send date string as per sql server date format

Bcz when u parse that string into date that开发者_运维技巧 will not parse properly. for that u have to send date string as per sql server date format

ALTER PROCEDURE [dbo].[SprSelectScheduleForReAutoAllocate]  --'<AADates><AADate AADateValue="2011-04-27 00:00:00.000" /><AADate AADateValue="2011-04-28 00:00:00.000" /></AADates>'
(
   @Datexml xml     
)
AS
BEGIN
                  EXEC sp_xml_preparedocument @xmlDoc output ,@DateXml 

                                SELECT  AADateValue
        FROM OPENXML(@xmlDoc,'AADates/AADate',1) 
        WITH 
        (
        AADateValue Datetime    
        )
        xmlDocuments

                EXEC sp_xml_removedocument @xmlDoc  
End


SQL Server reads date times values according to the ISO 8601 standard in the following two formats:

YYYY-MM-DDThh:mm:ss[.mmm]
YYYYMMDDThh:mm:ss[.mmm]

Format you input like this and SQL Server will never throw an error due to incompatible culture or language. This is the culture/language agnostic way to pass the value if you cannot pass it as an actualy datetime value.

0

精彩评论

暂无评论...
验证码 换一张
取 消