Posted on January 30, 2010, 4:44 pm, by Rhys, under
DBA.
Just a quick post showing how to add a Postgres database server as a Linked Server in Microsoft SQL Server.
Install the psqlODBC driver for Windows.
Control Panel > Administrative Tools > Data Sources (ODBC).
Click the "System DSN" tab and click the Add button.
Choose "PostreSQL ANSI" and click Finish.
Configure the data source by [...]
Posted on January 18, 2010, 9:08 pm, by Rhys, under
DBA,
T-SQL.
If you ever encounter this SQL Server error when selecting from a view then somebody has probably dropped columns from the base table. Here’s a quick run through of the problem.
?View Code TSQLCREATE TABLE dbo.Contact
(
Id INTEGER IDENTITY(1,1) NOT NULL PRIMARY KEY CLUSTERED,
FirstName VARCHAR(50) NOT NULL,
LastName VARCHAR(50) NOT NULL,
DOB DATETIME NOT NULL,
Phone VARCHAR(30) NULL,
Email VARCHAR(200) NULL,
Mobile [...]
Posted on January 14, 2010, 9:18 pm, by Rhys, under
DBA,
T-SQL.
Today I received the following SQL Server error which I had never encountered before.
Msg 4429, Level 16, State 1, Line 1 View or function ‘Table_1′ contains a self-reference. Views or functions cannot reference themselves directly or indirectly. Msg 4413, Level 16, State 1, Line [...]
Posted on December 28, 2009, 3:26 pm, by Rhys, under
Powershell.
Chuck Boyce Jr (blog | twitter) recently commented on a limitation of the script from my post Discover SQL Servers with Powershell. The script does require that the SQLBrowser service is running for discovery to occur which may be a major issue for some. Here’s an alternative method that does not have this limitation. All [...]
Posted on December 6, 2009, 7:40 pm, by Rhys, under
SSIS.
I’m currently building a lot of SSIS packages that are primarily date driven. Many of these involve periods of 100 days, to several years, so I wanted to automate the testing of these packages. I’d previously automated the testing of stored procedures over date ranges but wanted a solution for testing the system as a [...]
Posted on September 5, 2009, 5:21 pm, by Rhys, under
Powershell.
With Powershell and SMO you can easily discover SQL Server instances running on your network in just a few lines of code.
?View Code POWERSHELL[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null;
$smoObj = [Microsoft.SqlServer.Management.Smo.SmoApplication];
# This gets the sql servers available
$sql = $smoObj::EnumAvailableSqlServers($false)
foreach($sqlserver in $sql)
{
Write-Host -ForegroundColor Green "Discovered sql server: " $sqlserver.Name;
}
If this doesn’t seem to find all your sql servers [...]
Posted on July 9, 2009, 4:10 pm, by Rhys, under
T-SQL.
Previously I wrote an article about fulltext searching with MySQL and thought I’d redo the same article but for SQL Server users. Depending of which side of the database wars you’re on SQL Server has either a more advanced or complicated way of doing things. Here’s a very brief introduction to the fulltext search features [...]
Posted on June 23, 2009, 7:05 pm, by Rhys, under
DBA,
MySQL,
T-SQL.
Asking for database documentation in many tech shops will result in blank stares. Other places do see the value of but it forever remains on the to-do list. There are a few commercial products available hoping to help with this;
SchemaToDoc – http://www.schematodoc.com/ SqlSpec – http://www.elsasoft.org/ SQL Doc [...]
Posted on May 29, 2009, 7:44 am, by Rhys, under
Powershell.
Being able to know the setup and configuration of your SQL Servers is important for many IT Professionals. Powershell, combined with SMO, makes this task easy. SMO exposes a lot of properties allowing you to easily retrieve things like Processor & RAM Information, Service Pack Level, Operating System information, Collation Settings, number of Databases, and [...]
Posted on March 14, 2009, 2:14 pm, by Rhys, under
Tweet-SQL.
Tweet-SQL is a Twitter Client for Microsoft SQL Server 2005 and above allowing you to interact with the Twitter API with standard T-SQL. The forthcoming version 2 of Tweet-SQL contains a host of new features and improvements. Here’s a sneak peek at what is coming in Tweet-SQL V2;
New procedure allowing the use of the Twitter [...]