Skip to main content
Filter by
Sorted by
Tagged with
Advice
0 votes
5 replies
73 views

I'm working in Teradata SQL Assistant and I need to create a stored procedure that, given a table name, returns the percentage of NULL values for each column in that table. Right now, I generate the ...
danny's user avatar
  • 67
1 vote
1 answer
87 views

I have a stored procedure that we are scanning using some AI tools to look for vulnerabilities. I am doing a dynamic SQL statement with an order by clause and that parameter for that order by I am ...
Morgeth888's user avatar
3 votes
1 answer
71 views

I am trying to do some transaction management in calls invoked by dynamic sql (EXECUTE). The following works: CREATE or replace PROCEDURE transaction_test1() LANGUAGE plpgsql AS $$ DECLARE r RECORD; ...
Peter Rilling's user avatar
1 vote
1 answer
91 views

I need this working query as a stored procedure where I can give two databases (one masterdb one testdb), start chainage, end chainage and UniqueRun as input DECLARE @StartChainage FLOAT = 17.00; ...
anonymous123's user avatar
0 votes
1 answer
102 views

I need to replace a certain character inside a field with an empty string. But this simple need becomes complicated because I need to extract data from a remote Oracle server and I need a parameter to ...
tpol's user avatar
  • 195
0 votes
1 answer
96 views

I am trying to build queries to take data from table_1: id path curr_value 1 name Company ABC 2 address 123 Main St 3 name Company 123 And use it as the value AND column header for table_2 in SQL. ...
granger's user avatar
  • 85
-2 votes
1 answer
123 views

I’m trying to write a script to purge all the tables (and views and functions and procedures) from the current dbo schema in the current database. Bolting together what I have learned from other ...
Manngo's user avatar
  • 17k
0 votes
1 answer
198 views

Reason for change I have a main Staging server with multiple linked server's setup. Each one of these Linked Servers have their own DB on the main Staging Server. I have an SP that extracts data from ...
Enzo's user avatar
  • 3
2 votes
2 answers
117 views

I have a UserDAO class where I need to retrieve users based on different search criteria. Initially, I overloaded the method like this: public User getUserByUsername(String username) throws ...
Nhat Nguyen's user avatar
0 votes
1 answer
57 views

I want to include a drop everything section in a script which (re)generates a sample database. I know I can find a list of views in the current schema and generate the DROP VIEW statements this way: ...
Manngo's user avatar
  • 17k
0 votes
0 answers
94 views

I have a comma-separated list of file names, and I want to create multiple text files in MySQL. Each file should contain some static text. For example, if my input is: 'file1,file2,file3,file4' I ...
rMafia's user avatar
  • 85
0 votes
1 answer
91 views

