SQL Scripts are lists of SQL sentences written in a single file, meant to be executed sequentially. Depending on the particular RDBMS system, SQL scripts can have procedural language characteristics, such as control-of-flow constructs.
Questions tagged [sql-scripts]
437 questions
0
votes
1 answer
Oracle SQL script - Package created with compilation errors
Can anyone tell me what about these two scripts is causing "created with compilation errors." warnings? We're using Oracle db 19c. Do the "COMMIT;" statements matter one way or the other? I thought they were only needed for like create, update,…

public_void_kee
- 65
- 6
0
votes
1 answer
Oracle sql script with parameters - difference between # and $
I have the following CREATE TABLE ${schema_name}.TABLE and CREATE TABLE #[schema_name].TABLE.
I have some migrations to do with Flyway and the ones with # do not work.
What is the difference between these two? (given that the ones with # are from…

maria_so
- 13
- 5
0
votes
0 answers
Problem get Script from Database with .net Core 7
I want to get a script from my database, but it gives the following error:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
Microsoft.SqlServer.Management.Smo.TableCollection.this[string].get
returned…

Mohammad Hasan Salmanian
- 197
- 4
- 20
0
votes
1 answer
SQL Injection Detected By Firewall For SQL Code Submitted As Text For Storage
I have a head-scratcher here. Over a year ago, I wrote a website feature/form where I could submit SQL Code that is not executed but stored in a table. This feature worked when I created it, as I was able to upload several scripts into the database.…

TekkGuy
- 107
- 2
- 15
0
votes
1 answer
Creating ISNUMBER function in Snowflake
ISNUMBER is not a in-built function in Snowflake.
I want to create ISNUMBER function in Snowflake as an user-defined function.
Below is the user-defined function of ISNUMBER in oracle:
CREATE OR REPLACE FUNCTION is_number (p_string IN VARCHAR2)
…

Noob
- 1
0
votes
0 answers
How to assign array to JSONB variable in postgres script
I want to adjust a JSONB column by adding a new array prop in an existing record, but I struggle with getting this updated record.
Something like this:
DO $$
DECLARE
mt table1%ROWTYPE;
arr TEXT[];
BEGIN
FOR mt IN
SELECT * FROM…

Aleks
- 5,674
- 1
- 28
- 54
0
votes
2 answers
How to set in SQL a Flag based on days range
Sample table (customer) have the following data,
RecID
createdDate
UserID
ROWNUMBER
toCount
1
10-25-2022
User01
1
true
2
10-14-2022
User01
2
true
3
01-25-2020
User01
3
true
4
10-19-2022
User02
1
true
As per below query, will get…

KING
- 3
- 2
0
votes
2 answers
EF migration, reading and executing SQL from external file, quote problem
I wanted to use Entity Framework migrations in my .NET 6 application for creating and altering views. I found a relevant article covering this for stored procedures at https://dotnetthoughts.net/creating-stored-procs-in-efcore-migrations/. Following…

Green Grasso Holm
- 468
- 1
- 4
- 18
0
votes
0 answers
Calling a function with arguments using a variable in Microsoft T-SQL script is not working
DECLARE @P1Value varchar(1000) = '2022,2021,2023';
DECLARE @P1valuesrplc nvarchar(1000) = CONCAT('replace(''', @P1Value, ''','','','''''','''''')');
EXEC (@P1valuesrplc)
I get this error when calling EXEC:
Parse error at line: 1, column: 9:…

TomG
- 281
- 1
- 2
- 20
0
votes
1 answer
Migrating Data table values to Another Database Table using Script
I'm building a new system for a company.
They already have a system and the database is SQL Server.
Because of the issues I currently have in the existing system, I'm developing a new web-based application. Here in the new database, I have slightly…

Dev Beginner
- 589
- 1
- 11
0
votes
0 answers
EF Core 6 code first: Add triggers to new database?
I need to add sql scripts to a new database created with code first approach. I couldn't find anything about that when googling for it. How is it done please?
Background:
I need to add triggers to the database that need to run everytime certain…

Razzupaltuff
- 2,250
- 2
- 21
- 37
0
votes
1 answer
sql query to show all rows where a group of a field has the same value for all rows in another field
I have a table where i have two columns in the below fashion
sale_id status
268 5
268 1
268 1
268 1
283 5
283 5
283 5
284 5
284 1
284 1
284 1
284 1
284 1
284 1
As you can see, we have sale_id and status field. I need to write an SQL query where I…

Arif
- 377
- 2
- 5
- 21
0
votes
0 answers
Is there anyway to naming result query SQL scripts in Azure Synapse Analytics
My team wants to name each query result in SQL scripts instead of query0,query1,...
Does anyone know how to do that?
Thank you in advance.
Image

Do Chi Bao
- 13
- 2
0
votes
1 answer
Executing parameterized .sql commands
We have an SQL script in a .sql file. It has a couple of parameters defined like this
DECLARE @device_directory NVARCHAR(250) = '$(CONFIG_DBPATH)'+'$(CONFIG_DBNAME)'
We then execute this script in a .bat script:
SET CONFIG_DBNAME=NewConfigBase
SET…

havardhu
- 3,576
- 2
- 30
- 42
0
votes
0 answers
How to increase SQL parser speed that using TSqlParser?
In my code, I have several SQL scripts that I want to parse using TSql130Parser in order to refactor them. But this process takes a long time - is there a way to increase the speed of this?
Also I have another question that TSql130Parser can get…

Maryam
- 53
- 8