To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here

HOME News MS SQL Oracle DB2 Access MySQL PHP Scripts Books Links DBA Talk


Go Back   Database Journal Forums > Database Discussions > MS SQL Server 7/MS SQL Server 2000

MS SQL Server 7/MS SQL Server 2000 Discuss Microsoft SQL Server 2000 and earlier in this forum

Reply Post New Thread
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 03-17-2005, 02:53 PM
jannat jannat is offline
Registered User
 
Join Date: Oct 2002
Location: queens
Posts: 139
Breakin last naem, first name from full name

Hello all,

I have a field called name and the data is as John, Smith.

I need to show it as Smith John. How can I do it?

Any help will be appriciated.

Thanks in advance!!
Reply With Quote
  #2  
Old 03-17-2005, 03:31 PM
nosepicker nosepicker is offline
Registered User
 
Join Date: Dec 2004
Posts: 502
There may be a more elegant way to do it, but here is a straightforward method:

declare @name varchar(20)
set @name = 'John, Smith'

SET @name = LTRIM(RTRIM(SUBSTRING(@name, CHARINDEX(',', @name, 1) +1, LEN(@name) - CHARINDEX(',', @name, 1)))) + ' ' + LTRIM(RTRIM(LEFT(@name, CHARINDEX(',', @name, 1) -1)))

SELECT @name
Reply With Quote
  #3  
Old 03-17-2005, 03:34 PM
jannat jannat is offline
Registered User
 
Join Date: Oct 2002
Location: queens
Posts: 139
Thanks a lot! That works.
Reply With Quote
Reply Post New Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:32 AM.


DatabaseJournal Recent Articles


 » Configuring Oracle as a Data Source for SQ...

 » Tips for Simplifying Crosstab Query Statem...

 » Redmond exploits MySQL uncertainty

 » Oracle Launches Oracle Global Trade Manage...

 » SQL Server 2008 RTM Support Ends April 13,...

Search Database Journal:
 








Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.