I have a SQL 2008 R2 Express database that Im running an ASP.NET MVC 2 application on.
It always seems to be first thing in the morning when this problem arises – application login will fail. So I run a query against the database like SELECT * FROM tblUser and it returns only 1 result (always some random user and none of the others), making me think the records have been truncated.
So I try to recreate the admin user for example, which fails, and suddenly all users are back in the database (as reflected by a SELECT * FROM tblUser query)
Restarting the database service resolves the issue, but I need to find out why its happening. Does anyone have an idea?
SOLVED
I have a bad habit of simply copying my user instance databases and using them again in other projects that require a similar schema.
Knowing that, a friend of mine suggested scripting my entire database (including data, using SQL Management Studio) and recreating it from that.
Another friend suggested attaching the database to SQL Server 2008 full version, not Express, so I thought I’d combine the two ideas and script the database and data onto the SQL Server 2008 – which has worked 🙂
N.B. It also reminded me of how blisteringly fast SQL Server full version is!