The tag has no wiki summary.

learn more… | top users | synonyms

2
votes
1answer
16 views

How to get the spatial index in CREATE TO script?

Is it possible to get the spatial index using the create to script using SQL Server 2012? When I write out a table using SCRIPT TABLE AS > CREATE TO in Microsoft SQL Server Management Studio 2012, I ...
2
votes
0answers
17 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 ...
0
votes
0answers
10 views

Domain Inventory Powershell Script [migrated]

I'm working on a code for my companies office to help maintain better inventory of our computers and their capabilities/hardware. This is what I have written, Basically use Wmget to pull info off the ...
0
votes
0answers
21 views

long mysql insert and update script user variables appear to be lost while running script

I have a mysql database table called 'dash_something' dash_something ------------- date, DATE *this is the date of the summary type, CHAR(10) entity, CHAR(25) number_of_emails_1, INT ...
0
votes
1answer
192 views

how can I call nzsql or nzload from script without disclosing sensitive password?

I don't see this in the Netezza documentation. We have lots of Linux scripts where we do this: NZ_PASSWD_ENCRYPTED=29TY20T98= NZ_PASSWD_CLEAR=`DecryptFunc $NZ_PASSWD_ENCRYPTED` NzResult=$(nzsql -db ...
0
votes
0answers
28 views

cronjob(script) that sends(mail x) the query co-ordinator SID whenever parallels are invoked in queries

i am a junior dba im looking for help with a shell script that needs to be put in the crontab(which runs every 15min) which sends(via mail x) the query coordinator session id(SID) and other details ...
0
votes
3answers
59 views

List all tables that a specific login has permissions [duplicate]

This might be repetitive, but I haven't found a solution that serves my purpose 100%. What I'd like to achieve is to have a script (or SP) that'll list all tables that a user has permissions on. Any ...
0
votes
2answers
85 views

Set default value for all columns with specific name within a database

I've got a database that includes an int column project_id on many tables, and I want to script setting the default value to a specific value for all columns with that name in the database. Note that ...
0
votes
1answer
59 views

Testing multiple queries from input file

I have set of tables and need to execute select query based on different users. Table names are stored in file and I am looking forward to write a script to execute a script to read table name from ...
1
vote
0answers
973 views

Management Studio Generate Script Errors

I am trying to generate a script (right click database, tasks, generate scripts, tables) from SQL Server Management Studio 2008 R2 Express and I keep getting an error. I read somewhere that it could ...
2
votes
2answers
281 views

How do I Delete A Database And Log Files With SQL 2008 Script?

While working on making an automated Delete and Restore script for my backups I ran into a snag. I can not delete the database; however, the delete button works exactly how I need it to. Can anyone ...
0
votes
1answer
19 views

Continuous jobs on Redis [closed]

I want to setup a script that sums up a bunch of values in a list and then puts down the result in total-count and then removes the entire list, And this all should be repeated once a minute or as ...
2
votes
2answers
342 views

Scripting all of available databases to .sql files containing schema+data+users with single command

I have a SQL 2008 Express with 80 databases in it. I want to move these databases completely to another server which is hosting a SQL 2008R2 Enterprise instance. As i'm told it is better to script ...
1
vote
1answer
98 views

numbering rows consecutively for a number of tables

I have a number of tables, all containing attributes aid,bid,cid, and xid of type integer, other attributes may differ. For every (given) table T, I would like to order the rows according to ...
2
votes
1answer
488 views

Script all tables in a database

In SQL Server 2008 - is there any script available which will list all tables (incl column names, data type, length) for the entire database - with one script.
0
votes
1answer
115 views

Procedure and Automation in Mysql

i have a table with these columns and the values are coming in these tables from a csv file at a regular interval of n minutes ( by cron the load infile command) : ID (PK) status first ...
0
votes
1answer
150 views

How do I write this script?

I have a very large database and I want to select certain records and then set a column value such as: SELECT name, email FROM table WHERE zipcode = 12345 INTO outfile /tmp/file.csv; Then I ...
1
vote
1answer
197 views

db2ckbkp - How to determine what tablespaces are temp-tablespace

I am writing a script to restore databases from backup. The script should need as little input as possible to fulfill this task (in an efficient way). The restore command takes the parallelism ...
1
vote
1answer
775 views

Schema Change/Update script for Database deploy [closed]

I have a need to change the database schema . I'm planning to write Schema change and update scripts for tracking database changes and updating them. I followed Versioning Databases – Change Scripts ...
0
votes
2answers
92 views

Advice on scripting a “whitewashed” and downsized development db from main db

Currently we (an active opensource project) have a large PostgreSQL production database which contains all the site records. Since we can't just allow every developer or contributor access to the ...
2
votes
1answer
1k views

Does SQL Server 2008 have an equivalent to Oracle's “table%rowtype” syntax or (Data Type)?

In Oracle PL/SQL scripts, you can declare a variables using the syntax tablename%rowtype for its type. This will make that variable have the same "type" as a row of that table (i.e. a it will be a ...
1
vote
2answers
2k views

How to set password for PostgreSQL database with a script?

In a bash script I'm writing, I need to create a database and set a password that is generated automatically by my script. The problem is I can't find a way to set up the password without user ...
1
vote
2answers
409 views

How can I run a T-SQL Script using SQL Credentials?

I need to develop a T-SQL insert script for use on a remote SQL 2005 Express instance but I would like the script to include the necessary SQL credentials so all the user has to do is execute the ...
5
votes
1answer
167 views

How to schedule PostgreSQL replication?

I was reading postgresql replications solution but, even I just starting understaning how it works, another doubt has arrisen. I'll be using postgres internal replication solution but as far as I ...
1
vote
1answer
156 views

Drop database from remote that has connected users

I have a "small" problem. There is a database server that contains a database where some test frontends are connected to. I want to update that database from a dump + some scripts to the most recent ...
3
votes
1answer
433 views

Variable substitution in psql when using \copy

I'm using the psql command \copy and I would like to pass a variable to it from the shell (for table name) like I've done when scripting queries. I've read in the documentation for psql that: The ...
2
votes
1answer
70 views

How to create an object and then alter it

I'm using sql server 2012: I would like to script out creation of an object(if it doesn't exist first), and then alter it. I'm trying to avoid the usual drop/create as it would impact stats. It ...
3
votes
2answers
571 views

Perl vs Ksh for Unix Database Administration

I realize this is a somewhat more subjective question, but I am looking to the community for guidance. Our company is fairly new to having DBAs. We used to use DB2 for i on the IBM's iSeries servers, ...
0
votes
2answers
1k views

Reloading .sql file from java into PostgreSQL - Windows

I am trying to reload a .sql script file into PostgreSQL from my sample Java application. Script is successfully executed from console as well as from pgAdmin tool. But from Java, it hangs... This ...
2
votes
2answers
221 views

Defrag a HEAP by creating clustered index and immediately dropping it

I'm writing a script which intends to defrag a HEAP based table by creating a dummy col with a clustered index and then immediately dropping it. (It's someone else's app and I don't want to make any ...
2
votes
2answers
15k views

How to store single result in variable and reuse it in a query (Oracle)?

I have a query like SELECT id FROM xyz WHERE ...; which has a more or less complex WHERE clause and returns exactly one row with one column (ID). I need this ID for several later queries in a ...
3
votes
2answers
1k views

How to compare two SQL Servers instance level objects for a migration?

I'm currently working on a SQL Server migration (from a SQL Server 2005 to a 2008 R2 server, on a new physical server). The databases themselves will be transferred using a database backup and ...
1
vote
1answer
128 views

Regularly import tab-seperated log file to MySQL

I'm looking to keep arpwatch entries in a MySQL database to crossreference with other information I'm storing based on mac addresses. I've manually imported the arpwatch database into my mysql ...
0
votes
2answers
145 views

Auto Script DB Objects for SVN

