Hi, I am trying to create a function in the database by code.
For example..
create function dbo.myfunction(@i int)
returns int
as
begin
declare @r int
set @r = @i * 2
return @i
end
I get the message a RETURN statement with a return value cannot be used in this context. Must declare the scalar variable @id.
Incorrect syntax near the keyword 'function'.
This works from management studio but fails from tmsscript, tmsconnection
Problem creating a function by code
-
AndreyZ
Hello,
I have executed the following code:, and there were no problems. Please check if this code works for you. If it doesn't work, please try using the latest SDAC version 6.1.3 and check if the problem persists.
I have executed the following code:
Code: Select all
MSScript.SQL.Clear;
MSScript.SQL.Add('create function dbo.myfunction(@i int)');
MSScript.SQL.Add('returns int');
MSScript.SQL.Add('as');
MSScript.SQL.Add('begin');
MSScript.SQL.Add('declare @r int');
MSScript.SQL.Add('set @r = @i * 2');
MSScript.SQL.Add('return @i');
MSScript.SQL.Add('end');
MSScript.Execute;