TRY_PARSE()

Today I played around with the TRY_PARSE() function and it does work.
Though it’s an expensive one and as we all know, SQL Server isn’t built for handling strings 🙂

TRY_PARSE SQL Server 2012

Code:

DECLARE @dtSQL VARCHAR(10) = '09-2013-13';
SELECT TRY_CAST(@dtSQL AS datetime2) AS [TRY_CAST Result],
TRY_CONVERT(datetime2, @dtSQL) AS [TRY_CONVERT Result],
TRY_PARSE(@dtSQL AS datetime2) AS [TRY_PARSE Result];
GO

More examples: TRY_CAST(), TRY_CONVERT() and TRY_PARSE() – Compare and Contrast








Advertisements

Pause SQL Server service before restarting

Did you know that by pausing the SQL Server service before restarting the instance we allow end users to continue their work uninterrupted and we also stop any new connections to the instance? This is a nicer way of telling people to “get out” of the database in order for the server to be rebooted. I wouldn’t leave the server paused for 60 minutes of course, but I would rather use this method than forcibly disconnect users and rollback their transactions.

When a server is paused you will see messages similar to this in the SQL Server error log:

Error: 17142, Severity: 14, State: 0.
SQL Server service has been paused. No new connections will be allowed. To resume the
service, use SQL Computer Manager or the Services application in Control Panel.

Error: 18456, Severity: 14, State: 13.
Login failed for user ''. Reason: SQL Server service is paused.
No new connections can be accepted at this time. [CLIENT: ]

Next time you are worried about rebooting during the day think about the pause button instead. It might be a nice compromise for your end-users.

Thank Thomas Larock for his blog post: http://thomaslarock.com/2016/01/pause-sql-server-service-before-restarting/








SQL Server Features List (all versions)

Normally you can find everything on Google, but there is literary no overall list of SQL Server features per version/release. So…I had to make the list myself starting from SQL Server 2012.
Did I forget a feature? Drop a comment.



SQL Server 2012:
– AlwaysOn Availability Groups
– AlwaysOn Failover Cluster Instances
– Non-Clustered Columnstore Indexes
– Data Quality Services (DQS)
– Tabular Model (SSAS)
– FileTable Storage
– Power View
– SQL Server Data Tools (SSDT)
– Contained Databases
– User-Defined Server Roles
– Enhanced Auditing Features
– Sequence Objects (sequence keys)
– Distributed Replay (capture a workload on a server and replay)
– T-SQL commands/statements (for example: THROW, PARSE, TRY_PARSE, TRY_CONVERT, TRY_CAST, CHOOSE, IIF, CONCAT, FORMAT, ROWS, RANGE, LAG, LEAD, PERCENT_RANK, ORDER BY…OFFSET/FETCH)



SQL Server 2014:
– In-Memory OLTP/Tables (256GB)
– Managed Backup to Azure
– Azure VMs for Availability replicas
– SQL Server Data Files in Azure
– Clustered / Updateable Columnstore Indexes
– Resource Governor for I/O
– Delayed durability
– Buffer Pool Extension (SSD)
– Incremental statistics
– Lock priority of online operations
– AlwaysOn Availability Groups (enhanced with support for additional secondary replicas and Windows Azure integration)
– Database Backup Encryption
– SQL Server Data Tools for Business Intelligence (SSDT-BI)
– Native Compiled Stored Procedures (“WITH NATIVE_COMPILATION”)
– T-SQL commands/statements (for example: SELECT INTO)



SQL Server 2016:
– Always Encrypted
– Row Level Security
– Dynamic Data Masking
– Data Compression / Decompression
– In-Memory Table Enhancements (2TB, FK, Constraints, ALTER, TDE, Triggers)
– Improvements on Columnstore Indexes (Parallel insert, Nonclustered B-tree indexes on top of the columnstore, Read/write nonclustered columnstore on top of a regular clustered index, REORGANIZE)
– Stretch Database
– Polybase
– Datazen
– Built-in R Support
– New SSRS Visualizations (‘Power BI’-like)
– Compare Execution Plans
– Multiple TempDB Database Files
– Live Query Statistics
– Native JSON Support
– Temporal Tables
– Query Store Built-in Reporting
– Natively compiled stored procedures can be nested
– T-SQL commands/statements (for example: DROP IF EXISTS, DATEDIFF_BIG, COMPRESS, DECOMPRESS, SESSION_CONTEXT)