<?xml version="1.0" encoding="utf-8"?>
			
			<rss version="2.0">
			<channel>
			<title>Steve Bryant - SQL</title>
			<link>http://www.bryantwebconsulting.com/blog/index.cfm</link>
			<description>A Web Programmer&apos;s Exploration</description>
			<language>en-us</language>
			<pubDate>Mon, 08 Jun 2026 20:30:48-0500</pubDate>
			<lastBuildDate>Tue, 04 Feb 2025 11:00:00-0500</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>steve@bryantwebconsulting.com</managingEditor>
			<webMaster>steve@bryantwebconsulting.com</webMaster>
			
			
			
			
			
			<item>
				<title>Return a list of related records in SQL Server 2017</title>
				<link>http://www.bryantwebconsulting.com/blog/index.cfm/2025/2/4/Return-a-list-of-related-records-in-SQL-Server-2017</link>
				<description>
				
				I absolutely love SQL (especially SQL Server) and I love how it continually gets better.

A little over four years ago, I wrong an entry on &lt;a href=&quot;http://www.bryantwebconsulting.com/blog/index.cfm/2020/10/21/SQL-Server-Lists&quot;&gt;how to return a comma-delimited list of records in SQL Server&lt;/a&gt;. It turns out, that it is now much easier to do.

SQL Server 2017 introduced the STRING_AGG function. For those of you doing math, it would have actually been available when I wrote the previous entry, but we&apos;ll just ignore that and I&apos;ll use the same example.

For example, if you have users that can work in multiple regions and you need a list of which regions they work in.
				 [More]
				</description>
						
				
				<category>SQL</category>				
				
				<pubDate>Tue, 04 Feb 2025 11:00:00-0500</pubDate>
				<guid>http://www.bryantwebconsulting.com/blog/index.cfm/2025/2/4/Return-a-list-of-related-records-in-SQL-Server-2017</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Return a list of related records in SQL Server</title>
				<link>http://www.bryantwebconsulting.com/blog/index.cfm/2020/10/21/SQL-Server-Lists</link>
				<description>
				
				I absolutely love SQL (especially SQL Server) and I love how I continually find new ways to solve problems with it. I wish I could remember where I first found this tip to give proper credit, but I really love it.

Have you ever wanted to return a comma-delimited list of records in SQL Server? It turns out, that it is actually pretty easy to do.

For example, if you have users that can work in multiple regions and you need a list of which regions they work in.
				 [More]
				</description>
						
				
				<category>SQL</category>				
				
				<pubDate>Wed, 21 Oct 2020 10:45:00-0500</pubDate>
				<guid>http://www.bryantwebconsulting.com/blog/index.cfm/2020/10/21/SQL-Server-Lists</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>SQL Excluding Record sets</title>
				<link>http://www.bryantwebconsulting.com/blog/index.cfm/2011/7/14/SQL-Excluding-Record-sets</link>
				<description>
				
				I was eating with another speaker at &lt;a href=&quot;http://www.cfobjective.com/&quot;&gt;cf.Objective()&lt;/a&gt; (I am resolved to find a way to work my having spoken at a conference into all future anecdotes) and an interesting SQL question came up: How to delete everything &lt;em&gt;except&lt;/em&gt; the first 1000 records. To my mind, this brought up a general class of problems in SQL. Which is, returning results that exclude the result of a query.

With that in mind, let&apos;s look at a few of those.
				 [More]
				</description>
						
				
				<category>SQL</category>				
				
				<pubDate>Thu, 14 Jul 2011 09:45:00-0500</pubDate>
				<guid>http://www.bryantwebconsulting.com/blog/index.cfm/2011/7/14/SQL-Excluding-Record-sets</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Many-to-Many Relationships and All</title>
				<link>http://www.bryantwebconsulting.com/blog/index.cfm/2008/7/9/ManytoMany-Relationships-and-All</link>
				<description>
				
				Most of us have deal with many-to-many relationships from time to time. This is generally easy. What happens, though, when the client wants some items to be available to all members of the related table?

For example, I might have some articles that are only available to users with certain permissions.

