Questions tagged [scripting]

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

50 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3 votes
0 answers
16k views

DROP DATABASE IF EXISTS CREATE DATABASE IF NOT EXISTS USE in PostgreSQL

I always was used following header in files that defined database in MySql: DROP DATABASE IF EXISTS base; CREATE DATABASE IF NOT EXISTS base; USE base; In PostgreSQL there are the following ...
Daniel's user avatar
  • 209
3 votes
0 answers
1k views

execute R script using a postgresql trigger:

This is my first question here, so excuse me if it does not look well organized: I want to call a R script from a trigger (postgresql) so this script will be executed after an INSERT on my table (...
AIA's user avatar
  • 31
3 votes
1 answer
2k views

select two tables and print the columns side by side with matching key in hive

I have the below tables: table_1 name_1 id_1 value_1 avi 1 21 adi 2 X table_2 name_2 id_2 value_2 avi 1 21 adi 2 22 metadata_info: can be read from ...
avinash's user avatar
  • 31
2 votes
0 answers
108 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
2 votes
0 answers
266 views

the mystery of the table showing up in the subscription, but not in the publication

TL;DR: This question refer to sql server 2016, transactional replication I've got a table that shows up in the subscription but not in the publication. Here are the details: In one of my servers ...
Marcello Miorelli's user avatar
2 votes
1 answer
69 views

How can I optimize this MYSQL Script For many Records?

I have This script by Helping @lukstorms , -- DROP TABLE IF EXISTS test_words; CREATE TABLE IF NOT EXISTS test_words ( id int unsigned NOT NULL PRIMARY KEY, words text NOT NULL ); -- DROP TABLE ...
SmmSamm's user avatar
  • 21
2 votes
1 answer
226 views

How to order databases by size? (For use in full backups)

Recently, I've been trying to make our company's full backup process more efficient. In order to do this, my team has decided that instructing the backup job to tackle the full backups starting with ...
hemuxin's user avatar
  • 21
2 votes
0 answers
929 views

SSIS Script Component errors sporadically with the same code

I have a SSIS Data Flow Task that takes CSV output (from a flat file connection) and passes that to a Script Component. When I run the task I get the following error: Script Component has encountered ...
Zach Smith's user avatar
  • 2,360
2 votes
1 answer
278 views

My SSMS is bringing wrong object in "Script Stored Procedure as" > "CREATE To" > "New Query Editor Window"

When I go to Object Explorer and expand down to Stored Procedures (or Tables), right-click on one of them and choose "Script Stored Procedure / Table as" > "CREATE To" > "New Query Editor Window", it ...
Alexandre's user avatar
  • 165
2 votes
0 answers
1k views

How to get status of "opatch prereq CheckApplicable" via script

I want to check if a patch is Applicable via opatch prereq CheckApplicable -oh <oracle home> -ph <patch home> but the returncode is always 0! It doesn't matter if the text output says ...
Sebastian S.'s user avatar
2 votes
0 answers
1k views

Scripting Local Policy Perform Volume Maintenance Tasks

I am working on an automated SQL 2012 install process on Windows 2012 R2 and have everything complete except for one task. My process launches secpol.msc but I am still required to drill in and ...
Scott S's user avatar
  • 21
1 vote
0 answers
309 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
  • 4,507
1 vote
1 answer
240 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
  • 11k
1 vote
0 answers
819 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
1 vote
0 answers
607 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
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
0 answers
2k views

Show Collections in MongoDB throwing

I am connecting to MongoDB hosted on EC2 instance of AWS. I am connecting through ssh command. Upon entering the command "show collections", I am getting uncaught exceptions. Please see the sequence ...
RB17's user avatar
  • 107
1 vote
0 answers
40 views

Checking if schema name is included in every sentence

I got some oracle database scripts for creating the whole database of an application, including sentences for creating tables, sequences, synonyms, inserts and updates of data, etc I need to ensure ...
Tommy's user avatar
  • 111
1 vote
1 answer
72 views

is there a way to improve this query by not re calculating functions? cross apply?

when I set up replication I like to take a count of each table in the publisher, then I go to the subscriber I do the same thing in order to compare both pictures. this is the picture from the ...
Marcello Miorelli's user avatar
1 vote
1 answer
269 views

How to upgrade a MySQL database using numbered scripts based on a version field

I have a database that contains a version table with one value stored in it which is the database version number. I would like to be able to update the database version automatically using numbered ...
Mark Smith's user avatar
1 vote
1 answer
90 views

How to make performance tests for DML

I created two multi-column indexes on a big table (~2,5 millions rows 370Mb and 621Mb with indexes). SELECT queries are very fast. Know I want to check if we have a regression for INSERT/UPDATE ...
Mika's user avatar
  • 351
1 vote
0 answers
84 views

How to save SSMS 2012 Object Explorer Scripting Settings?

I'm generating a bunch of object creation scripts in SSMS 2012, using the Object Explorer context menu. The default options for these generated scripts are not to my liking (for example, I want the ...
Rebeccah's user avatar
  • 141
1 vote
0 answers
240 views

How to investigate non-specific Generate and Publish Scripts Wizard errors

I am trying to use the Generate and Publish Scripts wizard in SSMS 2012 against a 2012 SQL instance and am getting errors. Trying to generate a schema-only script of the tables and schemas. I allowed ...
IanG's user avatar
  • 314
1 vote
0 answers
214 views

Loop a script for all DBs in SQL Server

I am trying to run Kendra's script for all DBs but running into issues.I have tried below. http://www.littlekendra.com/2016/05/05/how-to-script-out-indexes-from-sql-server/ DECLARE @SQLCmd VARCHAR(...
SQLPRODDBA's user avatar
  • 1,908
1 vote
0 answers
238 views

SQL Server and Network considerations to transfer backup file to a shared folder

I'm facing with a situation where backups are being transferred manually to a Shared Folder and my goal is to optimize all of this. What I have to deal with is: 8 Windows 2008 R2 Servers 2 Windows ...
BlackStar's user avatar
  • 155
1 vote
0 answers
139 views

What should be the best practice to alter the table using the script to shift columns

I have a MySQL table which has columns 93 in it. All first 92 columns are INT(11) and the last column is of type DATE. |number|0|1|2|3........|88|89|90|ddate| | | | | | ........| | | | | ...
user79847's user avatar
1 vote
0 answers
57 views

Disable the Task action button

How can I disable the "Tasks ->" button in SQL Server Management Studio? I need to prevent users scripting objects.
raju's user avatar
  • 11
1 vote
0 answers
58 views

T-SQL stored procedure: granting general user access to specific stored procedure

I'm attempting to alter a stored procedure that needs the line added: grant exec on dbo.sproc_name to exec_proc I believe the admin setup the exec_proc as a group. I added this grant line following ...
natur3's user avatar
  • 21
1 vote
0 answers
389 views

Parallel insert in db2

I am trying to import from 8 files and insert into a single table in db2. I am running 8 .sql files that will do the task, but only one of them actually seem to be running and inserting into table. ...
Rangesh Ananthalwar's user avatar
0 votes
1 answer
313 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
0 answers
31 views

"consise" SQL table scripting via Powershell SQLServer module

When I script a database using Visual Studio, I get a more "consise" script like the one below, where constraints are included in the create table statement. I'm wondering if there is an ...
taglius's user avatar
  • 101
0 votes
1 answer
25 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
0 votes
2 answers
210 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
0 votes
0 answers
59 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
0 votes
1 answer
409 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,595
0 votes
1 answer
280 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
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
702 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
147 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
0 answers
137 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
0 votes
0 answers
102 views

Loading 260GB worth of CSV into MySQL in Linux

I'm bulk loading a few thousand CSVs totaling ~260GB and ~4.5 billion rows to MySQL using mysqlimport calls on each CSV executed within a bash script. The MySQL installation and the data itself are ...
Chris's user avatar
  • 191
0 votes
0 answers
335 views

Using SQL script in Toad, how do I suppress the echo of the SQL statements

I'm using a script (Toad, Oracle) so that I can use variables and enter two values that get repeated in multiple SQL statements. That's working great, but the SQL statements echo into the console ...
arcy's user avatar
  • 109
0 votes
1 answer
381 views

Realtime Update MySQL on every Update occurred on PostgreSQL

I have a PostgreSQL for my accounting system and a MySQL database for my php website, i want to sync these two database for every update may occurred on PostgreSQL it also updates MySQL database, they ...
AHAD's user avatar
  • 1
0 votes
0 answers
11k views

execute .sql script inside an anonymous pl/sql block which is invoked by a shell script

I got a shell script which connects to SQLPLUS and executes the .sql file like below: read a x=`echo $a | cut -d , -f 1` y=`echo $a | sed 's/.*,//'` c=`echo $USER | cut -c -2`"OPR"`echo $USER | ...
SSS1's user avatar
  • 11
0 votes
1 answer
46 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
  • 347
0 votes
1 answer
103 views

databases cross references baselines

We have on several databases on same instances, some stored procedures have references to tables on other databases. We are in the middle of a big project to take our database under source control. ...
Yaroslav's user avatar
  • 2,826
-1 votes
1 answer
414 views

Syntax Error in Create Table Statement

I'm using Oracle 12c, I want to create a table with partition by year and subpartition by month like this. create table par.Log_his ( ID NUMBER(20) not null, Year number(4,0), -- ...
Peace Peace's user avatar
-2 votes
1 answer
1k views

How to resolve error "SQL0104N" when running "db2 prune logfile prior to" command?

I wrote an script to delete transaction log files in db2. I need to delete all the files prior to the active log file.I wrote this code as .sh file db2 connect to DWHDB db2 get db cfg | grep '/...
user203085's user avatar
-2 votes
1 answer
111 views

How to write a shell script to disable the database accounts from a list of user IDs

I am new to Unix scripting...I have a list of userids for terminated employees. I want to write a script that will check these userids against my databases and disable/remove the user accounts ...
Londi Tangu's user avatar
-3 votes
2 answers
3k views

Need a shell script that can run a oracle query and produce output in .csv format

Can you please help- need a shell script that will have a oracle query inside it and produce a .csv format output in specific location, that script should be a scheduled in a cron job which runs, the ...
Kilaru Krishna Chaitanya's user avatar