If you want to execute several SQL-functions successively and a result is not expected, you can use #sql. Example: depending on the variable „lb_simple“ a function with different variants is created.
setvar=lb_simple=false
[sql]
IF OBJECT_ID ( 'dbo.beas_myfuction', 'FN' ) IS NOT NULL DROP function dbo.beas_myfunction;
#end
if <lb_simple> = true then
#sql
create function dbo.beas_myfunction
return datetime
with execute as caller
as
begin
declare @ldt_date datetime;
set @ldt_date=GETDATE();
return (@ldt_date)end
[/sql]
else
[sql]
create function dbo.beas_myfunction
return datetime
with execute as caller
as
begin
declare @ldt_date datetime;
declare @ll_offset int;
select top 1 @ll_offset =offset from OTIZ order by ID desc;
set @ll_offset = ISNULL(@ll_offset,0) * 60
set @ldt_date=dateadd(ss,@ll_offset,GETUTCDATE());
return (@ldt_date)end
[/sql]
end if
OR
you can define this area with
#sql
...
#end
for single-SQL-Statement use sql
If you've more then one result-line,then work with datastorevalues