About 279,000 results
Open links in new tab
  1. How can I filter words in SQL using a function?

    SQL Create Function. 0. Create a user defined function? 0. SQL Server Using Function. 1. Need to create ...

  2. sql - MySQL CREATE FUNCTION Syntax - Stack Overflow

    Jul 19, 2011 · I am trying to create a function in MySQL: Here is the SQL code: CREATE FUNCTION F_Dist3D (x1 decimal, y1 decimal) RETURNS decimal DETERMINISTIC BEGIN DECLARE dist decimal; SET dist = SQRT(x1 - y1); RETURN …

  3. sql - Can I create a One-Time-Use Function in a Script or Stored ...

    May 26, 2017 · The best you can do is something like this, with dynamic SQL: create proc DoStuff as begin declare @sql nvarchar(max) /* define function here, within a string note the underscore prefix, a good convention for user-defined temporary objects */ set @sql = ' create function dbo._object_name_twopart (@object_id int) returns nvarchar(517) as begin ...

  4. Create sql server functions from an assembly dll automatically

    May 16, 2012 · I have several functions in an assembly dll named UserFunctions.dll, for example :. public static partial class VariousFunctions { [SqlFunction(IsDeterministic = true, IsPrecise = true)] public static SqlBoolean RegexMatch(SqlString expression, SqlString pattern) { ...

  5. Define a function and use it in a SQL-Query - Stack Overflow

    Sep 6, 2017 · Yes, SQL functions are easy to create. But you have to understand the 3 different types of functions in SQL: 1) Scalar functions:-- return a single value. 2) Table based functions:-- returns a Table. 3) Aggregate function: returns a single value (but the function looped through a window set). creating a function in MS SQL Server 2012 by using ...

  6. sql - Create a function in PostgreSQL - Stack Overflow

    Oct 11, 2021 · You can create a function in PL/pgSQL or SQL language. For example, you create test table as shown below: CREATE TABLE test ( num INTEGER ); Then, you insert the row whose num is 2 as shown below: INSERT INTO test (num) VALUES (2); Now, you can create my_func() PL/pgSQL function which adds value to num and …

  7. Passing multiple values to a parameter of a function in SQL

    Nov 3, 2015 · I just ran into this, and I used the CROSS APPLY solution from this post: SQL Server: run function for each row based on the provided row value. To use CROSS APPLY, you would need to first select your values, and then CROSS APPLY. I have not used the split function before, so I don't have the exact syntax, but if you use it something like:

  8. How can I create a SQL function with a parameter?

    Nov 18, 2015 · CREATE OR REPLACE FUNCTION get_conc_names( p_event_id IN dt_event_service.event_id%type ) RETURN VARCHAR2 IS l_conc_names VARCHAR2(32676); -- You may want a smaller variable if you know the result will be smaller BEGIN SELECT LTRIM(SYS_CONNECT_BY_PATH(name, ', '),',') conc_names INTO l_conc_names FROM ( SELECT id, name, ROW_NUMBER() OVER (order ...

  9. SQL Server: CREATE FUNCTION with declare variables inside

    Jun 21, 2017 · I would like to create a function in SQL Server. In this function, I need to define some variables and then use it in the SELECT. SQL looks like below: CREATE FUNCTION [dbo].[MyFussnction] ( @path [nvarchar](10) ) RETURNS TABLE BEGIN DECLARE @xx varchar(50); SET @xx = 'Windows%'; RETURN SELECT * FROM MyTable WHERE DataPath LIKE @path AND XX ...

  10. sql server - Execute WITH statement inside a function - Stack …

    Oct 31, 2012 · You don't need the semicolon before the WITH in a TABLE-VALUED FUNCTION. Especially considering that you cannot even have multi-statements in a TVF, there's no reason for a statement delimiter to be present. The correct form is CREATE FUNCTION (...) RETURNS TABLE AS RETURN <statement>