sql-scripts

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

我的未来我决定 提交于 2019-11-29 06:37:12
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 is the best way to set this timeout from within the script? At the moment I have all of this at the top of the script file in the hopes that one of them does something: sp_configure 'remote login timeout', 600 go sp_configure 'remote query timeout', 0 go sp_configure 'query wait', 0 go reconfigure with override go However, I'm still getting the same

How to create text file using sql script with text “|”

陌路散爱 提交于 2019-11-28 13:09:08
if i run below script without char "|" it working but when i am adding char "|" it is not working how to add char "|" using sql script to text file ? DECLARE @Text AS VARCHAR(100) DECLARE @Cmd AS VARCHAR(100) SET @Text = 'Hello world| ' SET @Cmd ='echo ' + @Text + ' > C:\AppTextFile.txt' EXECUTE Master.dbo.xp_CmdShell @Cmd thanks Pondlife The pipe character has a special meaning in batch commands, so it must be escaped using the caret character. This should work: DECLARE @Text AS VARCHAR(100) DECLARE @Cmd AS VARCHAR(100) SET @Text = 'Hello world^| ' SET @Cmd ='echo ' + @Text + ' > C:

Executing script file in h2 database

大兔子大兔子 提交于 2019-11-28 03:54:13
First of all I would like to say am new to h2 database. I need to execute a sql script file in h2 database. I have a script file test.sql and I want to execute this in h2 database. Is it possible? You can use the RUNSCRIPT SQL statement : RUNSCRIPT FROM 'test.sql' or you can use the RunScript standalone / command line tool : java -cp h2*.jar org.h2.tools.RunScript -url jdbc:h2:~/test -script test.sql You can also use the RunScript tool within an application: RunScript.execute(conn, new FileReader("test.sql")); If you are using spring-boot and spring-test with H2 it will automatically look for

MySQL columns with DEFAULT NULL - stylistic choice, or is it?

十年热恋 提交于 2019-11-28 02:35:59
问题 In many flavors of SQL, there are three ways you can implicitly set a column to NULL on every row insertion. These are: columnname type NULL columnname type DEFAULT NULL columnname type NULL DEFAULT NULL I.e. the first one sets the NULL flag (as opposed to NOT NULL), second one leaves the NULL flag to the default value, and the third one sets the NULL flag and sets the implicit value as NULL. I've heard about how in Microsoft SQL, the second variation is not exactly the same since you can

SQL Server - Running large script files

别等时光非礼了梦想. 提交于 2019-11-27 17:40:18
I have a database table on a development server that is now fully populated after I set it running with an import routine for a CSV file containing 1.4 million rows. I ran the Database Publishing Wizard on the table, and now I have a 286MB SQL script on my local machine. The problem is, I can't figure out how to run it. If I load it into SQL Server Management Studio Express I get an alert window that says "The operation could not be completed". Any ideas on how I can get this SQL script to run? Running something that large inside a single transaction is not a good idea. Therefore, I'd

How to create a oracle sql script spool file

坚强是说给别人听的谎言 提交于 2019-11-27 15:35:57
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 verify off declare ab varchar2(10) := 'Raj'; cd varchar2(10); a number := 10; c number; d number; begin c := a+10; select ab,c into cd,d from dual; end; SPOOL select cd,d from dual; SPOOL OFF EXIT; The above script does not work, but I want to do something like this where in the begin end block we compute some values and i want to spool those results. Thanks. This

Export specific rows from a PostgreSQL table as INSERT SQL script

守給你的承諾、 提交于 2019-11-27 10:01:49
I have a database schema named: nyummy and a table named cimory : create table nyummy.cimory ( id numeric(10,0) not null, name character varying(60) not null, city character varying(50) not null, CONSTRAINT cimory_pkey PRIMARY KEY (id) ); I want to export the cimory table's data as insert SQL script file. However, I only want to export records/data where the city is equal to 'tokyo' (assume city data are all lowercase). How to do it? It doesn't matter whether the solution is in freeware GUI tools or command line (although GUI tools solution is better). I had tried pgAdmin III, but I can't find

Executing script file in h2 database

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 05:12:31
问题 First of all I would like to say am new to h2 database. I need to execute a sql script file in h2 database. I have a script file test.sql and I want to execute this in h2 database. Is it possible? 回答1: You can use the RUNSCRIPT SQL statement: RUNSCRIPT FROM 'test.sql' or you can use the RunScript standalone / command line tool: java -cp h2*.jar org.h2.tools.RunScript -url jdbc:h2:~/test -script test.sql You can also use the RunScript tool within an application: RunScript.execute(conn, new

How to Execute SQL Script File in Java?

混江龙づ霸主 提交于 2019-11-26 15:24:41
I want to execute an SQL script file in Java without reading the entire file content into a big query and executing it. Is there any other standard way? There is no portable way of doing that. You can execute a native client as an external program to do that though: import java.io.*; public class CmdExec { public static void main(String argv[]) { try { String line; Process p = Runtime.getRuntime().exec ("psql -U username -d dbname -h serverhost -f scripfile.sql"); BufferedReader input = new BufferedReader (new InputStreamReader(p.getInputStream())); while ((line = input.readLine()) != null) {

Export specific rows from a PostgreSQL table as INSERT SQL script

女生的网名这么多〃 提交于 2019-11-26 14:58:59
问题 I have a database schema named: nyummy and a table named cimory : create table nyummy.cimory ( id numeric(10,0) not null, name character varying(60) not null, city character varying(50) not null, CONSTRAINT cimory_pkey PRIMARY KEY (id) ); I want to export the cimory table's data as insert SQL script file. However, I only want to export records/data where the city is equal to 'tokyo' (assume city data are all lowercase). How to do it? It doesn't matter whether the solution is in freeware GUI