Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Request for sql 2008
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ykieko
Starting Member

1 Posts

Posted - 10/17/2012 :  23:09:52  Show Profile  Reply with Quote
Hi,
I am quite new at sql query...
I would like to get the below result in sql..
Required format: caren@emaildomain
(small letter for first name+email address)
So,is it possible to help me how can i get this result in sql 2008???

Please kindly see my current query result....

SELECT
t1.ID
,t1.NAME
,substring(t1.NAME,0,CHARINDEX(' ',t1.name,1)) As FirstName
,substring(t1.NAME,CHARINDEX(' ',t1.name,1)+1,150) AS LastName
FROM EMAIL as t1
left JOIN SM01_CONTACT AS t2
ON t1.ID like ltrim(rtrim(t2.ID))+'%'

One Row sample Result is
ID:1
Name:Caren Jone
FirstName:Caren
LastName:Jone

I am looking forward to your kind replys!!!!

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 10/17/2012 :  23:17:15  Show Profile  Reply with Quote
if the format is consistent


SELECT t1.ID
,t1.NAME
,PARSENAME(REPLACE(t1.NAME,' ','.'),2) AS FirstName
,PARSENAME(REPLACE(t1.NAME,' ','.'),1) AS LastName
FROM EMAIL as t1 
left JOIN SM01_CONTACT AS t2
ON t1.ID like ltrim(rtrim(t2.ID))+'%'


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000