Skip to main content

Questions tagged [scripting]

For questions about generating or using language scripts, for example scripting a database object definition.

Filter by
Sorted by
Tagged with
0 votes
1 answer
37 views

Help with creating postgres databases with - in the name

I'm currently trying to script some migration of databases on a server. As part of this process I will need to create a new database with a similar name to the existing database. Whilst I have this ...
Mr-F's user avatar
  • 101
0 votes
1 answer
96 views

How to execute complete database script without checks on objects existence

I'm working on a customer data archiving. I created a complete database script to prepare the new database for archiving data with the same DB schema of the production one. At the moment I'm preparing ...
El See's user avatar
  • 1
0 votes
1 answer
42 views

Display in asc order from multiple databases under multiple linked server and add two date parameters so that I can integrate it to my app

I have a script below where it display a result from different databases under different linked Server. The query is just connected or linked thru union all and it seems there's no issue on its result....
Caspersky12's user avatar
0 votes
1 answer
63 views

Extra `CASE WHEN` Removes Text from Dynamically Created String

I am trying to generate a CREATE TABLE statement based on a given table in my SQL-SERVER database using the INFORMATION_SCHEMA tables, but when I try and concatenate the DEFAULT portion of a field ...
javery's user avatar
  • 3
0 votes
2 answers
94 views

Do I need the MDF and LDF files when I run a script to generate my schema? [closed]

I'm migrating a database from SQL Server 2019 to SQL Server 2017. To do so, I am using the "Generate scripts" feature in the source database to generate the schema and data separately. (I ...
arnoldbird's user avatar
2 votes
0 answers
264 views

sp_OACreate script returns Null value from API fetch? The API works well in a html file

I am trying to create a script in Microsoft SQL Server Management Studio to fetch the current exchange rate from an API and update a database. I am told it is not posisble and common to do this. -- ...
Luis Avalos's user avatar
0 votes
1 answer
47 views

Do SQL Server have the utility same as Oracle Wrap Utility?

i have made a useful scripts in my environment and i want to wrap the script same as Oracle Wrap utility can do. is there any other way to the same in sql server?
zul nasir's user avatar
0 votes
1 answer
687 views

Error with dbatools

Trying to export SQL Objects via DBAtools in Powershell. Get-DbaAgentJob -SqlInstance 'TestServer01' -Job 'mydatabase-daily-backup' | Export-DbaScript -FilePath C:\temp\mydatabase-daily-backup.sql ...
Prakash's user avatar
0 votes
1 answer
59 views

How to rapidly compare definitions of many tables of two PostgreSQL databases?

I have two PostgreSQL databases, the one for producing, and the other for testing. Both of them have a lot of tables with same table names. Now I need to upgrade the producing system to the new ...
Leon's user avatar
  • 359
0 votes
2 answers
604 views

Loading multiple CSV files into mariadb table using LOAD DATA INFILE and shell script

I'm attempting to load CSV data into a mariadb table. MariaDB is running in a docker container and the CSV files have already been copied in the container as well. I'm already able to successfully ...
Roshan Upreti's user avatar
0 votes
1 answer
35 views

How to migrate a database from 2016 to 2014 if there are encrypted/locked objects(SPs) associated with it?

I am trying to migrate a database from 2016 to 2014 through Task-->Generate Scripts. There are some stored procedures that are locked and seems like they are encrypted as well. They are causing ...
user2664231's user avatar
1 vote
1 answer
493 views

Set 'timing on' for the duration of the current `psql` session using command-line options

What is the equivalent of \timing on command in psql, using the psql command-line options? I am aware that this will enable timing for all psql sessions: echo '\\timing on' >> ~/.psqlrc I am ...
Timur Shtatland's user avatar
0 votes
2 answers
258 views

Command line command to read Oracle Database export Success Message In log File

We have several oracle 19c servers with daily exports. I would like to find a way to run a command to read the export log file to find the success message for the day. e.g. I would like to putty into ...
crcoder's user avatar
-1 votes
2 answers
301 views

Is there a short script to safely perform a major-release upgrade on a postgreSQL docker container?

The question specifically focuses on the assumed required upgrade of the data structures when stepping up to the next or even latest major release. I know it usually involves dumping the data before ...
datenheim's user avatar
  • 123
0 votes
1 answer
430 views

Script to get definitions of table types and Sequences

I need to get the definition of some objects in the SQL server. I got the definitions of stored procedures, functions, views and triggers from sys.sql_modules. But, I don't know how to get that of ...
Viz Krishna's user avatar
2 votes
1 answer
9k views

Run PSQL command from bash script

I would like to know how to run \du within a script, and output that to a file. Something like the following: # some_script.sh psql <database connection> & \du > output_of_du.txt I can ...
baxx's user avatar
  • 316
0 votes
2 answers
59 views

How to query 30k of entries from an external data source by script

