Archive for the ‘SQL’ Category
Grant a MS SQL login Read Only access to ALL databases
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).
Simple script to backup all databases at once
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
Setting SQL Server to accept date in DD/MM/YYYY format
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
Cannot shrink transaction log SQL 2005
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
T-SQL Example code: Select, Insert, Update, Delete
Various examples and snippets of Select, Insert, Update, Delete T-SQL
In: SQL · Tagged with: delete, insert, select, update
T-SQL Example code: Table Management
T-SQL table management tips, tricks and code snippets
In: SQL · Tagged with: alter table, column, drop, management, select into, table, truncate
T-SQL Example code: useful stores procedures and snippets
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
T-SQL Example code: User Management
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
T-SQL Example code: Database Management
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
T-SQL Example code: SQL Fixes
Here are a few lines of code that have got me out of troubel in the past: