I am trying to convert our legacy functions into standard SQL and so by using UDFs as a gig to reuse the old function names with the native functions. Here I have my UDF to_char and inside use the parameters to run FORMAT_DATE but when I execute it even though a routine is created I get errors with no additional
Tag: user-defined-functions
Snowflake unable to display / interpret unicode ‘u0089’
I am trying to show Unicode character ‘u0089’ in the snowflake browser results, however it seems to be showing a default error value instead. I’m lost as to how to fix this issue The data is being ingested from a source JSON doc which states the field to be As you can see, “Units”: “u0089” is not displaying correctly as
SQL Exit scalar function prematurely
In SQL, you can exit the stored procedure prematurely with RETURN statement. However, when I try to apply the same principle to the scalar function, it returns the error, since function needs to return something. How do I prematurely exit the scalar function the same way RETURN is used in the stored procedure? Thank you. Answer You can’t RAISERROR or
Table, Row valued UDFs in SQL Server
SQL Server (and some other databases) support a Table-value function. Is there a such thing as a Row-valued function — where based on a set of input values, a specific row would be returned, or is that type of function type not supported. If not, why isn’t it supported? The example SQL Server gives is: So a Row valued function
Filtering rows in pyspark dataframe and creating a new column that contains the result
so I am trying to identify the crime that happens within the SF downtown boundary on Sunday. My idea was to first write a UDF to label if each crime is in the area I identify as the downtown area, if …
Loop through a table valued function
I have a table x which has columns y and z it has 10 rows of data. I then have a table-valued function getDetails(y,z) which takes values stored in table x in columns y and z to return a table tb with three columns. I need to write a tsql query that loops values from table x through function getDetails(y,z)to
How to find ASCII of every character in string using DB2 Function?
I have written a function in DB2 – that is calculating ASCII of records in a particular column. I want to some help as I want to check the ASCII of every single character in string return yes if the …
What is the simplest way to put pass an array of values into a parameter of TVF
Objective: I would like to have a parameter in my function to allow the user to input a list of values. Ideally, the simplest solution … Note: I dont have permissions to create tables in dbs. …
How to avoid multiple function evals with the (func()).* syntax in a query?
Context When a function returns a TABLE or a SETOF composite-type, like this one: the results can be accessed by various methods: select * from func(3) will produce these output columns : select func(3) will produce only one output column of ROW type. select (func(3)).* will produce like #1: When the function argument comes from a table or a subquery,
How to determine the number of days in a month in SQL Server?
I need to determine the number of days in a month for a given date in SQL Server. Is there a built-in function? If not, what should I use as the user-defined function?