What Version / Service Pack of SQL Server am I Running?

28 07 2009

Here’s a handy little script which tells you what version, service pack and edition of SQL Server you’re running.

It’s best to display results as “Text” rather than the “Grid”.

   SELECT   @@VERSION
   SELECT   RTRIM(CAST(SERVERPROPERTY('productversion') AS VARCHAR)) AS [Version],
            RTRIM(CAST(SERVERPROPERTY ('productlevel') AS VARCHAR)) AS [Level],
            RTRIM(CAST(SERVERPROPERTY ('edition') AS VARCHAR)) AS [Edition]

SQL Server Version Information

SQL Server Version Information





Export SQL Server 2005 Xml Column Data to Xml File

19 01 2009

Xml data stored using the SQL Server 2005 xml data type can be exported a number of ways and you can obviously write a managed stored procedure to do it.

However for a quick, one off, type approach you can use the BCP command.

bcp "SELECT [xml column name] FROM [TableName] FOR XML RAW"
      queryout c:\myOutputData.xml -SServerName -T -w -r -t

The downside of this is that, given the command above you’ll get your xml row data exported as shown;

<row><data>{row 1 xml}</row></data>
<row><data>{row 2 xml}</row></data>

so you might need to do some mangling on the output file, or you can obviously change the initial SELECT statement to shape your output appropriately.