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.
精彩评论