If that were the case, then I might have an articles2permissions table. Then I might pass in a comma-delimited list of permissions when retrieving articles:
				 [More]
				</description>
						
				
				<category>SQL</category>				
				
				<pubDate>Wed, 09 Jul 2008 07:00:00-0500</pubDate>
				<guid>http://www.bryantwebconsulting.com/blog/index.cfm/2008/7/9/ManytoMany-Relationships-and-All</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Slow Table in SQL Server? Re-Index it!</title>
				<link>http://www.bryantwebconsulting.com/blog/index.cfm/2008/6/18/Slow-Table-in-SQL-Server-ReIndex-it</link>
				<description>
				
				One of my sites has started getting sluggish lately. I thought it was just that the traffic was increasing and so I should optimize my code. Then, in the last couple of weeks, I had a 3AM scheduled task crash a few times. This weekend, I had a simple query with one row and one column take several minutes to execute even from the SQL Server Query Analyzer. This is getting weird!
				 [More]
				</description>
						
				
				<category>SQL</category>				
				
				<pubDate>Wed, 18 Jun 2008 07:30:00-0500</pubDate>
				<guid>http://www.bryantwebconsulting.com/blog/index.cfm/2008/6/18/Slow-Table-in-SQL-Server-ReIndex-it</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Trouble with Triggers</title>
				<link>http://www.bryantwebconsulting.com/blog/index.cfm/2008/3/21/Trouble-with-Triggers</link>
				<description>
				
				I was trying to create a trigger in Oracle last night with cfquery and it wouldn&apos;t work. Oracle kept reporting that the trigger was invalid. If I copied the same exact SQL into Oracle directly, it would work. When I would look at the invalid trigger in Oracle and copy the SQL from there into Oracle, it would fix the trigger, but still I couldn&apos;t get it to work from there.
				 [More]
				</description>
						
				
				<category>SQL</category>				
				
				<pubDate>Fri, 21 Mar 2008 07:00:00-0500</pubDate>
				<guid>http://www.bryantwebconsulting.com/blog/index.cfm/2008/3/21/Trouble-with-Triggers</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Copy Legacy Data with SQL</title>
				<link>http://www.bryantwebconsulting.com/blog/index.cfm/2008/2/1/Copy-Legacy-Data-with-SQL</link>
				<description>
				
				&lt;p&gt;In talking to a friend of mine yesterday, I realized that a great many programmers are not aware of one of the nicest features of SQL, the ability to insert the results of a query into a table. This is really handy for copying data from an old format to a newer format or if you have a need to denormalize part of a database.&lt;/p&gt;
				 [More]
				</description>
						
				
				<category>SQL</category>				
				
				<pubDate>Fri, 01 Feb 2008 14:00:00-0500</pubDate>
				<guid>http://www.bryantwebconsulting.com/blog/index.cfm/2008/2/1/Copy-Legacy-Data-with-SQL</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Using the Derby Database</title>
				<link>http://www.bryantwebconsulting.com/blog/index.cfm/2007/6/8/using_the_derby_database</link>
				<description>
				
				&lt;p&gt;When I read Ben Forta&apos;s &lt;a href=&quot;http://www.forta.com/blog/index.cfm/2007/5/28/Scorpio-And-Apache-Derby&quot;&gt;announcement&lt;/a&gt; (and &lt;a href=&quot;http://www.forta.com/blog/index.cfm/2007/5/29/More-On-Scorpio-And-Apache-Derby&quot;&gt;follow up&lt;/a&gt;)  that ColdFusion 8 would ship with support for the &lt;a href=&quot;http://db.apache.org/derby/&quot;&gt;Derby database&lt;/a&gt;, my first thought was &amp;quot;I should add support for that in &lt;a href=&quot;http://datamgr.riaforge.org/&quot;&gt;DataMgr&lt;/a&gt;&amp;quot;. This proved to be a good introduction to Derby.&lt;/p&gt;&lt;p&gt;I decided that I would get my local copy of my &lt;a href=&quot;http://demo.bryantwebconsulting.com/&quot;&gt;demonstration site&lt;/a&gt;  running on Derby.&lt;/p&gt;
				 [More]
				</description>
						
				
				<category>ColdFusion</category>				
				
				<category>SQL</category>				
				
				<category>DataMgr</category>				
				
				<pubDate>Fri, 08 Jun 2007 13:37:00-0500</pubDate>
				<guid>http://www.bryantwebconsulting.com/blog/index.cfm/2007/6/8/using_the_derby_database</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Join Tables and Primary Keys</title>
				<link>http://www.bryantwebconsulting.com/blog/index.cfm/2007/5/24/join_tables_and_primary_keys</link>
				<description>
				
				&lt;p&gt;I have found that many people set up the primary keys for join tables in a manner that I find undesirable. This leaves open the possibility of some sneaky bugs in their programs.&lt;/p&gt;&lt;p&gt;I&apos;ll start by covering what I mean by a join table (as opposed to what I will call a data table).&lt;/p&gt;&lt;p&gt;Most basic data is stored in data tables. For example a &amp;quot;users&amp;quot; table is a data table, as is a &amp;quot;groups&amp;quot; table. Each row in a &amp;quot;users&amp;quot; table represents one user, as each row in a &amp;quot;groups&amp;quot; table would represent a group.&lt;/p&gt;
				 [More]
				</description>
						
				
				<category>SQL</category>				
				
				<pubDate>Thu, 24 May 2007 13:44:00-0500</pubDate>
				<guid>http://www.bryantwebconsulting.com/blog/index.cfm/2007/5/24/join_tables_and_primary_keys</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Traveling Reference</title>
				<link>http://www.bryantwebconsulting.com/blog/index.cfm/2007/1/26/travelling_reference</link>
				<description>
				
				&lt;p&gt;&lt;a href=&quot;http://www.forta.com/blog/&quot;&gt;Ben Forta&lt;/a&gt;  is &lt;a href=&quot;http://www.forta.com/blog/index.cfm/2007/1/26/Book-Publishing-Dilemma-Input-Requested&quot;&gt;asking for input&lt;/a&gt;  on his next &lt;a href=&quot;http://www.amazon.com/gp/tagging/glance/cfwack&quot;&gt;CFWACK&lt;/a&gt;  book. The discussion in the comments reminded of the old CFML Reference that I keep with me. It is one of a few books that I always have near my computer when I travel.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://www.oreilly.com/catalog/csspr/&quot;&gt;CSS Pocket Reference&lt;/a&gt;  (outdated, but still handy when I can&amp;#39;t remember some bit of syntax)&lt;/li&gt;&lt;li&gt;ColdFusion Quick Reference Guide to CFML (no longer in print, but still handy to jog my memory a bit)&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.forta.com/books/0672325667/&quot;&gt;Regular Expressions in 10 Minutes&lt;/a&gt;  (Forta strikes again!)&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.amazon.com/SQL-Pocket-Guide-Jonathan-Gennick/dp/0596005121&quot;&gt;SQL Pocket Reference&lt;/a&gt; (perhaps the least used of the bunch, but I still like to have it)&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.bartleby.com/141/&quot;&gt;The Elements of Style&lt;/a&gt;  (I don&amp;#39;t write the copy, but it has still been handy)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;These books taken together weigh less than a pound and take up less space than your average computer book. They have still managed to be tremendously useful when I am working on the road (especially if I am trying to get some work done with no internet connection).&lt;/p&gt;&lt;p&gt;Anyone else have suggestions for books that they don&amp;#39;t leave home without?&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;
				
				</description>
						
				
				<category>ColdFusion</category>				
				
				<category>Personal</category>				
				
				<category>SQL</category>				
				
				<category>CSS</category>				
				
				<pubDate>Fri, 26 Jan 2007 19:29:00-0500</pubDate>
				<guid>http://www.bryantwebconsulting.com/blog/index.cfm/2007/1/26/travelling_reference</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>SQL to Put Record for Current User First</title>
				<link>http://www.bryantwebconsulting.com/blog/index.cfm/2006/5/9/sql_to_put_record_for_current_user_first</link>
				<description>
				
				I was recently asked how to show a record for the current user before the record for other users - in one query. Here is my solution.&lt;br /&gt;&lt;br /&gt;
				 [More]
				</description>
						
				
				<category>SQL</category>				
				
				<pubDate>Tue, 09 May 2006 21:01:00-0500</pubDate>
				<guid>http://www.bryantwebconsulting.com/blog/index.cfm/2006/5/9/sql_to_put_record_for_current_user_first</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Avoid Select *</title>
				<link>http://www.bryantwebconsulting.com/blog/index.cfm/2006/4/17/avoid_select_</link>
				<description>
				
				A &lt;a href=&quot;http://houseoffusion.com/cf_lists/messages.cfm/forumid:4/threadid:45532&quot;&gt;recent discussion on CF-Talk &lt;/a&gt;implied cfqueryparam as the culprit in a query problem. It seems, however that the problem only happens when using cfqueryparam in conjuction with &amp;quot;select *&amp;quot;.&lt;br /&gt;&lt;br /&gt;In the discussion, Ben Nadel pointed out reasons he recommends listing out columns instead of using of &amp;quot;select *&amp;quot;. His words:&lt;br /&gt;
				 [More]
				</description>
						
				
				<category>SQL</category>				
				
				<pubDate>Mon, 17 Apr 2006 13:41:00-0500</pubDate>
				<guid>http://www.bryantwebconsulting.com/blog/index.cfm/2006/4/17/avoid_select_</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>SQL Server Comments and ColdFusion MX 7</title>
				<link>http://www.bryantwebconsulting.com/blog/index.cfm/2005/6/27/sqlservercomments</link>
				<description>
				
				This problem (and solution) comes from my good friend Will Spurgeon of &lt;a href=&quot;http://www.tech-it-easy.net/&quot;&gt;Tech-It-Easy&lt;/a&gt;. He has long been using SQL comments when developing for SQL Server. The advantage of this approach is that you can see these comments when reviewing transactions in SQL Server Profiler. It can really help in a lot of trouble-shooting situations.&lt;br /&gt;&lt;br /&gt;For example:&lt;br /&gt;&lt;br /&gt;
				 [More]
				</description>
						
				
				<category>ColdFusion</category>				
				
				<category>SQL</category>				
				
				<pubDate>Mon, 27 Jun 2005 00:03:00-0500</pubDate>
				<guid>http://www.bryantwebconsulting.com/blog/index.cfm/2005/6/27/sqlservercomments</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Prevent duplicate Inserts</title>
				<link>http://www.bryantwebconsulting.com/blog/index.cfm/2005/3/16/prevent_duplicate_inserts</link>
				<description>
				
				I frequently need to insert a record that relates to tables to each other (or relates one table to external data) and I cannot have a duplicate record. Here is my method for doing this in case it helps anyone and as a convenient reference for myself.&lt;br /&gt;&lt;br /&gt;Let&apos;s suppose that you have three tables: Users, Classes and Students. Classes has a primary key of ClassID (int). Users has a primary key of UserID (int). Students has a two-column primary key of ClassID and UserID which relate to the corresponding columns in Classes and Users respectively.&lt;br /&gt;
				 [More]
				</description>
						
				
				<category>SQL</category>				
				
				<pubDate>Wed, 16 Mar 2005 13:46:00-0500</pubDate>
				<guid>http://www.bryantwebconsulting.com/blog/index.cfm/2005/3/16/prevent_duplicate_inserts</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Outer Join on Multiple Fields</title>
				<link>http://www.bryantwebconsulting.com/blog/index.cfm/2005/3/14/outer_join_on_multiple_fields</link>
				<description>
				
				I ran into a situation where I needed to do an outer join on more than one field (if only SQL supported such a thing). After banging my head against a wall for a bit, I asked the &lt;a href=&quot;http://www.houseoffusion.com/cf_lists/threads.cfm/4&quot;&gt;CF-Talk&lt;/a&gt; list.&lt;br /&gt;&lt;br /&gt;Lo and behold! SQL does support exactly what I want. I was just to dim to try it myself. Mark Gaulin provided the answer:&lt;br /&gt;
				 [More]
				</description>
						
				
				<category>SQL</category>				
				
				<pubDate>Mon, 14 Mar 2005 22:37:00-0500</pubDate>
				<guid>http://www.bryantwebconsulting.com/blog/index.cfm/2005/3/14/outer_join_on_multiple_fields</guid>
				
			</item>
			
		 	
			</channel></rss>