The tag has no usage guidance.

learn more… | top users | synonyms (4)

0
votes
2answers
43 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
47 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
37 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
9 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
42 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
138 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
36 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
60 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
227 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
32 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
106 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
90 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
171 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 ...
1
vote
2answers
72 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 ...
0
votes
0answers
18 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 ...
2
votes
1answer
99 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 ...
4
votes
1answer
224 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
254 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
106 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
265 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
115 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
62 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 ...
3
votes
1answer
42 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 ...
1
vote
1answer
220 views

Import data from one Database to another script

As part of a data migration I would like to script a data transfer from the existing to a new database. I used to do this with DTS on older versions of MS SQL. I am currently using SQL 2012. Note the ...
1
vote
2answers
521 views

ORACLE_HOME / ORACLE_SID variable - why do we need to export them ?

I am not sure if this is a bash / shell question or oracle question. I am on linux and oracle 11g. I have always export my ORACLE_HOME and ORACLE_SID variable and e.g. using invoking sqlplus is no ...
0
votes
0answers
81 views

How to generate “Too many connections” error using mysql cli over ssh

I have a script which queries for blocks of data, one after another, from a remote MySQL database via ssh and mysql cli and pipes the result output to stdin of a local executable. Loosely scripted, ...
2
votes
1answer
268 views

SQL Server : create dynamically queries to select all related data in DB based on entry table and ID

I'm tasked to create a SQL statement which will create (and run?) multiple other queries which will select all related data outgoing from an given ID (uniqueidentifier) and a given table name. It ...
1
vote
1answer
37 views

Is there another/better way to create and maintain large amounts of procedures?

So I've decided to take a step back, and scrutinize the way I implement procedures on my databases. I'll list what I have done, give my reason for doing so and hopefully I will be told that I'm a ...
0
votes
0answers
311 views

scipt for rman configuration & database backup in dataguard environment

environment Oracle Solaris 10 -> 5.10 Generic_147147-26 sun4v sparc Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit production Oracle Solaris Cluster 3.3u2 for Solaris 10 sparc ...
0
votes
1answer
49 views

Generate Schema Only Script from SQL Server 2012 to SQL Server 2008R2

Hi this is the first time that I've encounter this error in generating script for my database, what do you think causes this error? Thanks. Please see image.
2
votes
0answers
159 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 ...
0
votes
0answers
72 views

SQL Server 2008 R2 Error Msg 15063 and Msg 15410

I just execute a Schema Script from my SQL Server 2012 Database to SQL Server 2008 R2. I'm using same SQLAdmin account for this two Server. But when I execute the Schema Script I receive an error ...
0
votes
3answers
197 views

MySQL Monitoring Script in Shell or Perl for Linux

I need a MySQL Monitoring Script in Bash or Perl for Linux. I found some but they are quite big with a lots of checks that are not useful at all for me and in this case I should customise the ...
3
votes
1answer
146 views

xp_cmdshell in a transaction

I need to run multiple scripts in a certain folder in a transaction and rollback if there are any errors. At this point I'm just trying to get the rollback to work without a try catch. Currently when ...
1
vote
1answer
188 views

How do you grant permissions to a MySQL user using a shell script with variables?

I'm trying to create a provisioning script for Scotch Box (Vagrant) that will populate a database with seed content when I fire up the server. When I name the actual user, database, password, and ...
2
votes
1answer
106 views

How to script a table? [duplicate]

When I right-click a table in Object Explorer and click "Script Table" I can get SSMS to script my table. Can I do that with T-SQL code? I'm after the "CREATE TABLE xx" code that SSMS generates, so ...
3
votes
2answers
717 views

How do I pass multiple statements into sqlcmd?

Wanting to automate some tasks instead of firing up SSMS for everything, I'm trying to write a batch file to run these statements, which work perfectly when I paste them into the sqlcmd prompt. They ...
0
votes
1answer
782 views

Delete files from disk, with a job, respecting some rules ( SQL Server 2008 ) [closed]

We have An application that our customers use to download and upload files. I need to delete these files from disk after 30 days, of if it was downloded, in 7 days. How can i Use the script below, ...
0
votes
3answers
551 views

MySQL Exporting a query to text file via Cron Job

I'm in the beginning stages of hacking together code that syncs two completely different pieces of software/webware. I'm looking for a way to run a SQL query and output the results to a text file. I'd ...
4
votes
4answers
3k views

Get object script in SQL Server via T-SQL?

I need to get the creation script of an object in a SQL Server database. I need the exact same script that was used to create it. Like when you use SSMS to alter a view you already defined, and then ...
2
votes
2answers
149 views

PostgreSQL - is it possible to use a plpgsql function in a bash script?

Target : What i'm trying to achieve is to restore a partial backup of a database (only certain rows that satisfied certain conditions have been backed up). Problem : Since between the partial-backup ...
1
vote
1answer
257 views

PostgreSQL - partial dump of large orbjects (pg_largeobject table)

Context : Our web-app is like a collaboration platform where you can share files, appointments, survey and so on. An instance of this web-app is divided in communities, each one is independent to each ...
0
votes
2answers
85 views

How to list LOGIN + ROLE in SQL Server 2008?

I'm looking for an answer but I can't find it. Just a lot of long scripts. I need to list Login | Role (sysadmin, dbcreator, etc ) but I can't find a table to join. I have this for now: SELECT ...
0
votes
1answer
104 views

How do you dump specific table(s)?

Hi i have a shell script for doing a selected databases backup. Now my requirement is i wanted to take a particular tables in a database to be backed up. Each database backup need to be created in ...
0
votes
1answer
166 views

Shell script for partial table backup

I have multiple database in my MYSQL server and i want to take some particular tables backup from each database. can anyone help me in writting a shell script for this scenario.
0
votes
2answers
590 views

Write output from dynamic queries in PL/pgSQL to CSV file

PG_CMD="psql -d portal -U portal -c " PG_CMD_TP="psql -d portal -U portal -t -P format=unaligned -c " abc() { $PG_CMD " DO \$$ DECLARE srowdata record; ...
0
votes
1answer
97 views

dynamic postgres inside shell script not working

PG_CMD="psql -d portal -U portal -c " PG_CMD_TP="psql -d portal -U portal -t -P format=unaligned -c " abc() { $PG_CMD " DO \$$ BEGIN select * from customer; ...
2
votes
1answer
145 views

Reverse engineer SQL Server diagram?

I've been trying to find an option similar to MySQL Workbench 'Reverse engineer' for MSSQL Server 2012. I want to generate the SQL script from a diagram I've created. Is such option available for SQL ...
0
votes
1answer
587 views

Running Oracle Export Utility within a Shell script

I have wasted a lot of time on this. Any ideas of what I am doing wrong here? Script in bash #!/usr/bin/bash . . . /export/home/app/oracle/product/10.2.0/bin/exp $uname/$passw \ ...
0
votes
2answers
60 views

Tablespace Creation and Reassignment

It has been determined that user "SCOTT" should use a new temporary tablespace called TEMP2 size equivalent to TEMP tablespace (refer to Notes below for determining the size of TEMP). Create ...