DECLARE @LastmonLastBusinessDay date, @inputdate date SET @inputdate = ’05/25/2014′ SELECT @LastmonLastBusinessDay = DATEADD(ms,-3,DATEADD(mm,DATEDIFF(mm,0,@inputdate),0)) – CASE DATENAME(dw,DATEADD(ms,-3,DATEADD(mm,DATEDIFF(mm,0,@inputdate),0))) WHEN ‘SUNDAY’ THEN 2 WHEN ‘SATURDAY’ THEN 1 ELSE 0 END print @LastmonLastBusinessDay
Deleting duplicate rows in SQLServer is very simple. Example : Check this table let me call it as Sample, order number 1,2 & 3 have identical values. Now we need … Read More “SQLServer Delete Duplicate Rows”
There are many Free and Better alternatives for list mentioned below. I like them because they make my life simple. Microsoft 1. Windows 2. Office (Word, Excel, Outlook, Power point, … Read More “What I like the most”
While importing data from Excel to SQLServer, if a Excel column in has both Text and Numeric values then either Text or Numeric values will be NULL in SQLServer. See … Read More “SSIS import mixed datatypes from Excel to SQLServer”
Based on http://www.sqlbook.com/SQL/Avoiding-using-SQL-Cursors-20.aspx with a minor change. DECLARE @CustomerID int DECLARE @FirstName varchar(30), @LastName varchar(30) — declare cursor called ActiveCustomers DECLARE ActiveCustomers Cursor FOR SELECT CustomerID, FirstName, LastName FROM … Read More “Avoid Using SQL Server Cursors”
Where is the Connection String in SQL Server Management Studio sp3 ? How are we supposed to import data from ODBC data sources ?