–You can change GETDATE() with the date you want to use SELECT CONVERT(date, GETDATE())
Category: SQL
What does COALESCE do in SQL?
In SQL Server (Transact-SQL), the COALESCE function returns the first non-null expression in the list. If all expressions evaluate to null, then the COALESCE function will return null. SELECT COALESCE(NULL, NULL, ‘ErcanOPAK.com’, NULL, ‘blog.ErcanOPAK.com’); Result: ‘ErcanOPAK.com’ SELECT COALESCE(NULL, ‘ErcanOPAK.com’, ‘blog.ErcanOPAK.com’); Result: ‘ErcanOPAK.com’ SELECT COALESCE(NULL, NULL, 1, 2, 3, NULL, 4); Result: 1
How to find records based on CAPITAL and small letters in SQL Query?
SELECT * FROM SQLTABLE WHERE SUBSTRING(TableColumn, 1, 1) = ‘x’ COLLATE SQL_Latin1_General_CP1_CS_AS
Get a Tree view with SQL Query
First of all, I must thank to Maulik Dhorajia for his great post. That post saved me a lot. That’s the @Company table we will use: And here is the SQL Query we need to use: — Working Example ;WITH CTECompany AS ( SELECT EmpID, ParentID, PersonName , 0 AS HLevel, CAST(RIGHT(REPLICATE(‘_’,5) + CONVERT(VARCHAR(20),EmpID),20) AS […]
Database stuck in “Restoring” state
You can use this command: RESTORE DATABASE <database name> WITH RECOVERY


