SQL Server 2008: how do I grant privileges to a username?

If you want to give your user all read permissions, you could use: EXEC sp_addrolemember N’db_datareader’, N’your-user-name’ That adds the default db_datareader role (read permission on all tables) to that user. There’s also a db_datawriter role – which gives your user all WRITE permissions (INSERT, UPDATE, DELETE) on all tables: EXEC sp_addrolemember N’db_datawriter’, N’your-user-name’ If … Read more

How to see query history in SQL Server Management Studio

[Since this question will likely be closed as a duplicate.] If SQL Server hasn’t been restarted (and the plan hasn’t been evicted, etc.), you may be able to find the query in the plan cache. SELECT t.[text] FROM sys.dm_exec_cached_plans AS p CROSS APPLY sys.dm_exec_sql_text(p.plan_handle) AS t WHERE t.[text] LIKE N’%something unique about your query%’; If … Read more