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
0 answers
unable to export columns in single line in csv
i am using sqlplus and trying to export the columns(nearly 250 columns) of table_x. sharing the piece of code below:-
SET COLSEP ',' LINESIZE 32767 NUMWIDTH 18 LONG 4000 FEEDBACK OFF ECHO OFF
SET TRIMOUT ON ARRAYSIZE 5000 AUTOCOMMIT OFF FLUSH OFF…

iprashant
- 155
- 1
- 2
- 11
0
votes
1 answer
Update Script in SQL Server to add a hyphen after 5 characters
I have a varchar column which has data like ABCDE1, the first five characters will be alphanumeric.
I would like to add a hyphen for all records after fifth character
ABCDE-1
How can I achieve using an update script in SQL Server?

Cork Kochi
- 1,783
- 6
- 29
- 45
0
votes
2 answers
Run an oracle SQL script twice with different parameters
I have an SQL statement in Oracle SQL developer that has some variables:
DEFINE custom_date = "'22-JUL-2016'" --run1
DEFINE custom_date = "'25-JUL-2016'" --run2
SELECT * FROM TABLE WHERE date=&custom_date
The real query is much more complicated…

Nickpick
- 6,163
- 16
- 65
- 116
0
votes
1 answer
Why can't I write DDL directly after a PLSQL anonymous block?
I have the following simple script.
declare
begin
null;
end;
create table &&DB_SCHEMA..test_table (
test_column varchar(20)
);
Executing it ends with the following error
ORA-06550: line 6, column 1:
PLS-00103: Encountered the symbol…

Jagger
- 10,350
- 9
- 51
- 93
0
votes
0 answers
Running sql scripts in java from sql plus
I want to run sql scripts using sql plus. The problem is that if i dont have an exit statement in my sql script, the application stop running. I need to put exit to disconnect from sql. I dont want to be disconected because i want to maintain the…

CobianuA
- 15
- 5
0
votes
0 answers
Drop constraints not knowing its name
My problem.
I have a database and it is a big one, I want to remove a specific constraint between to table and i wanna do it with a migration scripts written in Visual Studio. I have it for development purposes running locally on my pc but it also…

Jimmy Lillegaard
- 129
- 1
- 9
0
votes
1 answer
Initializing database (with many 1...0,1 constraints) with default values
I have modelled a database (CMS for personal challenge), 14 tables with many foreign key constraints (specifically 1 -> 0,1 relations) and I will fill the tables with default values.
The challenge for me is to detect some kind of methodic in what…

Finn Christensen
- 91
- 1
- 10
0
votes
1 answer
Postgresql trigger delimiter issue when creating test database via Maven
I am currently working on a Java application which uses a PostgreSQL database. As part of the Maven build I test the database SQL scripts by dropping a test database, create it again and run all the SQL scripts.
On the Maven side I'm using the…

bobmarksie
- 3,282
- 1
- 41
- 54
0
votes
1 answer
Script Variables in Oracle SQL Developer
Given two tables
USERS
UID NAME
1 KEN
ADRESS
AID UID CITY
1 1 LONDON
I'd like to have an Oracle SQL Developer script that outputs two result tables just like if I'd had entered two select statements one after another.
This does NOT work, I…

weberjn
- 1,840
- 20
- 24
0
votes
1 answer
SQL EDITOR OPTIONS
Apologies in Advance for this question.
I have visual studio with reporting services 2008 R2. Editing SQL can be a pain when not formatted correctly. I have to do this in design mode in reporting services mainly and it is difficult to read.
What…

wodz
- 67
- 8
0
votes
1 answer
Script to automate TempDB free space check on SQL Server instances
Can anyone advice me how to write a script to automate TempDB free space check on SQL Server instances?
At the moment I connect to all instances individually and run the script
use tempdb
exec sp_spaceused
I have to repeat this for 10 other…

Kumar Velayutham
- 1
- 1
0
votes
1 answer
How do you generate a create users script from an existing MySQL db?
Have inherited a MySQL database that was completely trashed by the latest Windows 10 build update. The server lost all the user and schema information.
I restored the database back and recreated the users, set all the permissions etc. Obviously…

mmacneill123
- 33
- 6
0
votes
3 answers
selecting clients with only one product in SQL database
I have a table that has a primaryCustomerID and PositionCode columns.
The PriamryCustomerID contains the clients banking portfolio ID and the PositionCode contains the code of the banking products (WSO and PB).
I have to select clients with WSO…

Bethuel Mhlongo
- 47
- 8
0
votes
1 answer
relation "table name" does not exist (postgresql)
i wrote this code in the SQL Editor of postgresql for my database
CREATE TABLE flights.LINES
(
LID int NOT NULL,
ORIGIN varchar(255) NOT NULL,
DESTINATION varchar(255) NOT NULL,
DISTANCE float NOT NULL,
TIMETOARRIVE varchar(255) NOT NULL,
…

Abdulmalik Zoubi
- 23
- 1
- 2
- 6
0
votes
2 answers
Execute MySQL script in grails app
I have an MySQL Script I want to execute in a controller when my Grails 3.0.9 application is running. I've tried it this way:
import groovy.sql.Sql
import grails.util.Holders
def void clearDatabase() {
String sqlFilePath =…

Peter
- 1,679
- 2
- 31
- 60