Recently I was trying to restore a standard SQL Server database from .bak file and this error came up: Here are the steps I took to overcome the error 1. If one doesn’t already exist, create a new empty database…
Tag: sql server
SQL Server says: Saving Changes Not Permitted
If you’ve run into this error then you’ve probably recently set up a new installation of SQL Server Management Studio. You then made a change to a table and to your horror this error popped up: Frustrating, isn’t it. But…
SQL Server: Group records by Week
Quick code snippet to group a recordset by week. In this case we are summing hours worked per week. SELECT DATEPART(YEAR,myDateField) AS ‘Year’, DATEPART(wk,myDateField) AS ‘Week #’, MIN(DATEADD(wk, DATEDIFF(wk,0,myDateField), 0)) AS ‘Week date’, SUM(COALESCE([Hours],0)) AS ‘Hours’ FROM…
Orphaned SQL Server Users
The Scenario: You’re working on a SQL database locally and when you restore the database on the production server the login no longer works. The user has been orphaned. Solution #1 – Delete and recreate the user from scratch Solution…