Archive for the ‘SQL’ Category
Here is a SQL code snippet I used today that loops through all the databases on a server and creates a SQL script that will give a user Read Only access to all databases (including system databases).
Script to backup all non system databases To backup all your MS SQL databases quickly on a SQL instance use the following script in a new query window. You must change the “SET @path” string to a suitable location.
In: SQL · Tagged with: backup, script, sql, T-SQL
I’ve been working on a web based database project for the wifes business and during development I realised that half of the dates where being saved in M-D-Y format. As I live in the UK we use the correct date format which is D-M-Y obviously ;). The problem turned out to be a single settings […]
In: ASP.NET, SQL, Tech · Tagged with: asp.net, database, dmy, sql
If you ever come across a MS SQL 2005 transaction log that refuses to shrink, this little bit of code might help you out.
In: SQL · Tagged with: dbcc, sql, Transaction log
Various examples and snippets of Select, Insert, Update, Delete T-SQL
In: SQL · Tagged with: delete, insert, select, update
T-SQL table management tips, tricks and code snippets
In: SQL · Tagged with: alter table, column, drop, management, select into, table, truncate
Here are some useful one liners that I find very useful
In: SQL · Tagged with: alter database, attach, dbcc, detach, exec, restore, sp, sp_, stored procedure, update
Some useful commands for dealing with users (in a non violent way), and a very useful couple of lines for finding and then fixing orphaned users which often happens after moving a database to a differnet SQL server.
In: SQL · Tagged with: orphan, orphan user, sp_password
Here is some code that Iv’e found useful for managing databases:
In: SQL · Tagged with: database, drop, exec, rename, shrink, size, sp_database, table, truncate
Here are a few lines of code that have got me out of troubel in the past: