HOME | FERGUSON Digital Blog

CF First and Last Name Combined In One Record

ColdFusion Add comments

In sharp contrast to how make SQL deal with a list value, ColdFusion is very versatile. Although the SQL version of this example can be very confusing to look at, the ColdFusion version is very short and easy to understand. What programmers forget to do sometimes, is give more data manipulation to the SQL server. Most of the time the server is just sitting there waiting for the formatted data to be sent to it from ColdFusion, or waiting for a query request. We tend to give everything to ColdFusion to do, causing our processes to slow down while our SQL server is barely used.

Here is how list values can be extracted in ColdFusion:

<cfset NameConcat="John.Q.Public">

<cfset NameFirst=ListGetAt(NameConcat, 1, ".")>
<cfset NameLast=ListGetAt(NameConcat, 3, ".")>
<cfset NameMI=ListGetAt(NameConcat, 2, ".")>

Very short, very easy to understand, ListGetAt just returns the substring from the position in the list as defined.

If you find this post useful please leave a comment and let me know how you used the information.

0 responses to “CF First and Last Name Combined In One Record”

Leave a Reply




© Copyright 1997-2024, All Rights Reserved Coldfusion and MS SQL2008
Powered by Mango Blog.   Design by FERGUSON Digital
o:Event name="beforeHtmlBodyEnd" />