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

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Request for sql 2008

Author  Topic 

ykieko
Starting Member

1 Post

Posted - 2012-10-17 : 23:09:52
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

52326 Posts

Posted - 2012-10-17 : 23:17:15
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
   

- Advertisement -