I'm trying to create function that takes data from table, replaces certain characters and returns replaced data. Function will be executed when called for.
CREATE FUNCTION convert_lat(@rawtxt NVARCHAR)
RETURNS NVARCHAR(50)
AS
BEGIN
DECLARE @raw_mon NVARCHAR(50);
SELECT @raw_mon = REPLACE (r.mongol, N'ф', 'f')
FROM Connection.dbo.raw r
WHERE r.mongol = @rawtxt
RETURN @raw_mon;
END;
GO
UPDATE [Connection].[dbo].[raw]
SET [mongol] = dbo.convert_lat(mongol)
WHERE [mongol] LIKE N'ф%';
After I execute the UPDATE statement, characters that supposed to be replaced are not replaced but whole row becomes null.