Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
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 LastNameFROM EMAIL as t1 left JOIN SM01_CONTACT AS t2ON t1.ID like ltrim(rtrim(t2.ID))+'%'One Row sample Result isID:1Name:Caren Jone FirstName:Caren LastName:JoneI 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 LastNameFROM EMAIL as t1 left JOIN SM01_CONTACT AS t2ON t1.ID like ltrim(rtrim(t2.ID))+'%'
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/