Create table words
(
Keyword varchar(50),
rsltword varchar(50)
)
insert into words(keyword,rsltword)
values('1+1','=2')
insert into words(keyword,rsltword)
values('3*3','=9')
insert into words(keyword,rsltword)
values('4/2','=2')
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[getword]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[getword]
go
CREATE FUNCTION getword (@seekword varchar(50)) RETURNS Varchar(50) AS
BEGIN
Declare @retword varchar(50)
If Exists(select rsltword from words where Keyword=@seekword) Begin
Select @Retword=rsltword from words where Keyword=@seekword
End Else Begin
Select @Retword='Hitta inget!!'
End
RETURN @Retword
END
select keyword+dbo.getword(keyword) from words