SQL, SQL Server, Tutorials, Oracle, PL/SQL, Interview Questions & Answers, Joins, Multiple Choice Questions, Quiz, Stored Procedures, Select, Insert, Update, Delete and other latest topics on SQL, SQL Server and Oracle.
PARSE()
PARSE()
PARSE(): PARSE is a method which returns the output of an expression by translating it to the required data type. It is actually relying on the existence of .Net’s CLR (i.e. Common Language Runtime). It has been suggested to use PARSE only to convert string to Data/Time and number types. CAST & CONVERT can still be used for general type conversions.
Syntax of PARSE():
PARSE ( string_value AS data_type [ USING culture ] )
Example of PARSE():
Parse string to DateTime
SELECT PARSE('Tuesday, 01 February 2011' AS DATETIME2 USING 'en-US') AS 'Output';
The result for the above statement would be:
2011-02-01 00:00:00.0000000
Parse with Currency symbol
SELECT PARSE('€88,76' AS MONEY USING'de-DE') AS 'Output';
The output will come out to be:
88.76
For complete post go to SQL Server 2012 Enhancements.