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
5
votes
1 answer
JPA Entity Manager - How to run SQL script file?
I have an SQL script file which drops and recreates various tables as well as inserts various records into these tables. The script runs fine when executing in the SQL query console however I need it to be executed by the Entity Manager.
Any idea's…

Harvey Sembhi
- 287
- 1
- 5
- 13
5
votes
2 answers
Can Flyway execute SQL scripts that are not treated as migrations?
We would like to use Flyway for database migrations. In addition to our migration scripts, we have a need to execute some scripts that should not be treated as migrations (and do not need to be tracked in the schema_version table). An example would…

Tim Andersen
- 344
- 3
- 7
5
votes
4 answers
SQL Management Studio Express opening SQL scripts in Notepad
When I go to File > Open > File and select a .sql script, or even when I drag a .sql file into the SQL Management Studio Express window, it opens the script in Notepad which is totally useless when I want to run the script.
Since this is on an…

tags2k
- 82,117
- 31
- 79
- 106
4
votes
2 answers
Create SQL Server tables and stored procedures in one script?
I have a SQL script that is setting up two database tables with their keys and constraints without any problem. I won't include the whole code but the 'skeleton' of it looks like this:
BEGIN
CREATE TABLE [table] (
)
CREATE TABLE [table2]…

DevDave
- 6,700
- 12
- 65
- 99
4
votes
2 answers
Script all views/functions/procedures in a Sql Server database in dependency order
Sql Server 2008 (and probably most other versions): Management Studio has a 'generate scripts' option that can in theory script a whole database with all objects (Right click, tasks, Generate Scripts). It works OK for most things but when you use it…

codeulike
- 22,514
- 29
- 120
- 167
4
votes
3 answers
Spring Boot and Database Initialization not working properly
The scripts in schema.sql gets executes but scripts from data.sql are not executing,
not sure what I am missing?
I am using Spring Boot with two data source my data base configuration is as follows
@PropertySource({…

MasterCode
- 975
- 5
- 21
- 44
4
votes
1 answer
Generating scripts based on condition
The inserts of a certain table(s) can be generated by using SQL Server Management Studio by right clicking on the database -> tasks -> generate scripts, choosing the tables and finally selecting data only. However the table gets bigger with time and…

Andrius Naruševičius
- 8,348
- 7
- 49
- 78
4
votes
2 answers
How do I run multiple scripts one after another in Oracle?
I have the following script:
ALTER TABLE ODANBIRM
ADD (OBID NUMBER(10, 0) );
----------------------------------------------------------------------------
CREATE OR REPLACE TRIGGER TR_OB_INC
BEFORE INSERT ON ODANBIRM
FOR EACH ROW
BEGIN
SELECT…

Mikayil Abdullayev
- 12,117
- 26
- 122
- 206
3
votes
2 answers
Executing a SQL Query multiple times with different parameters
I have a SQL stored procedure that I need to execute several times with different parameters. Is it possible to execute a SQL-script of some kind that will execute multiple times with like an array or other data-structure of different parameters? …

SoftwareSavant
- 9,467
- 27
- 121
- 195
3
votes
2 answers
object_id() vs sys.objects
I use database scripts where I check for the existence of a Stored Procedure then drop it then create it.
Which of the following would be more efficient for checking and dropping SPs
Option 1
IF EXISTS(SELECT * FROM sys.objects WHERE OBJECT_ID =…

Binoj Antony
- 15,886
- 25
- 88
- 96
3
votes
3 answers
what is the correct syntax for executing .sql script in MySQL command line?
I am confused. From references I have seen online, the command to execute a text file script is this:
mysql> --user=root --password=admin --database=zero

Benny Tjia
- 4,853
- 10
- 39
- 48
3
votes
1 answer
BULK INSERT is replacing BLANK values with NULL
I have a huge CSV file with a lot of blank values like:
VALUE1,VALUE2,VALUE3,VALUE4,VALUE5,VALUE6,,VALUE8,VALUE9,VALUE10,,,
That I'm trying to import thru a PS Script. For that I'm using the following powershell script
$Server =…

Guido Larrain
- 33
- 3
3
votes
5 answers
How to execute more than 1 million insert queries in Oracle SQL Developer?
I have more than 1 million insert queries to be executed in Oracle SQL Developer, which takes a lot of time. Is there any way around to optimize this.

pheww
- 163
- 2
- 2
- 8
3
votes
2 answers
Executing several SQL queries with MySQLdb
How would you go about executing several SQL statements (script mode) with python?
Trying to do something like this:
import MySQLdb
mysql = MySQLdb.connect(host='host...rds.amazonaws.com', db='dbName', user='userName', passwd='password')
sql =…

Maxim Veksler
- 29,272
- 38
- 131
- 151
3
votes
2 answers
Need to create an SQL script to get this result
Let's say I have this:
+-----+------+
| ID | Var |
+-----+------+
| 100 | 2 |
| 100 | 4 |
| 100 | NULL |
+-----+------+
| 425 | 1 |
| 425 | 2 |
| 425 | 3 |
| 425 | 7 |
+-----+------+
| 467 | NULL |
| 467 | NULL |
+-----+------+
|…

Max Schwartz
- 35
- 6