<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jay R. Wren - lazy dawg evarlast &#187; SQLServer</title>
	<atom:link href="http://jrwren.wrenfam.com/blog/category/sqlserver/feed/" rel="self" type="application/rss+xml" />
	<link>http://jrwren.wrenfam.com/blog</link>
	<description>babblings of a computer loving fool</description>
	<lastBuildDate>Wed, 01 Feb 2012 19:08:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>RegexReplace in SQL Server</title>
		<link>http://jrwren.wrenfam.com/blog/2009/04/23/regexreplace-in-sql-server/</link>
		<comments>http://jrwren.wrenfam.com/blog/2009/04/23/regexreplace-in-sql-server/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 20:55:07 +0000</pubDate>
		<dc:creator>jrwren</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[SQLServer]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://jrwren.wrenfam.com/blog/2009/04/23/regexreplace-in-sql-server/</guid>
		<description><![CDATA[My last post was about SQL Server. Even 10+ years later, I’m continually amazed by features which are daily use features in MySQL and Postgresql which are missing from MS SQL Server. Regular expression matching and replacing is a severely &#8230; <a href="http://jrwren.wrenfam.com/blog/2009/04/23/regexreplace-in-sql-server/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>My last post was about SQL Server. Even 10+ years later, I’m continually amazed by features which are daily use features in MySQL and Postgresql which are missing from MS SQL Server.</p>
<p>Regular expression matching and replacing is a severely lacking feature.</p>
<p>Sql Server 2005 introduced a means to write user defined functions in .NET code, so this method is uploaded to a sql server and exposed as a function.</p>
<p>[Microsoft.SqlServer.Server.SqlFunction]   <br />public static SqlString RegexReplace(SqlString input, SqlString pattern, SqlString replacement)    <br />{    <br />&#160;&#160;&#160; var result = System.Text.RegularExpressions.Regex.Replace(input.Value, pattern.Value, replacement.Value);    <br />&#160;&#160;&#160; return new SqlString(result);    <br />}</p>
<p>&#160;</p>
<p>Now you can use it in select statements.</p>
<p>SELECT&#160;&#160;&#160;&#160;&#160;&#160;&#160; Name, dbo.RegexReplace(Name, N&#8217;(?:\d+-)?\d+PPM&#8217;, N&#8221;) AS e   <br />FROM&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Table2</p>
<p>&#160;</p>
<p>Or use it to update tables</p>
<p>update table2 set name=dbo.RegexReplace(Name, N&#8217;(?:\d+-)?\d+PPM&#8217;, N&#8221;)</p>
<p>&#160;</p>
<p>I have absolutely no idea how any database developer could live without this kind of functionality.</p>
]]></content:encoded>
			<wfw:commentRss>http://jrwren.wrenfam.com/blog/2009/04/23/regexreplace-in-sql-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SQL Server Command Line Administration</title>
		<link>http://jrwren.wrenfam.com/blog/2009/04/23/sql-server-command-line-administration/</link>
		<comments>http://jrwren.wrenfam.com/blog/2009/04/23/sql-server-command-line-administration/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 20:43:08 +0000</pubDate>
		<dc:creator>jrwren</dc:creator>
				<category><![CDATA[Script]]></category>
		<category><![CDATA[SQLServer]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://jrwren.wrenfam.com/blog/2009/04/23/sql-server-command-line-administration/</guid>
		<description><![CDATA[I don’t have SQL Management Studio installed. Perhaps I should install it, it would make my life easier. Here are the commands I used to create a new database and add myself to it as administrator. I want to own &#8230; <a href="http://jrwren.wrenfam.com/blog/2009/04/23/sql-server-command-line-administration/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I don’t have SQL Management Studio installed. Perhaps I should install it, it would make my life easier.</p>
<p>Here are the commands I used to create a new database and add myself to it as administrator. I want to own the database too. I don’t want to have to be sa (root for you mysql folk) just to be able to create tables. I want to delegate the ownership of this database instance (not the whole sql server) to a non-admin user. This is just for me, for dev on my laptop.</p>
<blockquote><p>C:\&gt;osql -E -S .\SQLEXPRESS -V 2 -Q &quot;create database test2&quot;      <br />C:\&gt;osql -E -S .\SQLEXPRESS -V 2 -Q &quot;use test2;exec sp_changedbowner [theknife\jrwren]&quot;      <br />C:\&gt;osql -E -S .\SQLEXPRESS -V 2 -Q &quot;exec sp_configure &#8216;clr enabled&#8217;, 1&quot;      <br />Configuration option &#8216;clr enabled&#8217; changed from 0 to 1. Run the RECONFIGURE      <br />statement to install.       <br />C:\&gt;osql -E -S .\SQLEXPRESS -V 2 -Q &quot;reconfigure&quot;</p>
</blockquote>
<p>Finding this set of commands was the must frustrating experience that I have had in a VERY long time. It made me long for Postgresql or MySQL.</p>
]]></content:encoded>
			<wfw:commentRss>http://jrwren.wrenfam.com/blog/2009/04/23/sql-server-command-line-administration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

