I am trying to apply some logic to my select by creating the following function:
ALTER FUNCTION [dbo].[SelectemnExportObject]
(@TITLE NVARCHAR(MAX))
RETURNS NVARCHAR(20)
AS
BEGIN
DECLARE @Str NVARCHAR(MAX) = ''
DECLARE @Definition1 VARCHAR(MAX) = (SELECT DEFINITION1
FROM [dbo].test
WHERE title = @Title)
DECLARE @Definition2 VARCHAR(MAX) = (SELECT DEFINITION2
FROM [dbo].test
WHERE title = @Title)
DECLARE @Definition3 VARCHAR(MAX) = (SELECT DEFINITION3
FROM [dbo].test
WHERE title = @Title)
IF @Definition1 <> ''
SET @str = @Definition1
ELSE IF @Definition2 <> ''
SET @str = @str + '<br />' + @Definition2
ELSE IF @Definition3 <> ''
SET @str = @str + '<br />' + @Definition3
RETURN @Str
END
Am I correct in saying, to call this function is as such?
select *
from [dbo].[SelectemnExportObject]('absconding')
I am trying to create a row of information, cell 1 will contain @str, then will create another called @str2 and so on ..
Will I need to return something else if I want to accomplish this?
I appreciate the help, and apologies in advance if the tagging isn't correct
SELECTclause, notFROMclause.