SQL get last Monday and last Sundays date based on todays date

Published on

this is much cleaner solution: SELECT — 17530101 or 1753-01-01 is the minimum date in SQL Server DATEADD(dd, ((DATEDIFF(dd, ‘17530101’, GETDATE()) / 7) * 7) – 7, ‘17530101’) AS [LowerLimit], — Last Week’s Monday DATEADD(dd, ((DATEDIFF(dd, ‘17530101’, GETDATE()) / 7) * 7) – 1, ‘17530101’) AS [UpperLimit] — Last Week’s Sunday. Which can be used … Continue reading SQL get last Monday and last Sundays date based on todays date

MS SQL Server 2005, 2008 – How to set unique constraint for a column

Published on

Here is how to set unique constraint for a column in Microsoft SQL Server 2005, 2008 to 2012. Using SQL: See the full syntax here. In SQL Server Management Studio Express: Right-click table, choose Modify or Design(For Later Versions) Right-click field, choose Indexes/Keys… Click Add For Columns, select the field name you want to be unique. For Type, choose Unique Key. Click Close, Save the table.