﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server 2008 - General  / concat string with numeric / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 25 May 2013 10:53:55 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: concat string with numeric</title><link>http://www.sqlservercentral.com/Forums/Topic1384870-391-1.aspx</link><description>Thx good advice.. have a great dayU7</description><pubDate>Thu, 15 Nov 2012 05:28:48 GMT</pubDate><dc:creator>jbalbo</dc:creator></item><item><title>RE: concat string with numeric</title><link>http://www.sqlservercentral.com/Forums/Topic1384870-391-1.aspx</link><description>[quote][b]jbalbo (11/14/2012)[/b][hr]ThanksSO this works!!!Client.LName + ', ' + Client.FName + ' -' + cast(client.ID as nvarchar)  as ClientName[/quote]Be very careful about using the default lengths for datatypes. When you don't specify the length you get the default size, and this can vary depending on context. I would add a length for your nvarchar. I don't know what datatype your ID is but 10 should be plenty of room. Make it smaller if you don't need that much length, or longer if needed.[code]Client.LName + ', ' + Client.FName + ' -' + cast(client.ID as nvarchar(10))  as ClientName[/code]/soapbox onAs a side note, it is often considered poor naming convention to have ID. What happens when you have two tables with a PK named ID? Something like ClientID is probably a better choice. One general rule for databases is that is usually preferred that a column name not change it's name when referenced as a foreign key. For example. If you have an Order table and the PK is ID it gets awfully confusing. You have a column with the same name in two tables but you join those tables on Order.ClientID = Client.ID where Order.ID = 8473. That just makes my head spin. If those same two table were aliased O and C the join becomes very clear (O.ClientID = C.ClientID where O.OrderID = 8473/soapbox off</description><pubDate>Wed, 14 Nov 2012 14:58:42 GMT</pubDate><dc:creator>Sean Lange</dc:creator></item><item><title>RE: concat string with numeric</title><link>http://www.sqlservercentral.com/Forums/Topic1384870-391-1.aspx</link><description>ThanksSO this works!!!Client.LName + ', ' + Client.FName + ' -' + cast(client.ID as nvarchar)  as ClientName</description><pubDate>Wed, 14 Nov 2012 14:38:35 GMT</pubDate><dc:creator>jbalbo</dc:creator></item><item><title>RE: concat string with numeric</title><link>http://www.sqlservercentral.com/Forums/Topic1384870-391-1.aspx</link><description>You need to convert the numeric value to a text value.  [url]http://msdn.microsoft.com/en-us/library/ms187928.aspx[/url]  Once all the data is strings you can concat to your hearts content.</description><pubDate>Wed, 14 Nov 2012 14:36:18 GMT</pubDate><dc:creator>CapnHector</dc:creator></item><item><title>concat string with numeric</title><link>http://www.sqlservercentral.com/Forums/Topic1384870-391-1.aspx</link><description>I know this is pretty basic ...but how do I concat string and numeric?I wanted  Client.LName + ', ' + Client.FName + ' -' &amp; client.ID  as ClientNamewhere client.id is numericThanksin advanceJoe</description><pubDate>Wed, 14 Nov 2012 14:34:42 GMT</pubDate><dc:creator>jbalbo</dc:creator></item></channel></rss>