Having some issue with my function call please. I have a situation that I am yet unable to figure out. I have a simple function call like so . . .
If(@confirm ='Y')
BEGIN
SELECT dbo.ReplaceString(@rawText, '2342345432', 'radefr', @User_no, @password,@email,' ',' ',GetDate() ,@company, @end, @start, @remove) as messagetext
END
I have been able to verify that the function works fine as all it does is simple string replace using the parameters passed in. The problem I am having is that when I plug the call in as above, I get a null value returned instead of the string passed in initially as expected. Barring any errors in the code, is there any other situation when a function would return unexpected result?
Function [dbo].[ReplaceString]
(
@rawtext As Varchar(400),
@numbernum As Varchar(15),
@name As Varchar(25),
@userno As Bigint,
@password As Varchar(50) ,
@email As Varchar(50) ,
@keyword As VARCHAR(40),
@litext As Varchar(500),
@datecreated As DateTime,
@company As Varchar(30),
@end As Varchar(140),
@start As Varchar(140),
@remove As Varchar(200)
)
RETURNS VARCHAR(450)
AS
BEGIN
SELECT @rawtext = Replace( @rawtext , ''@@name@@'', @ name)
SELECT @rawtext = Replace( @rawtext , ''@@number@@'', @numbernum)
SELECT @rawtext = Replace( @rawtext , ''@@company@@'', @company )
SELECT @rawtext = Replace( @rawtext , ''@@ssn@@'', @numbernum )
SELECT @rawtext = Replace( @rawtext , ''@@message@@'', @littext )
SELECT @rawtext = Replace( @rawtext , ''@@date@@'', CAST(@datecreated AS VARCHAR(10)) )
SELECT @rawtext = Replace( @rawtext , ''@@keyword@@'', @ keyword )
SELECT @message_text = Replace(@littext, @ keyword, '''' )
SELECT @rawtext = Replace( @rawtext , ''@@withoutkeyword@@'', @littext)
SELECT @remove= Replace(@remove ''@@company@@'', @company)
SELECT @start= Replace(@start, ''@@company@@'', @company)
SELECT @end = Replace(@end, ''@@company@@'', @company )
SELECT @rawtext = Replace( @rawtext , ''@@Settings[END]@@'',@end )
SELECT @rawtext = Replace( @rawtext , ''@@Settings[START]@@'', @start )
SELECT @rawtext = Replace( @rawtext , ''@@Settings[REMOVE]@@'', @remove)
RETURN(@rawtext )