Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to pull empId using concatenated Firstname and LastName, please check the code:

SQL
select UPPER (issueid) as IssID,rtrim(upper(left(Description, 1))
+ substring(Description ,2,len(Description ))) as Descrptn,
status,priority,(select ( rtrim( upper(left(a.First_name, 1))+
substring(a.First_Name ,2,len(a.First_Name ))) +' ' +
rtrim(upper(left(a.Last_Name, 1))+substring(a.Last_Name  ,2,len(a.last_Name ))))
from User_Details a where Emp_ID = issDtl.created_by) as Name,Created_On
from Issue_Details as issDtl where project_id = 214587 and issDtl.Created_By  =
(select emp_id from user_details where
 UPPER (First_Name+' '+Last_Name ) = 'SOUVIK DUTTA')

Please let me know how should it work
Posted
Updated 18-Aug-10 21:46pm
v2

1 solution

Dear SouvikD

The code works if there is no null value in any of these fields. else will throw error.

I do not understand the reason for using the mode of "rtrim(upper(left(Description, 1))
+ substring(Description ,2,len(Description ))) as Descrptn," when you can directly fetch the value.
 
Share this answer
 
Comments
souvikd 19-Aug-10 10:19am    
i am able to handle the errors, i just need to write a query which will fetch the emp_id from the concatenated first and last name.
shivaprasadk 19-Aug-10 12:40pm    
Other than overloading issue (use "display Estimated execution plan" to know the time taken for query execution), the query has no issues. It fetches the value required.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900