<?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>CoryMathews.com &#187; MsSQL</title>
	<atom:link href="http://corymathews.com/category/mssql/feed/" rel="self" type="application/rss+xml" />
	<link>http://corymathews.com</link>
	<description>Things I should remember and then some...</description>
	<lastBuildDate>Wed, 04 Aug 2010 18:32:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Select and Insert in 1 SQL Query</title>
		<link>http://corymathews.com/570/select-and-insert-in-1-sql-query/</link>
		<comments>http://corymathews.com/570/select-and-insert-in-1-sql-query/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 21:30:14 +0000</pubDate>
		<dc:creator>CoryMathews</dc:creator>
				<category><![CDATA[MsSQL]]></category>

		<guid isPermaLink="false">http://corymathews.com/?p=570</guid>
		<description><![CDATA[I really dislike messing with cursors and loops in SQL and so I jump on any chance I get to avoid them. This little SQL-Server trick allow me to perform a select and insert statements in just 1 short query. In the simplest form the query looks like the following. INSERT INTO Table2 (col1, col2) [...]]]></description>
			<content:encoded><![CDATA[<p>I really dislike messing with cursors and loops in SQL and so I jump on any chance I get to avoid them. This little SQL-Server trick allow me to perform a select and insert statements in just 1 short query. In the simplest form the query looks like the following.</p>
<pre>INSERT INTO Table2 (col1, col2)
SELECT col3, col4
FROM Table1</pre>
<hr />How about a bit detailed example using the following sample database structure.</p>
<p><strong>Table1</strong><br />
===========<br />
Tbl1_ID (going to assume an auto increment here)<br />
FK_Tbl2_ID<br />
Data_Copy</p>
<p><strong>Table2</strong><br />
===========<br />
Tbl2_ID<br />
Data</p>
<p><strong>Query1</strong>: Select Tbl2_ID From Table2 Where Data = 1</p>
<p>For every returned record from query1 it should insert a record into Table1</p>
<pre>INSERT INTO Table1 (FK_Tbl2_ID, Data_Copy)
SELECT Tbl2_ID, Data
FROM Table2
WHERE Data = 1</pre>
<p>If anyone has seen/done any kind of performance testing on this sort of query would you kindly post them below.</p>
]]></content:encoded>
			<wfw:commentRss>http://corymathews.com/570/select-and-insert-in-1-sql-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSSQL Escape Character</title>
		<link>http://corymathews.com/255/mssql-escape-character/</link>
		<comments>http://corymathews.com/255/mssql-escape-character/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 21:08:53 +0000</pubDate>
		<dc:creator>CoryMathews</dc:creator>
				<category><![CDATA[MsSQL]]></category>

		<guid isPermaLink="false">http://corymathews.com/?p=255</guid>
		<description><![CDATA[Here is something that got me for a while today, escaping characters in MsSQL. I went through and tried the normal \ then thought I was losing it and tried the other slash /. However for some odd reason Microsoft went with the single tick &#8216;. So for example a mssql query using the escape [...]]]></description>
			<content:encoded><![CDATA[<p>Here is something that got me for a while today, escaping characters in MsSQL. I went through and tried the normal \ then thought  I was losing it and tried the other slash /. However for some odd reason Microsoft went with the single tick &#8216;.</p>
<p>So for example a mssql query using the escape character might look like</p>
<pre name="code" class="sql">SELECT a FROM b WHERE a = 'cory''s'</pre>
<p>Notice the double tick to escape the apostrophe. Really quite simple but still really weird.</p>
]]></content:encoded>
			<wfw:commentRss>http://corymathews.com/255/mssql-escape-character/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
