Skip to main content
1 vote
1 answer
80 views

Is COL_LENGTH sufficient for parameter sanitation

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
63 views

"invalid transaction termination" when executing dynamic sql

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
86 views

How do I make this query as a dynamic stored procedure?

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
88 views

Replace a character with an empty string inside a dynamic SQL using OPENQUERY

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
92 views

How can I use data from 1 table and then INSERT into a second using data as a column header SQL?

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
119 views

Using sp_executesql drop multiple tables

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
  • 16.9k
0 votes
1 answer
150 views

Possible ways of updating the catalog of an already created Linked server

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
107 views

How to dynamically build a query based on variable number of fields, in Java with PreparedStatement?

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
44 views

Dropping all Views dynamically in Db2

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
  • 16.9k
0 votes
0 answers
84 views

How to create multiple files with different names and content using a comma-separated list without loops?

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
74 views

Providing string variable into Dynamic SQL SELECT statement WITHOUT it being read as a column name?

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
61 views

Dynamic sql to retrieve volume count throwing incorrect syntax error [closed]

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
182 views

Switch ASC / DESC in ORDER BY with a CASE construct?

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
103 views

Oracle DBMS_SQL giving ORA-1007 variable not in select list

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
0 answers
23 views

Dynamic SQL BCP on local desktop writes no file and generates no error

I have a script task in SSIS that executes Dynamic SQL and builds a BCP statement that is executed in the typical manor. But when editing in SSMS as a SQL script, I can execute it within SSMS and it ...
mf.cummings's user avatar

15 30 50 per page
1
2 3 4 5
183