Lectura 1 - PARSE (Transact-SQL) - SQL Server - Microsoft Docs
Lectura 1 - PARSE (Transact-SQL) - SQL Server - Microsoft Docs
PARSE (Transact-SQL)
07/05/2017 • 3 minutes to read • +4
In this article
Syntax
Arguments
Return Types
Remarks
Examples
Applies to: SQL Server (all supported versions) Azure SQL Database
Returns the result of an expression, translated to the requested data type in SQL Server.
Syntax
= Copy
Arguments
string_value
nvarchar(4000) value representing the formatted value to parse into the specified data
type.
string_value must be a valid representation of the requested data type, or PARSE raises
an error.
data_type
Literal value representing the data type requested for the result.
culture
Optional string that identifies the culture in which string_value is formatted.
If the culture argument is not provided, then the language of the current session is
used. This language is set either implicitly, or explicitly by using the SET LANGUAGE
https://docs.microsoft.com/en-us/sql/t-sql/functions/parse-transact-sql?view=sql-server-ver15 1/6
4/7/2020 PARSE (Transact-SQL) - SQL Server | Microsoft Docs
statement. culture accepts any culture supported by the .NET Framework; it is not
limited to the languages explicitly supported by SQL Server. If the culture argument is
not valid, PARSE raises an error.
Return Types
Returns the result of the expression, translated to the requested data type.
Remarks
Null values passed as arguments to PARSE are treated in two ways:
1. If a null constant is passed, an error is raised. A null value cannot be parsed into a
different data type in a culturally aware manner.
2. If a parameter with a null value is passed at run time, then a null is returned, to
avoid canceling the whole batch.
Use PARSE only for converting from string to date/time and number types. For general
type conversions, continue to use CAST or CONVERT. Keep in mind that there is a
certain performance overhead in parsing the string value.
PARSE relies on the presence of the .NET Framework Common Language Runtime (CLR).
This function will not be remoted since it depends on the presence of the CLR.
Remoting a function that requires the CLR would cause an error on the remote server.
The values for the data_type parameter are restricted to the types shown in the
following table, together with styles. The style information is provided to help
determine what types of patterns are allowed. For more information on styles, see the
.NET Framework documentation for the System.Globalization.NumberStyles and
DateTimeStyles enumerations.
https://docs.microsoft.com/en-us/sql/t-sql/functions/parse-transact-sql?view=sql-server-ver15 2/6
4/7/2020 PARSE (Transact-SQL) - SQL Server | Microsoft Docs
The following table shows the mappings from SQL Server languages to .NET Framework
cultures.
https://docs.microsoft.com/en-us/sql/t-sql/functions/parse-transact-sql?view=sql-server-ver15 3/6
4/7/2020 PARSE (Transact-SQL) - SQL Server | Microsoft Docs
https://docs.microsoft.com/en-us/sql/t-sql/functions/parse-transact-sql?view=sql-server-ver15 4/6
4/7/2020 PARSE (Transact-SQL) - SQL Server | Microsoft Docs
Examples
= Copy
= Copy
Result
---------------
2010-12-13 00:00:00.0000000
(1 row(s) affected)
https://docs.microsoft.com/en-us/sql/t-sql/functions/parse-transact-sql?view=sql-server-ver15 5/6
4/7/2020 PARSE (Transact-SQL) - SQL Server | Microsoft Docs
= Copy
= Copy
Result
---------------
345.98
(1 row(s) affected)
= Copy
= Copy
Result
---------------
2010-12-16 00:00:00.0000000
(1 row(s) affected)
Yes No
https://docs.microsoft.com/en-us/sql/t-sql/functions/parse-transact-sql?view=sql-server-ver15 6/6