Welcome to MSDN Blogs Sign in | Join | Help

Browse by Tags

All Tags » Scripts

Using Perfmon with SQL Server – Part Two

Yesterday I posted a header from a script that shows you some links for how to use “Logman”, a Windows command-line utility that can automate your collection of Windows Performance Monitor counters. Towards the bottom, you can see the logman command I

Store XML Document as Binary, Read as XML

I had an interesting question the other day, so I thought I would share both the question and the answer. We had an older application that had stored an XML document in a table as a binary data type column. I know, I know – we’ve had an XML data type
Posted by Buck Woody | 2 Comments
Filed under: , ,

Templates for New Query Window

When I’m in SQL Server Management Studio and I click the “New Query” button, my Query Window comes up like this: /* <ScriptFileName, SYSNAME, ScriptFileName>.sql Purpose: <Purpose, SYSNAME, Purpose> Author: <Author, SYSNAME, Buck Woody>

T-SQL Prettifiers

OK, I don't think that's even a word, but the synonyms (can a non-word have a synonym?) are code beautifiers, sql formatters, etc. The basic idea is that it's a program that re-formats the text in a Transact-SQL statement using a standard set of rules.

The Importance of a Test System

Most of us have three environments in our organizations: Development, Staging, and Production. But I don't count Staging as a test system. Sure, I use it to do an integration test for code before it goes to the users, but that's not the only kind of testing

Commenting your Code

You should always add descriptive comments to any code that will live longer than a single event. It's useful not only for the other unfortunate souls blessed with your code, but for yourself, years later, when you say "what was I thinking here?"

PowerShell and SQL Server: Script all Tables

This is a script that I found/put together/re-arranged that will script out all of the tables from a database - in this case, Adventureworks2008. You need to change the BWOODY1 part to the name of your server, and the SQL2K8 part to your Instance name.
Posted by Buck Woody | 0 Comments

Use PowerShell to Backup All User Databases

This script will back up all user databases - you need to change the BWOODY1\SQL2K8 part to your server\instance name, and of course, you should only run this on a test system until you completely understand it. Unfortunately, the SQL Server PowerShell
Posted by Buck Woody | 4 Comments

Read the SQL Server Error Log with PowerShell

This script uses a native client call, so you can use it on any machine that has PowerShell installed along with the SQL Server client software. As always, only run this script on a test system until you understand what it does, and of course you'll need
Posted by Buck Woody | 3 Comments

A Template for Setting and Reading Extended Properties

In the SQLCMS project, I show an example of some "base tables" that you can create for the system. Whenever I create a database, or database object, I make use of a feature that's been around for quite awhile - Extended Properties. You can set and read

Who is Active - a replacement for sp_who2

Most every DBA I know uses sp_who2, an undocumented stored procedure that shows locking, blocking, who is on, what they are doing and so on. At TechEd on Monday (I could only go for one day this time) I met up with my friend Adam Mechanic - a SQL Server

T-SQL to Find Physical and Logical Processors

I ran into a licensing question the other day on Physical versus Logical Processors. Happily, Microsoft only charges you for Physical sockets - which you can find with this query: SELECT cpu_count / hyperthread_ratio AS PhysicalCPUs FROM sys.dm_os_sys_info

Quickly Locate Text in a Query Window in SSMS

Wow - long title.   Anyway, my good friend Bill Ramos and I were chatting just the other day. He's a the guy at Microsoft that took my old responsibilities for SQL Server Management Studio (SSMS), and we were swapping tips and tricks. He showed me

Listing the Central Management Servers Programmatically

I don't normally advocate hitting the system tables in any database with direct queries, preferring instead to use views or functions that the vendor provides. But so far I haven't been able to find the view or function that would return the list of servers

Run a SQL Server Command from PowerShell without the SQL Server Provider

Some folks don't have SQL Server 2008 installed - shame on you! If you're in that sad state, you can still run a query against a SQL Server. You will still need the client connection software installed on your system - you'll have that with any 2005 edition
Posted by Buck Woody | 1 Comments
Filed under: ,
More Posts Next page »
 
Page view tracker