Questions tagged [sql-scripts]

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.

437 questions
10
votes
1 answer

Is there a way to define the names of the result tabs names in an SQL Script in DBeaver?

I'm creating a MySQL Script that runs on a record and pulls associated records from a series of other tables, which is super useful but in DBeaver the results come back as tabs that only have the name of the table the results come from, which is…
Dri
  • 492
  • 4
  • 13
10
votes
2 answers

The difference between "Build", "Compile" and "None" Build actions in Visual Studio Database project

Although I can find (on the web) a lot of information about the PreDeploy and PostDeploy Build Action for SQL scripts in a Visual Studio 2012 Database project and I understand that None does not compile or include the script when deploying, please…
10
votes
3 answers

How do I set a SQL Server script's timeout from within the script?

I have a large script file (nearly 300MB, and feasibly bigger in the future) that I am trying to run. It has been suggested in the comments of Gulzar's answer to my question about it that I should change the script timeout to 0 (no timeout). What…
tags2k
  • 82,117
  • 31
  • 79
  • 106
9
votes
2 answers

SQL Server 2012 : How to script all database stored procedures into separate .sql files?

I want to script all the stored procedures from SQL Server 2012 to Visual Studio 2012 as .sql files (in a different project). How do I do that? I want one .sql file for each stored procedure? I get the scripts using the Generate Scripts in Tasks…
user5821224
8
votes
2 answers

How to execute multiple sql files in postgreSQL linux?

I have many .sql files in a folder (/home/myHSH/scripts) in linux debian. I want to know the command to execute or run all sql files inside the folder into postgreSQL v9.1 database. PostgreSQL informations: Database name=coolDB User…
null
  • 8,669
  • 16
  • 68
  • 98
7
votes
4 answers

How to create a oracle sql script spool file

I have a question about spooling the the results of my program. My sample sql script looks like this. whenever sqlerror exit failure rollback set heading off set arraysize 1 set newpage 0 set pages 0 set feedback off set echo off set…
user987900
  • 105
  • 1
  • 3
  • 11
6
votes
2 answers

Spring Boot Database initialization MySQLException for Trigger

I am using Spring Boot Database initialization using Spring JDBC with schema.sql file.I am using MYSQL If I have simple table creation in schema.sql as follows it works fine CREATE TABLE Persons ( PersonID int, LastName varchar(255), FirstName…
MasterCode
  • 975
  • 5
  • 21
  • 44
6
votes
4 answers

How to run an SQL script against a MDF file?

I've created a database model with model-first method using Entity Framework 4.0. I then created an sql script using the Generate Database from Model... I've also created an SQL Server Database file in my App_Data folder. How do I now run the SQL…
gligoran
  • 3,267
  • 3
  • 32
  • 47
6
votes
3 answers

C#, MySQL, ADO.NET, delimiter causing syntax error

I have C# code that cycles through .sql files and executes what's inside them to set up a database. One .sql file is basically as follows: DROP PROCEDURE IF EXISTS myProc; DELIMITER $$ CREATE PROCEDURE myProc() BEGIN -- procedure stuff goes…
Brillyints
  • 87
  • 3
  • 5
6
votes
3 answers

Calculate sum of column for selected Ids in SQL

These are my tables: Member: Id, Points CartRegister : Id, Member_Id, CartId, RegisterDate, Point SelectetMembers: Id, Member_Id Members can register Cart in CartRegister, and in Member.Points All points that a member earned must be calculated and…
Saeid
  • 13,224
  • 32
  • 107
  • 173
5
votes
1 answer

How do you create and update your SQL scripts?

I'm wondering what is the best way to create and maintain databases maps and SQL scripts. I know I'm more a fan of writing the SQL script by hand on a text editor (plus designing a map to have next to me on a piece of paper), while others prefers to…
Otiel
  • 18,404
  • 16
  • 78
  • 126
5
votes
3 answers

Create table as select statement primary key in oracle

Is it possible to specify which is the primary key on creating table as select statement? My aim is to include the declaration of primary key on the create table not modifying the table after the creation. CREATE TABLE suppliers AS (SELECT…
absolute
  • 63
  • 1
  • 8
5
votes
2 answers

IF in MySQL script

I have the following script: use my_db; if (2 < 3) then select 1; end if; When I execute this with command: mysql --user=myuser --password=mypassword < script.sql I get the following error: ERROR 1064 (42000) at line 3: You have an error in…
artaxerxe
  • 6,281
  • 21
  • 68
  • 106
5
votes
1 answer

Transfer data from one database to another database with different schema

i have problem to Transfer data from one sqlserver 2008 r2 to another sql server 2012 databases with different schema, here is some different scenario, database 1 database 1 with tables Firm and Client, these both have FirmId and ClientId…
adnan
  • 1,429
  • 1
  • 16
  • 26
5
votes
3 answers

How to create a procedure in an oracle sql script and use it inside the script?

I want to create a script for my oracle DB, which drops tables. If the table does not exist, the script won't exit as fail, just print a text: "does not exists". The script is the following: BEGIN EXECUTE IMMEDIATE 'DROP TABLE mytable'; …
victorio
  • 6,224
  • 24
  • 77
  • 113
1
2
3
29 30