Quick and Dirty Altering all tables in a database using T-SQL
Sometimes you want to make changes across all tables in a particular database. For example, lets say you’ve got a database that was replicated and now its not and you want to strip the...
View ArticleQuick and Dirty monitoring – Using T-SQL to peform basic login monitoring
Its important for security to monitor unused logins on SQL. Only logins which need to be there should be there. There are a number of ways to monitor the which logins are using used but these methods...
View ArticleQuick and Dirty monitoring – Recording Failing Login attempts using T-SQL
You could check the SQL logs for failed login attempts but searching through those can be a pain. Far easier to make use of the following stored procedure, EXEC xp_readerrorlog 0, 1, 'Login failed'...
View ArticleQuick and Dirty attach a CSV in database mail
Insert your query and away you go EXEC msdb. dbo.sp_send_dbmail @profile_name = '<<NAME>>' , @recipients = '<<RECIPIENTS>>' , @query = '<<QUERY>>' ,...
View ArticleQuick and Dirty – View Query Plans using T-SQL
Query plans possess vital information which can help a DBA to make optimization decisions. The T-SQL below will retrieve the query plan for database of your choice. By extending the where clause in the...
View ArticleQuick and Dirty Using BCP to export CSV files
Ta-Dah! The switches below in the BCP statement export the results of the query to CSV BCP "select * from table" QUERYOUT "C:\TEST.csv" -c -t"," -r"\n" -T -S server
View ArticleQuick and Dirty exporting XML using BCP
Last post on BCP tonight promise . . . There are *many* ways of exporting an XML file from SQL, adding the section in bold below to the select in a BCP command will create XML from the search results....
View ArticleCapturing the error message from XP_CMDSHELL
Using XP_CMDSHELL we can run commands that could otherwise be run using Windows Scheduled Tasks. It is kick ass, what makes this even more kick ass is being able to capture the errors running these...
View ArticleKick Arse Deadlock Query
I thought the only way to get Deadlock info out of SQL was to enable trace flags 1204 and 1222 (see http://technet.microsoft.com/en-us/library/ms178104(v=sql.105).aspx) but this isn’t actually the case...
View Article
More Pages to Explore .....