Posted on December 21, 2010, 9:37 pm, by Rhys, under
Powershell.
Sometimes I’m writing Powershell scripts to gather information on a seemingly ad-hoc basis and then someone says; "Oh, and can you send that to me in an email every day|week|month". These scripts would often use a bunch of Write-Host statements to output to the console. Modifying these to send the output in an email can [...]
Posted on December 15, 2010, 9:17 am, by Rhys, under
Powershell.
I’ve written a post about Documenting Databases with Powershell that’s featured today on the Microsoft Scripting Guys blog. Head on over and check it out!
Posted on December 14, 2010, 9:11 pm, by Rhys, under
DBA,
Linux,
MySQL.
Unfortunately the MySQL SELECT INTO OUTFILE command doesn’t support an option to output the headers of the result set you are exporting. A feature request has been open for over 2 years to sort this with no apparent activity. A few people have had the idea of using a UNION ALL to include the headers [...]
Posted on December 1, 2010, 9:17 pm, by Rhys, under
Powershell.
I’ve been working on a performance benchmarking project recently to gauge the effect of new releases to our systems. Powershell happens to be very useful gathering various system statistics using the Get-Counter cmdlet. There’s literally a tonne of available counters for everything to disk use, memory usage to sql server specific counters. You can list [...]
Recently I needed to check which of our databases, on our many SQL Servers, had the TRUSTWORTHY property set to true. This property, when set to false, can reduce certain threats from malicious assemblies or modules. Obviously this should only be enabled where it needs to be. Here’s a quick Powershell script that will enable [...]
Posted on November 11, 2010, 8:25 pm, by Rhys, under
DBA.
Just a quick one today as I’m always forgetting how to do this! I occasionally have to schedule server reboots to happen in the middle of the night. This is easily achieved by using the AT command in a command prompt window. The following example will schedule a server reboot for 3AM as a one-off [...]
Posted on November 5, 2010, 9:25 pm, by Rhys, under
DBA,
SQL Server.
I was in two minds about whether to blog about this as I’m sure many people know this already! What the hell! I’m not embarrassed to admit I don’t know everything. Even the most casual user of SSMS knows that you can drag any database, table or column from the object explorer to the editor. [...]
Posted on October 29, 2010, 11:47 am, by Rhys, under
T-SQL.
I’ve been spending the past week or so changing a colleagues scripts into SSRS reports so we can automate things a bit better. During some QA checks I noticed that I was coming out with higher counts on one section of the report. Much to my frustration the two queries looked identical and I had [...]
Posted on October 27, 2010, 8:03 pm, by Rhys, under
Powershell.
There’s two methods I often use for sending email in my Powershell scripts. The first uses the Send-MailMessage cmdlet and the second resorts to using the .Net Framework. Why do I use two methods? Well…. ?View Code POWERSHELLSend-MailMessage -To ‘me@here.com’ -From ‘sender@here.com’ -Subject ‘Test Message’ -Body ‘This is a test message.’ -SmtpServer ‘smtp.server.com’; The Send-MailMessage [...]
A Tweet-SQL user emailed me recently about how to store results from the tweet_src_search procedure in a table. Twitter returns an atom feed for search requests so you have to handle this slightly differently compared to other Tweet-SQL procedures. Here’s a quick walk-through of how we can get Twitter search results into a database table [...]