The tag has no usage guidance.

learn more… | top users | synonyms (4)

1
vote
1answer
23 views

how to execute unix commands within nzsql?

I'm converting a script from Teradata to Netezza, and I'm stuck at the portion where BTEQ uses the functionality of the OS to check if a file contains any data. If it does, it is deleted. I want to ...
0
votes
1answer
8 views

Insert into table which contains nested-table inside (Object in Oracle)

I have script of creating here: create type Ingredients_type as object ( Ingredient_ID varchar2(20), Ingredient_Name varchar2(50), ICalori int, IPretein int); create type Food_type as object ( ...
0
votes
0answers
23 views

Need Help Shell Script Connecting MySQL DB

I am running this script to connect to the MySQL DB and achieve the following goal. Run the script for a set period of time. Run the Script for a set number of iterations within the that time. ...
-1
votes
0answers
20 views

How to script sftp using PSFTP.exe with private and public key [migrated]

We are doing ftp to remote server, and using password, but now they want us to use private and public key instead. just wonder if any one have done scripting(command line) ftp that use private and ...
-1
votes
1answer
38 views

Oracle csv line size more than 32767

How to generate csv in oracle if it's query result return more than 32767 character per line in linux shell script
0
votes
1answer
26 views

PostgreSQL - cannot create RULE from stored procedure

I'm trying to automate boring database work. I would like to have one function which creates views, rules, etc so I don't need to run corresponding SQL queries from file. Currently I faced an issue ...
0
votes
0answers
16 views

Need to run mysql script from monit

I wrote a shell script for mysql alerts which need to run under monit. The script is as below: #! /bin/bash -x tmp="/root/$$.txt" emailid="xyz@xyz.com" subject="Running Processes" echo "Running ...
2
votes
1answer
88 views

Grant sysadmin permissions to 'NT AUTHORITY\SYSTEM'

As you all know, Microsoft SQL Server version 2012 and above are not enabled any more sysadmin role flag to Local System (NT AUTHORITY\SYSTEM) account. In my case it's becomes a problem: I have a WiX ...
0
votes
0answers
33 views

Backup /www/ directory and all mysql databases

I'm trying to write simple shell script which will zip all databases + www directory. I don't know what is the problem but I've got wired output. I've got zip with .sql file full of hieroglyphics... ...
1
vote
1answer
40 views

Why does SQL Server Mangement Studio not script Indexes by default?

Recently I realized by default, scripting the database does not including indexes, and I have to change the option every time. Could anyone please explain the reason? Is there any insight about this ...
0
votes
0answers
12 views

Windows Powershell - multiline indirect for psql connection

I have a script that goes like psql << EOF sql 1 sql 2 EOF I want to do the same in Windows powershell. I learned about the script block, but tried passing it in Invoke-command, but hitting a ...
0
votes
2answers
41 views

sp_configure: Preserve values of 'xp_cmdshell' and 'Show Advanced Options'

I dont want to disturb the server values of xp_CMDShell & Show Advanced options. The criteria is to use SQL to run a batch file. This is the script i am trying to solve it with: DECLARE @...
0
votes
1answer
27 views

Powershell: Does System.Data.SqlClient.SqlDataAdapter usange in powershell need some ADO.Net installation?

In PowerShell, goal is to query some data from Sql Server and put that into a preformatted Excel file. Towards that, the following PowerShell script snippet, throws an error saying "assemblies are ...
0
votes
0answers
14 views

What is the best practice of storing mysql connection details to use in ruby/python scripts

I have ruby and python scripts that connect to mysql DBs. They are controlled in github and can populate to different servers. They run in a schedule way (not adhoc). What is the best practice of ...
0
votes
2answers
80 views

oracle rman connecting to a database in not mount state

When connected to oracle database through rman directly from the terminal, everything works fine, but when the same connection string is executed through a shell script rman connects to the database ...
1
vote
1answer
51 views

How is powershell commonly used in SQL server? [closed]

I am wondering how is powershell used in SQL Server? I heard people saying that powershell makes a DBA's life easier. But I dont know how is powershell commonly used in SQL server. Can anyone provide ...
1
vote
1answer
85 views

Include scripts for Indexes on Alter Views

After a Developer altered an Indexed View to add a comment, the clustered index that was created on it was dropped with no warning. This caused a failure as there are a couple of procedures that have ...
1
vote
2answers
22 views

How to grant permissions to users based on table information?

Say I have a table: +------------------------+ | Employees | +------+--------+--------+ | Dept | Name | Salary | +------+--------+--------+ | 1 | John | 10000 | | 1 | Mary | ...
0
votes
1answer
68 views

Generate backup script of SQL Agent Jobs using c#

I am using C# code to read all the SQL Agent Jobs: static readonly string SqlAgentJobName = "SqlAgentJob_123"; static ServerConnection conn; static Server server; static Job job; try { conn = ...
4
votes
2answers
101 views

How to script permissions for all logins/users/tables/schemas

Over the years, I have used countless scripts and applications to generate all permissions for SQL Server databases. I have used both paid and free tools. I feel that not one of them seems to be ...
0
votes
1answer
26 views

Is it possible to take the table level backup in mysql using any of the script?

I am new to MySQL and I am in need of the script which is taking backup of multiple tables from the multiple databases in single file in MySQL?
0
votes
1answer
37 views

how to access a table containing . in its name

I have created a database schema as "mytest.us" and inside this schema, I have created a table "a.b.c". When I do select * from select * from "mytest.us"."a.b.c"; year | mydata ------+-------- ...
1
vote
1answer
38 views

What is the purpose of the command-line options “-ANe” for MySQL?

I've recently changed how a mysqldump backup is set up, and happened across a helpful answer by RolandoMySQLDBA where his example: mysql ${MYSQL_CONN} -ANe"${SQL}" Uses the -ANe command line ...
0
votes
1answer
18 views

Prostrct create causes windows batch file to exit

I have a daily job to restore a database from last night's back up before doing other things to it and moving on. I'm trying to automate this with a script, but when I get to the following command the ...
1
vote
1answer
28 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 ...
0
votes
2answers
146 views

Find database user name from sysprocesses

I know that this is a strange requirement but I need to find out database user name(not the login name) from sys.sysprocesses for all the currently running processes. For e.g. select spid,dbid, uid ...
-2
votes
1answer
112 views

Script to check CPU, memory, server type

Can someone please help me with the script to get CPU, total physical memory, server type(i.e. physical/VM), maxdop and max server memory details? I need it to run for 50 servers. All the servers are ...
2
votes
1answer
46 views

SQL Server: Programatically trigger export of db schema

SQL Server 2014, Std edition We have seen and used, over the years, a variety of sprocs and non-MS tools to export the DB schema. The way we really like to do this is the built in utility, in SSMS, ...
0
votes
0answers
15 views

How to migrate logins ( not users ) from one instance to another? [duplicate]

I have lots of instances here where I work, and I'm planning to put all of them into just one. I will migrate all databases from these instances to only one instance. Ok, I can do this (I will backup-...
0
votes
1answer
14 views

Setting Blank lines to ON before executing a SQLFILE in shell script

echo exit | sqlplus username/password@host_ip:port/Service_name @SQLFILENAME I want to execute set sqlbl on before executing The SQLFILENAME and also want that after executing SQLFILENAME it should ...
1
vote
1answer
59 views

Ola Hallengren Scripts and Maintenance Plan Editor - How to execute sequentially on completion?

I'm using Ola Hallengren's scripts to perform maintenance on my databases. In the Maintenance Plan Designer I am trying to setup a plan that works step by step, but no matter what I try everything ...
1
vote
3answers
343 views

Need to get identify all tables and columns in a SQL Query

I have a massive task to go through hundreds of SQL scripts and identify the Table and Columns in each query as we are updating our system and some of the columns and tables may be renamed or ...
1
vote
0answers
46 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| | | | | | ........| | | | | ...
-3
votes
1answer
204 views

Generate Script Of Database in SQL Server 2008 [closed]

How to Create Script for the Database Objects in SQL server 2008 r2 and restore it in database.
1
vote
2answers
441 views

Script to backup all databases

I'm working on automating backups of SQL Server databases on SQL 2008 R2 Express. These backups are initiated daily by the Windows Task Scheduler, which execute a batch file, which in turns executes a ...
1
vote
0answers
39 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.
6
votes
2answers
184 views

Scripting an application role with a hashed password

I need to script an application role with a hashed password, so I can copy it from one database to another. Consider the following example code, which uses an Application Role to provide elevated ...
0
votes
1answer
129 views

Documenting SQL Server Database [duplicate]

I wrote the following (Quick and Dirty) script to document a database schema: Note - The relationships part came from another guys site (I just can't remember where). Does anyone know how to ...
3
votes
1answer
421 views

many csv file loading using bash script

#!/bin/bash # show commands being executed, per debug #set -x # define database connectivity _db="mydata" _db_user="root" _db_password="123" # define directory containing CSV files _csv_directory="/...
1
vote
2answers
160 views

parse rs.status() output to display one secondary node for mongodump destination

I wish to run mongodump to secondary (not primary). So I need as output hostname and port of one secondary. # ./mongo -udbadm admin --port 27100 -p --quiet --eval "printjson(rs.status().members.map(...
0
votes
0answers
23 views

Finding the least binary logs amount multiple slaves connected in master

I have the master server with multiple slaves (for ex: 4). I would like to purge the binary logs after checking the processed binlogs on all slaves. I wrote the below script to find the least ...
3
votes
1answer
151 views

How to map a drive in a SQL Server script

I am trying to execute below script to Network a Drive use master go exec sp_configure 'show advanced options', 1; go reconfigure go exec sp_configure 'xp_cmdshell',1; go reconfigure go EXEC ...
0
votes
1answer
131 views

List of role permissions including other roles - how can I find out the roles that belong to other roles?

I can see the permissions of a role in a database using the scripts in List all permissions for a given role? However, It does not show me when the role belongs to a another role. For ...
4
votes
1answer
249 views

Running a SQL Server query with as little impact as possible

I'm looking to create some basic scripts that are aimed at running on production systems. I want them to run with as little impact as possible. They shouldn't affect performance whenever ...
1
vote
1answer
562 views

executing shell (bash) commands from within the mongo client

How can I execute shell (bash) commands from within the MongoDB client? With MySQL client: system (!) Execute a system shell command. Is there something similar for MongoDB?
-1
votes
1answer
222 views

How can I generate a script to choose only top 10 items from each table in SQL database?

I know how to generate scripts that would contain insert queries of all records in all tables. But how can I limit this to top 10 records only from each table?I can select "Data Only" when generating ...
14
votes
1answer
415 views

User-shared queries: Dynamic SQL vs. SQLCMD

I have to refactor and document a number of foo.sql queries which will be shared by a team of DB tech support (for customer configurations and things like that). There are types of tickets that come ...
3
votes
1answer
264 views

How can filesystem storage (for blobs, images, etc.) be integrated with (traditional) database storage (e.g. MySQL/Postgres)?

If I use my database for relational data and opt to store large binary blobs in the filesystem, how can I integrate the two? How does this process work? I know that the database will need to store a ...
5
votes
1answer
65 views

Getting column information from the MySQL command line

I am trying to get all the columns from MySQL using bash scripting. I want them to be stored in an array. If I write it this way: mysql -uroot -pPassword1 "select column_name from ...
4
votes
1answer
50 views

Scripting Microsoft Data Warehouse Wizard

I am trying to automate the MDW setup process in my environment. Currently I have everything complete except for enabling the data collectors (usually uses a wizard as seen ). Has anyone seen or ...