I have a SQL query which works for single checks: SELECT trans_id from schema.table where trans_id like '%<trans_id>%' There're might be better approaches to query for, but that's not the point. ...
dbalucas's user avatar
0 votes
1 answer
4k views

Run both of "DROP DATABASE" and "CREAT DATABASE" in CLI with "-c" option of psql of Postgresql

When debugging programs, I need to frequently drop a database of Postgresql, and then re-create it again. To convenient, I want to execute this in a single command line like following: psql -c "...
Leon's user avatar
  • 359
0 votes
0 answers
66 views

Create dadabase with spesific encoding from shell script

I want to create a database from shell script, I add this line to my script psql -c 'CREATE DATABASE template1 WITH OWNER = postgres ENCODING = 'LATIN1' TABLESPACE = pg_default LC_COLLATE = "...
user3093583's user avatar
1 vote
1 answer
1k views

Executing Cassandra pod CQL queries from shell script, using shell variables with kubectl exec

I have a repetitive task that I do while testing which entails connecting to a cassandra pod and running a couple of CQL queries. Here's the "manual" approach: On cluster controller node, I ...
James's user avatar
  • 113
4 votes
2 answers
2k views

How to set the sqlcmd.exe exit code?

The script needs to test to see if a backup table already exists and stop if it does. This is to prevent overwriting a backup already created. The following will stop further script execution (but not ...
lit's user avatar
  • 223
0 votes
1 answer
682 views

Script server level user securables onto another server

I have restored a backup of the live DB on a test SQL Server VM. Then I scripted the server level SQL users and restored them on the test SQL Server and fixed the orphaned user situation. But the user ...
variable's user avatar
  • 3,499
0 votes
1 answer
3k views

How to use psql command with no password prompt? [duplicate]

I'm trying to write shell script to avoid entering password every time while login to psql.
Lenin's user avatar
  • 1
1 vote
0 answers
325 views

Scalar function parses and runs in SSMS, incorrect syntax in ScriptDOM

I'm preparing the Database migration from compatibility level 140 (SQL Server 2017) to level 150 (SQL Server 2019). As part of the preparation, Data Migration Assistant (DMA) has been run and it found ...
Zikato's user avatar
  • 5,512
0 votes
1 answer
311 views

Pentaho does not read sql script (csv)

I was trying to use a different sql script for one job. For doing this i need to pass the script by file csv, so i set the script like a variable and then i make a transformation that "copy to ...
umberto mauro's user avatar
1 vote
1 answer
7k views

Postgres how do return a message if no results for SELECT query

Have been trying to work out how to return a message if the result is empty. I am running a select statement as below: select * from maxIDValue where max_value > 1000000 order by max_value desc; I ...
rdbmsNoob's user avatar
  • 459
1 vote
1 answer
287 views

Cannot script stored procedure while restoring another copy of current db

I have some large DB that I need to restore to another db from time to time, this process take some time to conclude. The annoying thing I found out in last version of SSMS is that I cannot script any ...
sepupic's user avatar
  • 11.2k
0 votes
2 answers
7k views

Oracle: Simple way to compare all objects of a schema in two databases?

I'm attempting to compare all objects of two schemas located in two different databases. I know there may be ways to do this with TOAD and SQL Developer, but is there another way to do this by script ...
Phillip's user avatar
  • 11
0 votes
1 answer
815 views

How to generate constraint sql?

I'm looking for a method that can generate the creating sql, like PgAdmin's SQL tab while having selected the constraint. (how pg admin does it?) I want to implement a generic method that can drop and ...
cdalxndr's user avatar
  • 141
0 votes
1 answer
4k views

Read and Get Data from ExcelFile using powershell

I'm starting with powershell and this time. I have to read all the values from a excel file In this case from a specific sheet. The ultimate goal of this task is to get the values from two columns and ...
SakZepelin's user avatar
0 votes
1 answer
135 views

Space estimates for each table if compression is removed

I am trying to gather space estimates if compression is removed from tables in a database. I started with a temp table and generated statements to execute sp_estimate_data_compression_savings as ...
Patrick's user avatar
  • 688
1 vote
1 answer
380 views

how do you escape single quotes in a mysql script?

I need to create a trigger via mysql script CREATE TRIGGER sync_new_oauth_sessions AFTER INSERT ON oauth_sessions FOR EACH ROW BEGIN SET @s = 'INSERT INTO oauth_sessions_new(id, client_id, ...
dierre's user avatar
  • 115
1 vote
1 answer
3k views

MySQL dump to MariaDB issue with collation

I have a django app running on a staging server (windows server 2012) with a MariaDB database. I have a git hook running mysqldump locally when I push to the staging branch. On the server I have a ...
Samoht's user avatar
  • 13
0 votes
1 answer
913 views

Oracle database 12C restore script

i'm trying to create backup restore script . in short my backup script creating new directory every day from the operating system level and then backup the database using the directory created i tried ...
Seif Hassan's user avatar
0 votes
1 answer
800 views

What does this statement mean: SELECT ... COLLATE SQL_Latin1_General_CP1_CI_AS AS [-‌- Logins To Be Created --]

What does this statement mean? SELECT ... COLLATE SQL_Latin1_General_CP1_CI_AS AS [-- Logins To Be Created --] It is part of a script I'm trying to adapt for listing out the SQL Server logins in an ...
PTL_SQL's user avatar
  • 377
0 votes
1 answer
248 views

Silence Sqlplus Login Message but Retain Echo

Running a series of automated checks on our databases for the security folks checking our STIG compliance. Mostly simple stuff like certain parameters turned off, etc. We're in the stone ages, so this ...
Jeff Bauersfeld's user avatar
0 votes
3 answers
7k views

History of actions that occured on a table in SQL Server

I am running a shell script that runs insert, update, delete queries on a table in an SQL Server DB. Is there a way to get a history of all transactions that happened on the table to validate that ...
Fazil Hussain's user avatar
0 votes
1 answer
807 views

Take a "slice" of a SQL Server database: for all tables, get only the rows that join (directly or indirectly) to a specific row

For audit purposes, I'm trying to obtain a copy/export of a DB but including only the rows from each table that have relevance to a small collection of rows in some table. So every row of every table ...
Carl Patenaude Poulin's user avatar
1 vote
2 answers
603 views

How to script server level objects in sql server?

I regularly do sql server installations (mainly sql server 2016), in virtual machines or otherwise, and I have a bunch of things like permissions, and linked servers and endpoints that I have mostly ...
Marcello Miorelli's user avatar
1 vote
1 answer
678 views

Shell Script to kill slow running Mongo Queries

I need to create a shell script that finds and kills long running mongo queries more than a specified threshold e.g. 15sec I plan to use db.currentOp(); and db.killOp(); to find and kill queries but I ...
DB guy's user avatar
  • 69
1 vote
0 answers
888 views

How to simulate slow queries on MongoDB

I need to write a shell script that finds and kills long running mongodb queries, but I don't have access to the database that runs slow queries, how to I simulate running slow queries on my local ...
DB guy's user avatar
  • 69
0 votes
0 answers
144 views

Appropriate language to write a Script that Kills Long running query MongoDB

I want to create a script that kills queries when they reach specific time threshold, I will be using db.currentOp() method to get information about currently running queries, and use db.killOp to ...
DB guy's user avatar
  • 69
1 vote
3 answers
3k views

DB2, How to save all stored procedures as files

How does one extract all stored procedures from a DB2 schema as individual files (without using Data Studio so it can be scripted). I need them all so I can uploaded to source control. I have found ...
Jake v1's user avatar
  • 73
1 vote
0 answers
797 views

Keeping the same order of selected records while inserting to another table

I am running a below query in big query insert into `test-project.temp_test_dataset.cluster_records` (pm,col1,col2,col3,total) select pm,col1,col2,col3,total from ( select 'ingest' as pm,col1,col2,...
vikrant rana's user avatar
2 votes
1 answer
203 views

Where can I find SQL Developer Database examples (scripts) to add data to practice?

Where can I find SQL Developer Database examples (scripts) to add data to practice? I require SQL scripts that will add tables and data on those tables in order to practice with Power Bi.
Rodolfo Villalta's user avatar
2 votes
3 answers
9k views

Postgresql Backup all databases separate files

I need to create an automatic backup of all databases from PostgreSQL (running on a Windows machine). I need to know if it is possible to get a backup of all databases but in separate files. Using ...
Anisa Ibro's user avatar
1 vote
1 answer
2k views

SQL Server Command Line Install - How to change the edition?

I am creating a script to install SQL Server via the command line. I cannot see a way to choose the edition I want to install. The GUI on my install media offers Evaluation, Developer or Express: (...
SE1986's user avatar
  • 2,083
0 votes
1 answer
613 views

How to save Outlook attachment in a drive with a new name and overwrite if it already exists? [closed]

I am using below VBA script to download attachments from email and save it to my windows directory. I need help to modify this script - 1) to save rename the attachment before saving it 2) Overwrite ...
Andleeb Hasan's user avatar
1 vote
1 answer
2k views

Oracle - Delete dmp files from ASM diskgroup

I want to delete my export files daily from ASM diskgroup with a crontab job. I want to prepare a script for it. ASMCMD> ls exp1.dmp exp2.dmp exp3.dmp exp4.dmp ASMCMD> pwd +DATA/EXP How can I ...
jrdba's user avatar
  • 55
1 vote
4 answers
5k views

Error "the system cannot find the file specified" when opening a large SQL Server file

I have generated the script of my whole SQL Server database into a file and it's more than 36 GB. When I try to open it, I get the following error: The system cannot find the file specified. At ...
iminiki's user avatar
  • 119

1
2 3 4 5
8