I have the table below :
Desk_name | head
ali | john
cars ln | max
pol fr | max
jus | john
I want to create a stored procedure in order to have in return :
Name | sector_head
ali mm | john
cars ln | max
pol fr | max
jus mm | john
As you can see the column name has changed (from 'Name' to 'Desk_name') and every name in the 'Name' column has the abbreviation "mm" at the end of each values if it is a single word (ali and jus).
How can I do such a stored procedure (i am using sql server)?
Thanks
You need to supply ALIAS
on it, example
SELECT CASE WHEN LTRIM(RTRIM(Desk_name)) LIKE '% %' -- finds any space in string
THEN Desk_name
ELSE Desk_name + ' mm'
END AS Name,
head AS sector_head
FROM tableName
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With