stored-procedures

How to pass NULL to a optional parameter and it not be interpreted as a missing parameter

邮差的信 提交于 2021-01-07 02:46:30
问题 I have a SQL Server stored procedure that updates a large table. Because of its size, most parameters are optional. Most recommendations for setting the default of my optional parameters is to set them to NULL. However, my problem is that NULL is a legitimate update parameter value so I'm trying to figure out how to handle detect the difference between a NULL that is passed vs. a NULL that exists due to a missing optional parameter. One solution I've seen is to set the optional parameter's

Debugging BigQuery Stored procedure

梦想与她 提交于 2021-01-04 05:54:09
问题 Is there any way I can use print statements within BigQuery stored procedure? I have a stored procedure like below, I like to see how SQL statement is generated to debug the issue or any other better way to debug what stored procedure is producing etc. CREATE OR REPLACE PROCEDURE `myproject.TEST.check_duplicated_prc`(project_name STRING, data_set_name STRING, table_name STRING, date_id DATE) BEGIN DECLARE sql STRING; set sql ='Select date,col1,col2,col3,count(1) from `'||project_name||'.'|

In a Snowflake stored procedures, is there a way to check how many columns are in a resultSet?

筅森魡賤 提交于 2021-01-04 03:16:52
问题 I am working with stored procedures in Snowflake. I want to know how to safely check that there are columns in a resultSet before running getColumnValue() which errors if I try to call it on a non-existent column. If I run this var query = `SELECT * FROM somewhere` var result = snowflake.execute({sqlText: query}); var count = result.getColumnCount(); I get an error saying that getColumnCount is not a function. If I run var query = `SELECT * FROM somewhere` var result = snowflake.execute(

In a Snowflake stored procedures, is there a way to check how many columns are in a resultSet?

。_饼干妹妹 提交于 2021-01-04 03:16:38
问题 I am working with stored procedures in Snowflake. I want to know how to safely check that there are columns in a resultSet before running getColumnValue() which errors if I try to call it on a non-existent column. If I run this var query = `SELECT * FROM somewhere` var result = snowflake.execute({sqlText: query}); var count = result.getColumnCount(); I get an error saying that getColumnCount is not a function. If I run var query = `SELECT * FROM somewhere` var result = snowflake.execute(

In a Snowflake stored procedures, is there a way to check how many columns are in a resultSet?

回眸只為那壹抹淺笑 提交于 2021-01-04 03:13:50
问题 I am working with stored procedures in Snowflake. I want to know how to safely check that there are columns in a resultSet before running getColumnValue() which errors if I try to call it on a non-existent column. If I run this var query = `SELECT * FROM somewhere` var result = snowflake.execute({sqlText: query}); var count = result.getColumnCount(); I get an error saying that getColumnCount is not a function. If I run var query = `SELECT * FROM somewhere` var result = snowflake.execute(

Using OFFSET-FETCH, how to default number of rows to “all rows”?

一个人想着一个人 提交于 2021-01-02 08:16:33
问题 Envision a stored procedure which takes @skip (offset) and @take (maximum number of rows to return. If @take is null , then I want to return "all rows after applying the offset". I can accomplish this by counting the number of rows in the table/view if @take is null , but then I have to perform two queries which is, of course, not optimal. I was hoping there was an option similar to FETCH [NEXT] ALL ROWS . DECLARE @skip BIGINT = 0; DECLARE @take BIGINT = NULL; IF (@take IS NULL) SET @take =

Create a Stored Procedure for AES Encryption in MS SQL Server 2008

送分小仙女□ 提交于 2020-12-29 08:44:23
问题 I have an SQL Server 2008 table with a structure similar to the following: ID int PRIMARY KEY IDENTITY(1,1) Name nvarchar(100) LongText ntext What I am trying to achieve is simple. Before inserting data inside this table, I want to encrypt the LongText using AES_192 algorithm. I am using the following SP to encrypt data: create proc sp_Encrypt_LongText @rawText ntext = null, @encryptedText nvarchar(max) output as begin OPEN SYMMETRIC KEY Encryption_Symmetric_Key DECRYPTION BY CERTIFICATE

Create a Stored Procedure for AES Encryption in MS SQL Server 2008

ⅰ亾dé卋堺 提交于 2020-12-29 08:44:16
问题 I have an SQL Server 2008 table with a structure similar to the following: ID int PRIMARY KEY IDENTITY(1,1) Name nvarchar(100) LongText ntext What I am trying to achieve is simple. Before inserting data inside this table, I want to encrypt the LongText using AES_192 algorithm. I am using the following SP to encrypt data: create proc sp_Encrypt_LongText @rawText ntext = null, @encryptedText nvarchar(max) output as begin OPEN SYMMETRIC KEY Encryption_Symmetric_Key DECRYPTION BY CERTIFICATE

How to grant a user access to all stored procedures on mysql?

白昼怎懂夜的黑 提交于 2020-12-26 06:22:24
问题 I'm trying the following: DROP USER IF EXISTS 'my_user'@'%'; CREATE USER 'my_user'@'%' IDENTIFIED BY 'my_pwd'; GRANT EXECUTE ON PROCEDURE mydb.* TO 'my_user'@'%'; but I get the error: Illegal GRANT/REVOKE command; please consult the manual to see which privileges can be used 0.000 sec If I name a proc explicitly: DROP USER IF EXISTS 'my_user'@'%'; CREATE USER 'my_user'@'%' IDENTIFIED BY 'my_pwd'; GRANT EXECUTE ON PROCEDURE mydb.my_proc TO 'my_user'@'%'; then it works fine, but I want to allow

Azure Data Factory Get Metadata to get blob filenames and transfer them to Azure SQL database table

心不动则不痛 提交于 2020-12-15 08:34:51
问题 I am trying to use Get Metadata activity in Azure Data Factory in order to get blob filenames and copy them to Azure SQL database table. I follow this tutorial: https://www.mssqltips.com/sqlservertip/6246/azure-data-factory-get-metadata-example/ Here is my pipeline, Copy Data > Source is the source destination of the blob files in my Blob storage. I need to specify my source file as binary because they are *.jpeg files. For my Copy Data > Sink, its the Azure SQL database, I enable the option