I have a situation where I am trying to create a query using Dynamic SQL in SSMS where I am trying to generate a complete file path by concatenating both the name of a parent folder(s) (which change ...
WJTownsend's user avatar
-2 votes
2 answers
63 views

I am getting incorrect syntax error at 'and Type=0 in the below dynamic sql. What I am trying to achieve is get the volume count of import activities between certain dates where the import id does not ...
Jatin's user avatar
  • 45
1 vote
4 answers
226 views

In PostgreSQL, I am trying to have SQL which orders by multiple columns. The first column will always be priority DESC NULLS LAST. The second one needs to be dynamic based on some conditions (for ease ...
sudoExclamationExclamation's user avatar
2 votes
1 answer
106 views

I get this on Oracle 11g and 19c. Below is a simplified example of the code I am using to process some queries dynamically. It needs to be DBMS_SQL because the actual use case will have various ...
Pro West's user avatar
  • 419
0 votes
2 answers
60 views

I'm trying to make a CRUD application that uses Oracle procedures for the operations. For the READ component, I wrote a procedure that returns one or more entire rows depending on the specified ...
sodaCodes's user avatar
1 vote
2 answers
110 views

I have a table in SQL Server that has rows as follows: ID (int) Name (varchar) IsEnabled (int) ObjectName (varchar) PropertyName (varchar) PropertyValueString (varchar) PropertyValueInt 1 Rule01 1 ...
SoftwareDveloper's user avatar
0 votes
1 answer
90 views

The title is indeed strange, but I will try to explain. I have been programming Oracle (PL-SQL) in version 11G for several years. I recently moved to a new workplace, and in the first task I was ...
StevenU's user avatar
  • 39
1 vote
1 answer
107 views

I'm looping through table1: create table table1(id,"date",quantity,"value")as values (1,'2024-10-01',1,1) ,(2,'2024-10-02',1,1) ,(3,'2024-10-03',1,1) ,(4,'2024-10-04',1,1) ,(5,'...
douglas_forsell's user avatar
0 votes
2 answers
158 views

I'm new to Postgres and trying to create code that inserts data from several tables into a single table. All source tables have a name starting with "B3_HIST_", differing only in terms of ...
Delta Soares's user avatar
0 votes
1 answer
93 views

I have a table Customers with multiple columns one of which is state. I want a dynamic query : When my stateInput is empty I want all customers, if not I want customers that have the state given in my ...
Rancha124's user avatar
1 vote
1 answer
112 views

I am working with code inside of a PostgreSQL pgsql function. I have a merge statement that has multiple elements that are only known at runtime and are supplied to the function as parameters, which ...
MRodriguez's user avatar
0 votes
0 answers
73 views

I have the following query in MySQL 8.0: set @userid = 'XXX'; set @lastdate = '2024-09-30'; SET @sql = null; SELECT GROUP_CONCAT( DISTINCT CONCAT( 'Count(CASE WHEN Checkedby = '''...
TemNyilv's user avatar
1 vote
1 answer
96 views

In my Oracle 19c-database, I would like to make 1 trigger per table where the jornalling is handled for insert, update and delete. I would like that every trigger is the same for each table, with the ...
Allard's user avatar
  • 11
0 votes
1 answer
84 views

I created the following dynamic SQL: DECLARE @DATE nvarchar(4) = '0824'; DECLARE @LocalID INT; SET @sql = N'SELECT Col1, Col2, Col3, Col4, '; SET @sql = @sql + N'@LocalID = Col5 FROM Table WHERE ...
Stephen's user avatar
2 votes
2 answers
698 views

Suppose I have the following macro: CREATE OR REPLACE MACRO hello_world(col_name, series_start, series_end) AS TABLE ( SELECT generate_series::VARCHAR AS col_name FROM generate_series(...
bzm3r's user avatar
  • 4,684
1 vote
1 answer
158 views

I have a list of column names, for example ('Name', 'Code', 'Title') that can be array but not necessarily, it can be anything. I just have a list of column names. Then I have to create a dynamic SQL ...
Biljana M.'s user avatar
0 votes
1 answer
85 views

I try to create/alter the same view in a list of databases. Let's call them A, B, C. The best would be to create/alter them all at once so I'm looking into a stored procedure to create the view: ...
Hestaron's user avatar
  • 302
0 votes
1 answer
374 views

Need help to call variable inside snowflake stored procedure. It throws a "Missing column specification" - how to access variable allcols inside dynamic SQL in snowflake? CREATE OR REPLACE ...
gayathri's user avatar
0 votes
1 answer
80 views

I am attempting to use a WHILE loop with dynamic SQL. See code below. I have a table [Users] that set out various conditions required to update fields in [DB1] with a Status Code. The code runs, ...
SarahChapman's user avatar
1 vote
1 answer
75 views

How do I turn the query below into a temporary view? Everything I've tried returns the text of the generated query (second quoted code block). "Everything" includes... Wrapping the 1st ...
Randall's user avatar
  • 3,064
0 votes
1 answer
124 views

I want to write a SQL Server stored procedure that contains the following: Imagine a query like this: SELECT VARNAME, TYPE, VARVALUE, LEN(CAST(VARVALUE AS VARCHAR(5))) + 1 AS LENGTH FROM SOMETABLE; ...
mightycpa's user avatar
  • 155
1 vote
1 answer
280 views

I'm working on a SQL query where the filters can be dynamic, and I'm concerned about its efficiency. My current approach is as follows: SELECT * FROM table t WHERE (:param1 IS NULL OR t.example = :...
dssof's user avatar
  • 317
0 votes
2 answers
335 views

I am trying to tweak my stored procedure in Snowflake so that I can loop through all external stages (in S3) from my schema manual_adjustments and not have to call this other procedure CHECK_LOAD() ...
Estrobelai's user avatar
-1 votes
1 answer
103 views

User.java // User.java public class User { private int userId; private String userName; private String userEmail; private String userPassword; // getters and setters } Post.java //...
Mohan mohan's user avatar
0 votes
0 answers
92 views

I've developed a stored procedure that utilizes dynamic SQL to search for specific entities (this is a procedure for catch all logic). Is this procedure prone to SQL injection, and how do I get the ...
lifeisajourney's user avatar
0 votes
1 answer
113 views

Long and short is that my query is taking FOREVER to run and I think it has to do with the sp_executesql queries. Yes, there are loops, and yes I am using Dynamic SQL. I use loops enough to know ...
Dizzy49's user avatar
  • 1,550
0 votes
1 answer
95 views

The code with sp_executesql is in a loop (two actually), that goes through the list of IDs in the [tmp_compare], and compares the data in each of the columns in the [contact_compare_fields] from two ...
Dizzy49's user avatar
  • 1,550
4 votes
3 answers
433 views

In the case that I have the same example data as in this question and additionally declare the following two functions: CREATE OR REPLACE FUNCTION example.markout_666_example_666_price_table_666_price(...
Stuart's user avatar
  • 1,502
0 votes
1 answer
35 views

I have a function with a dynamic copy statement and when I try to SELECT function, I get the error "query has no destination for result data" select loadTodaysData(); CREATE FUNCTION ...
Yuju Takahashi's user avatar
-1 votes
1 answer
630 views

I need variable in parametrized view. CREATE VIEW my_new_view AS SELECT CampaignName, sentiment, -- **CASE WHEN variable** = sentiment THEN sentiment ELSE NULL END AS sentiment_match COUNT(CASE ...
dundi rajesh's user avatar
0 votes
1 answer
152 views

I have (24.1.4.20) view in clickhouse and want change order by columns inside over() of row_number(). create or replace view data.v1 as select row_number() over(order by COLUMNS({p_order_by:String})) ...
Aleksey N Yakushev's user avatar
0 votes
0 answers
49 views

I have the following query in SQL Server, I am trying to create variables dynamically DECLARE @TESTEO NVARCHAR(max) SET @TESTEO = ' DECLARE @SEG1HEM NVARCHAR(max) SET @SEG1HEM = (SELECT ...
Sebastian Galeano's user avatar
-1 votes
3 answers
615 views

Note: My intention with this question was to learn about approaches other than mine, to execute multiple CREATE TRIGGER statements in a single string. Not "solving" this, by executing one by ...
FcoJavier99's user avatar
1 vote
1 answer
99 views

I would like to query a table which has few columns (such as 4 below) from where i would like to create a snapshot table which can provide insight on the attribute count everyday userId attr1 attr2 ...
TechDan's user avatar
  • 47
-1 votes
1 answer
252 views

Below I have my current code. What I am trying to do in this code: The #BySite table has a list of records where all the columns listed before the PlayMonth column are a snap shot at the end of every ...
Chad Portman's user avatar
  • 1,232
1 vote
1 answer
368 views

I have a execute block inside a stored procedure and I am executing a query dynamically: execute 'create table raw_mine.financial_multicase_xwalk_' || target_date || ' as select distinct a....
Rikesh Kayastha's user avatar
0 votes
1 answer
393 views

I'm working with jOOQ and want to construct a dynamic CASE WHEN expression using the DSL. The desired outcome is a structure like this: var myCase = DSL.case_() .when(condition1, result1) .when(...
Guillaume F.'s user avatar
  • 6,533
0 votes
0 answers
52 views

My query is like this: unload('select * from table') to 's3://path' credentials '*******' header parallel off delimiter as '\307' The delimiter is Cedilla Ç. and I have to unload it like this '\307'. ...
Rikky Bhai's user avatar
  • 1,018
1 vote
1 answer
130 views

I have a large dataset with many different product. In a small scale it would look like this: product month amount AA 1 100 AA 1 150 AA 2 200 AA 2 120 BB 2 180 BB 2 220 CC 3 80 I want get the info in ...
Francisco MS's user avatar

1
2 3 4 5
55