diff --git a/ui/src/views/sqlQueryManager/SqlQueryManager.tsx b/ui/src/views/sqlQueryManager/SqlQueryManager.tsx index ca2614cb..961835d4 100644 --- a/ui/src/views/sqlQueryManager/SqlQueryManager.tsx +++ b/ui/src/views/sqlQueryManager/SqlQueryManager.tsx @@ -212,8 +212,8 @@ WHERE t1.IsActive = 1; GO`, - 'create-function': `-- Create Scalar Function -CREATE FUNCTION [dbo].[FunctionName] + 'create-scalar-function': `-- Create Scalar Function +CREATE FUNCTION [dbo].[ScalarFunctionName] ( @Parameter1 INT, @Parameter2 NVARCHAR(100) @@ -230,6 +230,30 @@ BEGIN RETURN @Result; END +GO`, + + 'create-table-function': `-- Create Table-Valued Function +CREATE FUNCTION [dbo].[TableFunctionName] +( + @Parameter1 INT, + @Parameter2 NVARCHAR(100) +) +RETURNS TABLE +AS +RETURN +( + SELECT + t.Column1, + t.Column2, + t.Column3, + t.Column4 + FROM + TableName t + WHERE + t.Id = @Parameter1 + AND t.Column2 LIKE '%' + @Parameter2 + '%' + AND t.IsActive = 1 +) GO` } diff --git a/ui/src/views/sqlQueryManager/components/SqlObjectExplorer.tsx b/ui/src/views/sqlQueryManager/components/SqlObjectExplorer.tsx index 63d24c4d..a8fc7460 100644 --- a/ui/src/views/sqlQueryManager/components/SqlObjectExplorer.tsx +++ b/ui/src/views/sqlQueryManager/components/SqlObjectExplorer.tsx @@ -155,10 +155,16 @@ const SqlObjectExplorer = ({ data: { templateType: 'create-view' } as any, }, { - id: 'template-function', - label: 'Function', + id: 'template-scalar-function', + label: 'Scalar Function', type: 'object' as const, - data: { templateType: 'create-function' } as any, + data: { templateType: 'create-scalar-function' } as any, + }, + { + id: 'template-table-function', + label: 'Table-Valued Function', + type: 'object' as const, + data: { templateType: 'create-table-function' } as any, }, ], },