My Boss requires that we keep up to date scripts of all database objects in svn. This results in constantly trying to find the object in the current script and copy and pasting the changes. Is there ...
2
votes
2answers
541 views

Save Results of DBCC ShrinkFile

When we execute the following command: DBCC SHRINKFILE('MyDB_log', 1) We get the following results in SSMS: DBID | Field | CurrentSize | MinimumSize | UsedPages | Estimated Pages ...
6
votes
2answers
12k views

Easy way to check connectivity to SQL Server from client

For troubleshooting purposes, I would like to be able to check if a client can connect to a SQL Server instance, independent of the application that possibly can't connect to the SQL Server. Is there ...
-1
votes
1answer
220 views

Selecting just one table from Oracle view [closed]

I am creating a view to ease my manual selecting because I only want to fetch data from DB where it is meeting certain criteria which are present in several tables, so it is containing a lot of joins. ...
2
votes
3answers
212 views

What is running right now?

I know I can use "show processlist" to see what is running when I'm in the office. How can I see what is running when I'm not there. Something is running on my server at 3am every morning that is ...
1
vote
1answer
3k views

Drop multiple databases in one script

I am trying to figure out how to drop multiple databases on PostgreSQL in one sql script. I preferably need it to work both when executed in pgAdmin console, and when used in psql command line tool. ...
4
votes
1answer
1k views

How, if possible, can an .sql file be executed against an oracle database from a bash script

Is it possible to execute an sql file (a text file containing several SQL statements) against an oracle database from a bash shell command line (e.g. no graphical GUI and no interactive clients) ...
2
votes
0answers
3k views

SQL*Plus, @, and relative paths

Somehow, it seems that SQL*Plus (at least on Windows) is unable to locate a script with a relative path when called with @@ and when the path starts with a single or double dot. For example, under ...
1
vote
2answers
251 views

PostgreSQL Database Migration

How can I migrate data from on PostgreSQL database to another PostgreSQL database? Is there any technique to migrate data with SQL scripting?
7
votes
2answers
2k views

Is there any collection of PowerShell scripts that help the task of SQL Server maintenance?

I've been studying PowerShell and I've been (slowly) getting it into my day-to-day DBA tasks. So far I've seen a bunch of disconnected PowerShell scripts for many disparate administration activities. ...
4
votes
2answers
755 views

Scrubbing Names via SQL Query/Batch

We have sensitive information (names of people) and we're looking to put into place a script to "scrub" of the names. Has anybody come up with a good algorithm to do this, something other than just ...
1
vote
1answer
133 views

Is it possible to allow write-through computed columns for legacy code that expects a column to be read/write?

I have this existing table for IP storage: CREATE TABLE [dbo].[IPAddresses]( [ID] [int] IDENTITY(1,1) NOT NULL, [IPv4Address] [varchar](15) NULL, [IPv6Address] [varchar](45) NULL, ...
1
vote
2answers
8k views

Exporting table records to an INSERT script

I'm setting up a test environment for development and need to export some static data from tables in Production. Ideally the exported product would take the form of a script with all the required ...
1
vote
3answers
878 views

SQL Server 2008 R2 Express Edition - generating database create script

I need to script a database schema out to T-SQL for inclusion source control. The Express version of SSMS doesn't seem to let you script the entire database, just individual tables. Are there any free ...
9
votes
2answers
6k views

Script out Oracle DDL in an automated fashion

Oracle SQL Developer is able to export DDL through Tools -> Database Export... This works very well, but requires manual intervention. I know of DBMS_METADATA.get_ddl(), but have found that the ...
14
votes
3answers
665 views

Alternatives to concatenating strings or going procedural to prevent SQL query code repetition?

Disclaimer: Please bear with me as someone who only uses databases a tiny fraction of his work time. (Most of the time I do C++ programming in my job, but every odd month I need to search/fix/add ...
4
votes
2answers
302 views

How to manage my own scripts

Every administrators, developers have their own collection of scripts (some patterns). Time to time they are dismissed from one job and they are employed to other one. Is there any good, easy used, ...