Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
SELECT EmpId,
EmpName=CASE
WHEN EmpName='Mahesh'; THEN 'Dasari Mahesh';
WHEN EmpName='Prasanthi'; THEN 'Donthi Prasanthi';
........
ELSE;
END,
Role
FROM Employeedetails




How to create dynamically More than 50 when statement that EmpName =Mahesh that value get from Database
Posted
Updated 17-Sep-14 23:32pm
v2
Comments
Bernhard Hiller 18-Sep-14 8:33am    
Ehm, isn't a database column containing the full name the item you actually need?

1 solution

Hi,

You have not provided full information to help you. Below i am trying to help you out on my understanding and your info.

Here i am considering your table structure is...

SQL
EmpId,
EmpName,
EmpFullName
.
.
and so on.


Check this ...
SQL
Create proc pr_emp_info
(
@pa_empName varchar(100)
)
AS 
BEGIN

SELECT EmpId, EmpFullName, Role from EmployeeDetails where empname=@pa_empName

END


Hope this will help you.

Cheers
 
Share this answer
 
Comments
Gauri Chodanker 18-Sep-14 6:34am    
Writing a stored procedure to get the name is not a valid point. Instead please let us know your exact table structures and the desired output. Maybe its a straight forward query that needs to be written
Magic Wonder 18-Sep-14 6:45am    
It is always better to write a small piece of code instead of duplicating and hard coding 50 lines of sql scripts. Its already mentioned in my solution that my solution is based on my assumption and input info by user.

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