Dynamic SQL is a technique using SQL (Structured Query Language) whose main difference from traditional SQL is that Dynamic SQL allows to build SQL statements dynamically at runtime, which eases the automatic generation and execution of program statements.
Questions tagged [dynamic-sql]
2681 questions
0
votes
1 answer
Like in dynamic function
The code below works well. I however have issues trying to turn it into a like statement that I need some assistance with
CREATE PROCEDURE [dbo].[searcher]
@deliverer nvarchar (100)
AS
BEGIN
DECLARE @sql nvarchar(1000)
SET @sql =…

Kamikaze K
- 181
- 1
- 11
0
votes
1 answer
How to Call a Pkg/Procedure Executing an API From a Pkg/Procedure. The API name needs to be Dynamic and Has In and Out Parms
We use APIs, baninst1.PP_DEDUCTION.p_update and baninst1.PP_DEDUCTION.p_create, to maintain our payroll tables of benefit/deduction data. Numerous packages utilize the APIs. We would like to create a package containing the API call that all the…

Marcha
- 1
- 1
0
votes
2 answers
PL/SQL Developer - Creating dynamic SQL
I'm using PL/SQL Developer. I'm trying to get query results to excel via vba. Since query is so long, i decided to create table with the query results and then simply get the table results with vba. In order to create table via excel i needed to…

fatih arslan
- 85
- 8
0
votes
1 answer
Stored procedure in pgsql to create materialized views
I'm trying to create a stored procedure in pgsql that creates a materialized view with data from a specific year from a table. The parameters will be the table name, the column that contains the year, and the year.
I know that in SQL Server it would…

Eulidio
- 5
- 1
0
votes
1 answer
Cannot get output variable from stored procedure when procedure written in dynamic sql
I am writing a procedure to produce an int output variable, but I'm not sure how to do this using dynamic sql. If I execute the below procedure I get the @AnlyNum value displayed in the results screen, but I just want @AnlyNum variable set with a…

CGarden
- 169
- 17
0
votes
0 answers
Find columns based on row data postgresql
I am interacting with a huge Postgres database that I am not familiar with. This database exposes large views with hundreds of columns each. I am supposed to get the column that contains a store ID, but I do not know the name of the column and it…

José Mancharo
- 175
- 1
- 14
0
votes
0 answers
SQL Server Dynamically Pivot on column with +100 different values
Here is a table that I have in SQL Server and here are the first three rows. I need to pivot on the node name column.
Here is the table I have
CREATE TABLE [dbo].[VanHalen99](
[FileName] [varchar](100) NULL,
[NodeName] [varchar](max) NULL,
…

TenkMan
- 27
- 4
0
votes
1 answer
How to show all tables in database dynamically?
I want to select all tables in my database
Using Dynamic-SQL:
DECLARE @sql nvarchar(max) = N'',
@base nvarchar(max) = N'select * from $x$;';
SELECT @sql += REPLACE(@base, N'$x$;', QUOTENAME(name)+';
')
FROM sys.all_objects where…

XMehdi01
- 5,538
- 2
- 10
- 34
0
votes
1 answer
How can I use if exists with execute?
I am unable to create this stored procedure due to syntax error. Is here any one can solve this syntax issue?
DROP PROCEDURE REMOTE_DB_CONNECTION_REMOVER;
CREATE PROCEDURE REMOTE_DB_CONNECTION_REMOVER(
rm_server_user varchar(100),
…

Sheikh Wasiu Al Hasib
- 450
- 5
- 18
0
votes
1 answer
How to parse XML file in a folder with dynamic t-sql?
I'd like to change this XML to SQL statement below to work with a path rather than a file name, at the moment it's looking for 'C:\Test\XML\PT38.xml'.
I need it to parse any .XML file in the folder rather than look for a specific one. It will be…

KnockOutMan2015
- 29
- 5
0
votes
2 answers
Regex to generate dynamic sql
I want to generate dynamic sql on Notepad++ based on some rules. These rules include everything, so no sql knowledge is needed, and are the following:
Dynamic sql must have each single quote escaped by another single quote ( 'hello' becomes…

George Menoutis
- 6,894
- 3
- 19
- 43
0
votes
3 answers
TSQL Passing MultiValued Reporting Services Parameter into Dynamic SQL
Duplicate of: TSQL varchar string manipulation
I'm building a dynamic SQL statement out of parameters from a reporting services report. Reporting services passes MutiValue Parameters in a basic CSV format. For example a list of states may be…

Jeff
- 8,020
- 34
- 99
- 157
0
votes
0 answers
Run SQL Dynamic using column value
I am using dynamic SQL.
I inserted a select statement into one row from #example, I want to call that select statement and run it with dynamic SQL, my select stored has a variable call @NumOrder
create table #example(id int, description…

Webb
- 167
- 4
- 15
0
votes
1 answer
SQL Pivot With n Columns into Single Row
I have XML files will engineering test data in them. There are n possible parameter definitions for any given XML file, but the parameter definitions are of a fixed construct.
1
…

mattr
- 3
- 4
0
votes
1 answer
Dynamically looping multiple tables to inner join clause
I am in a situation where I have to pull around 30 columns from 20 different tables. All the 20 tables can be joined with 2 key columns. I want to replace the static join statements with dynamic join statements.
I am able to pull all the 20 table…

0537
- 993
- 8
- 15
- 32