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
Database Journal Forums
>
Database Discussions
>
MS SQL Server 7/MS SQL Server 2000
Breakin last naem, first name from full name
User Name
Remember Me?
Password
Register
FAQ
Members List
Calendar
Search
Today's Posts
Mark Forums Read
MS SQL Server 7/MS SQL Server 2000
Discuss Microsoft SQL Server 2000 and earlier in this forum
Thread Tools
Search this Thread
Rate Thread
Display Modes
#
1
03-17-2005, 02:53 PM
jannat
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!!
jannat
View Public Profile
Find all posts by jannat
#
2
03-17-2005, 03:31 PM
nosepicker
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
nosepicker
View Public Profile
Find all posts by nosepicker
#
3
03-17-2005, 03:34 PM
jannat
Registered User
Join Date: Oct 2002
Location: queens
Posts: 139
Thanks a lot! That works.
jannat
View Public Profile
Find all posts by jannat
Bookmarks
Digg
del.icio.us
StumbleUpon
Google
«
Previous Thread
|
Next Thread
»
Thread Tools
Search this Thread
Show Printable Version
Email this Page
Search this Thread
:
Advanced Search
Display Modes
Rate This Thread
Linear Mode
Switch to Hybrid Mode
Switch to Threaded Mode
Rate This Thread
:
5 : Excellent
4 : Good
3 : Average
2 : Bad
1 : Terrible
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
User Control Panel
Private Messages
Subscriptions
Who's Online
Search Forums
Forums Home
Database Discussions
IBM DB2
Informix
Microsoft Access
Microsoft SQL Server 2008
Microsoft SQL Server 2005
MDX and Analysis Services
Reporting Services
MS SQL Server 7/MS SQL Server 2000
MySQL
Oracle
PostgreSQL
Sybase
Miscellaneous
General Database Discussions
Ask an Expert
Database Design
Database Programming
Database News and Announcements
Structured Query Language (SQL)
SQL Scripts
Database Lounge
Feedback
Related Sites
SQL Course
SqlCredit
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:
View RSS feed
Contact Us
-
Database Journal Forums
-
Top