Can I define a custom, user-defined function that will stay active for as long as the sqlsrv_connect
connection stays on? If it can't stay on for the whole connection time, I could live with it being defined at least just before the execution of a specific SELECT
query.
Specifically, for a particular SELECT
query I want to use something like the UPPER
function, which will drop accents of Greek capital letters... So I crafted my custom function that will take care of that, named it UPPERGR
but I don't know how to execute this query...
CREATE FUNCTION UPPERGR(@Word nvarchar(max))
RETURNS nvarchar(max)
AS
BEGIN
DECLARE @Ret nvarchar(max);
SET @Ret = UPPER(@Word);
SET @Ret = REPLACE(@Ret,'Ά','Α');
SET @Ret = REPLACE(@Ret,'Έ','Ε');
SET @Ret = REPLACE(@Ret,'Ή','Η');
SET @Ret = REPLACE(@Ret,'Ί','Ι');
SET @Ret = REPLACE(@Ret,'Ό','Ο');
SET @Ret = REPLACE(@Ret,'Ύ','Υ');
SET @Ret = REPLACE(@Ret,'Ώ','Ω');
RETURN @Ret;
END;
So I want to run the command above just before executing my SELECT
query below:
SELECT prod.ID,
prod.CODE,
prod.DESCRIPTION AS TITLE,
prod.REMARKS AS DESCRIPTION,
prod.DESCR2 AS SHORTDESCRIPTION,
manuf.DESCR AS MANUFACTURER,
CONCAT(UPPERGR(cat1.DESCR), ' > ', UPPERGR(cat2.DESCR), ' > ', UPPERGR(cat3.DESCR)) AS CATEGORIES,
...
Can someone help me with this unusual task please? Thank you in advance!