Posts Tagged ‘SQL’

IN queries with LINQ to SQL

This is another awesome feature in LINQ to SQL that i always forget about. Sometimes you have an array of strings or any other type and want to query the database for all values that have one of the values in the array. string platform = “windows|linux”; string[] platformList = platform.Split(‘|’); itemQuery = from m [...]

Return random rows from a MS SQL database

I always forget this command: SELECT * FROM YourTable TABLESAMPLE SYSTEM (10 PERCENT) This gives you some sample data from your database. In this case 10 percent of the content.  You could also use TABLESAMPLE SYSTEM (1000 ROWS) to get 1000 sample rows. Great to use if you have a big database and do not [...]

SQL Server: Saving changes is not permitted because table will be re-created

Microsoft has added a setting to Management Studio to prevent us from re-create tables when we make changes to them. I don’t like this settings and it would have be much better if they said ‘This table will be re-created, are you sure you want to do that?” instead of just stop us from doing [...]

ASP.NET membership: System.Web.Security. SqlRoleProvider problems

I had this really weird problem just now. I have done some work with the ASP.NET Membership provider and everything has been working great. But when i tried to deploy my application to the server i got this: The ‘System.Web.Security.SqlRoleProvider’ requires a database schema compatible with schema version ’1′. However, the current database schema is [...]

Join and Group By with LINQ to Entities

I have banged my head against some LINQ to Entities stuff today. It started out when i was doing a query to get some stats out of my forum. I should point out that i’m a newbe with LINQ to Entities and the Entity Framework so if i have done anything stupid here you are [...]