[how to] Sqlcmd command strips $ out of query variable |
- Sqlcmd command strips $ out of query variable
- Delete rows in parent table based on criteria in child table - Oracle
- Recursive update for Tree structure in pgsql
- Get Results from DMV Query into SQL Server Table
- Color output in PSQL?
- if block fails to create temp table in a procedure
- How to normalize data en-masse?
- Wrong Last Modified Date of .ndf file on SQL Server
- To EAV or not to EAV?
- Cannot shrink transaction log
- Adding a replication article manually & failing to generate new replication sprocs
- Migrating a tablespace to a different database on the same ASM
- Oracle Materialized View Refresh Group - Montly Interval
- In what order does postgresql handle queries which have conflicting locks?
- Partition Function with only one value, what does this effect?
- MySQL gives me:“Can't open and lock privilege tables: Table 'host' is read only”
- Cannot set ArithAbort to Off on SQL Server
- Where can I find the connection string for a DB2 database?
- Assign values with the := operator
- Software for working with SQL Server databases in Windows Server 2008 [closed]
- Moving away from CmdExec steps in job without losing logging detail (SQL Server 2008)
- Meaning of "nonclustered located on primary"
- InnoDB Failure of some kind
- MySQL is running but not working
- Mistake during Oracle 11g PITR
- Can't connect to SQL Server Windows 7
- Empty LONGTEXT or NULL?
- Best embed/reference/field strategy for many inserts (mongo)
Sqlcmd command strips $ out of query variable Posted: 10 Sep 2013 09:02 PM PDT What I am trying to do Restore a database from backup using sqlcmd. Sqlcmd is being called by PowerShell. What is the issue The server folder which contains the database backups has a $ inside of the name. ie Hostname$InstanceName. When I try to restore any databases I get an error and notice it is trying to restore from \\networkshare\Hostname\DatabaseName\Database.bak You'll notice that everything after the $ got stripped out. I believe this is due to sqlcmd's support of variables (-v parameter). I have tried to use the -x parameter (disable variable substitution) with no success. This process works fine with folders that do not have $ inside of their names. Does anyone know what I can try from here? Or see if I'm doing something wrong. Thanks Sample code |
Delete rows in parent table based on criteria in child table - Oracle Posted: 10 Sep 2013 08:04 PM PDT I have a table Here is a SQLFiddle with a sample table structure: http://sqlfiddle.com/#!4/f156c/4/0. My first inclination was to attempt to save the keys by But that just gives an How can I either get around the Oracle version: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod (Yes, I'm well aware of how old that is. Client's choice of DB, not ours.) |
Recursive update for Tree structure in pgsql Posted: 10 Sep 2013 08:01 PM PDT I have the following structure of table.
After added new row in between the rows, this and all the following rows (ChNum) want to be change. Result as follows
Is this possible to use recursive update sql query in Plpgsql and is this best way for faster data update than through application side. |
Get Results from DMV Query into SQL Server Table Posted: 10 Sep 2013 07:08 PM PDT today I began to troubleshoot an issue that I was asked to resolve, and for the first time I found myself querying in the SSAS database. I obtained a very useful set of results (who was connecting to what applications/cubes and for how long), but for the life of me I cannot figure out how to get the results from that query into a database table so that I can track the data. Any help would be much appreciated, and thank you in advance for any assistance you are able to provide. |
Posted: 10 Sep 2013 04:16 PM PDT I'm looking for a way to get I did find this page, http://matlads.blogspot.com/2012/09/tweaking-psql-in-color.html, but its kind of hacky and I would prefer something better. Anyone have suggestions? |
if block fails to create temp table in a procedure Posted: 10 Sep 2013 04:16 PM PDT I'm attempting to do this in a procedure: I get the error: Why is this happening and is there a work around? Update I've attempted to add a |
How to normalize data en-masse? Posted: 10 Sep 2013 08:49 PM PDT Goal:Extract address fields from a users table into a separate addresses table linked by foreign key. I have created the structure below, and have millions of rows to deal with. I need to do this once, but relatively quickly (ie, I can't loop over every row in my Rails code) The query below does work to extract the address fields into new rows in the addresses table. But I can't figure out how to link the new rows back to the users table that the data came out of. Structure:Before: After: What I have so far: PROBLEMI don't know how to get the |
Wrong Last Modified Date of .ndf file on SQL Server Posted: 10 Sep 2013 12:51 PM PDT I have SQL Server Database and we have many tables. To improve performance, I have created different filegroups with files on different disks just for indexes. I have created new index today in a different file group. However, I still see last modified date of file as 1 month in the past. I have checked file names and I am worried that SQL Server is not setting Last Modified date of file. The new index works fine, but the file still does not show me a more recent modified date. Ok I have just learned something new, none of the files in SQL Server's Data directory shows last modified date to recent date while, my database is continuously updated. All dates are 1 month old. The server's system clock is correct. |
Posted: 10 Sep 2013 12:57 PM PDT I am working on an application which records data from different forms. New forms can (and will be) constructed dynamically by an admin. I am wondering what would be the correct way to save this data in a database? My first guess would be to use EVA, but considering all the bad publicity I am a bit hesitant. Let's say I have two forms: There is no way of predicting the number of possible attributes. I am playing around with two ideas, but maybe you'll be able to suggest a much better approach. Idea I: Idea II: Thanks in advance for any suggestions. |
Posted: 10 Sep 2013 08:36 PM PDT Bit of a headscratcher here. I have a db that has less than 1GB of data, but a 40GB log file. Transaction logs are backed up daily, and there is not a lot of activity on this database; approximately once a week it records new payroll information and then regurgitates this data for reporting purposes. The database is set to Auto Shrink. running running ...the discrepancy between the Nothing has changed at this point. The log file is still 40GB. So I think, maybe I have some open transaction. Running Crap. Well maybe my indexes are fragmented. I will defrag them with Still nothing has changed. Ok, how about I reindex with ...and now we get: no change. All right, how about Immediately, this fails with: Huh? It's there, all right. I do a But I am out of ideas. I cannot shrink this thing. What else can I try? Why are my UsedPages so incredibly higher than my EstimatedPages? What is going on here? |
Adding a replication article manually & failing to generate new replication sprocs Posted: 10 Sep 2013 09:02 AM PDT I've got a large number of articles I need to add to a new replication transactional publication in a dynamic fashion, but appear to be running into an error every time I switch replication on. Specifically, the error I'm getting is that the publication is telling me that the replication stored procedures aren't there, despite me telling it to specifically create them. I don't believe this is a security thing as the dev server I'm working on is completely open and basically everyone/everything has sysadmin access. From my investigations, it appears that when I'm running sp_addarticle from a dynamic SQL string within a cursor, even though I've explicitly set the @schema_option to create the replication sprocs, it's failing to do so. For reference, I'm doing things in the following order:
I've had a look through all the options, but I'm honestly starting to get a bit codeblind, so can anyone help me ID why this isn't working? Thanks. |
Migrating a tablespace to a different database on the same ASM Posted: 10 Sep 2013 07:57 AM PDT How might one go about copying or moving tablespaces between databases that uses the same ASM instances? Might it be possible to cut some corners in RMAN or have ASM remap files belonging to a transportable tablespace? |
Oracle Materialized View Refresh Group - Montly Interval Posted: 10 Sep 2013 08:09 AM PDT I have a few Materialized Views that I need to update weekly and monthly. So for the weekly I'm using: How can I do so they refresh monthly, say every 1st of the month at 1 am? Is there something like Interval => sysdate+monthly? |
In what order does postgresql handle queries which have conflicting locks? Posted: 10 Sep 2013 10:53 AM PDT Let's say that I have a long running query Which query will be serviced first? |
Partition Function with only one value, what does this effect? Posted: 10 Sep 2013 09:01 AM PDT I am currently looking at a database that has been setup by the default installation routine of AppFabric. Looking at the creation scripts I encountered this partition function: And it is being applied to a table that way: I wonder what this specific partition style effects in. I was under the impression that you store boundary values into the partition function by which the data will be partitioned. Unfortunately, looking for this on the web I could not find a similar example using just one Can someone shed some light on this for me? |
MySQL gives me:“Can't open and lock privilege tables: Table 'host' is read only” Posted: 10 Sep 2013 08:44 PM PDT I am facing problem restoring a MySQL database. My primary database was MySQL 5.1 and now I am trying to copy it to MySQL 5.5. The database was backed up by using Xtrabackup. I am using Ubuntu 12.04.3 LTS on this server, MySQL version is: I have followed all the steps to restore using Xtrabackup, this created database files, which I have copied to a tmp directory. I have modified Now when I start the MySQL server I get this error:
I have given a try as follows:
Can some please point me in right direction? I am not sure whats wrong with permissions. |
Cannot set ArithAbort to Off on SQL Server Posted: 10 Sep 2013 12:11 PM PDT I have 2 SQL 2012 servers. The settings are exactly the same, but on one I can set ARITHABORT to Off but no matter how I try I can't do the same on the second server. The only difference I could find was that the server I could set it on is an older version of SQL 2012. Has something changed? Or is there something else I'm missing? |
Where can I find the connection string for a DB2 database? Posted: 10 Sep 2013 07:54 AM PDT I need to connect an application to my DB2 database. Both application and db are running on the same machine. I've tried this: I'm getting the following error:
Am I using the wrong connection string? Edit I've also tried the following format: Same result. |
Assign values with the := operator Posted: 10 Sep 2013 02:55 PM PDT When I assign a variable with it is taking more time (approx. 15 sec) to run the function. it takes only 133ms. Why is it taking more time for the first scenario? And what is the reason behind this? Full function is given below. |
Software for working with SQL Server databases in Windows Server 2008 [closed] Posted: 10 Sep 2013 11:15 AM PDT We have an ASP .NET project that uses SQL Server that we host on a Windows Server 2008 machine. Where does Microsoft keeps its documentation for the tools that can be used for administering SQL Server databases? I'm not sure where to start looking for the software to manage our db. |
Moving away from CmdExec steps in job without losing logging detail (SQL Server 2008) Posted: 10 Sep 2013 07:20 PM PDT My department currently relies heavily on CmdExec steps in SQL Server Jobs, called using a SQL Server Login. For example For a lot of reasons (not least security and the expectation that this method will become obsolete) I'd like us to move away from this model and replace with a mixture of stored procedures and SSIS packages. I've proposed this several times and I'm always told that we can only move in this direction if we can recreate the detail of logging possible by the method above, which our department has come to rely on quite heavily. The method above outputs the contents of the script fed in along with any server messages including all rowcounts and error messages, in context. This does admittedly mean that errors that wouldn't count as errors for SQL Server are far more easily picked up - Unexpectedly low row counts etc. You could put in as much error handling as you liked and never get something as easy to follow as the logging from this method, so I can see this side of the argument. To sell my boss on a move away from cmdexec steps I'd like to find a method of recreating something like the output of the logging that cmdexec currently gives us - perhaps to SQL tables rather than files (although either would be fine) - in SSIS packages and stored procedures. I'm familiar with using raiserror for error handling - I use this extensively in stored procedures - but the task here is not just to catch SQL errors, but to catch all that cmdexec logging catches and ideally in context of the script being executed... Short of writing a stored procedure and executing it after every step in every script I can't see a way of doing this. Also I'm keen to hear about best practice approaches to logging for people who don't use cmdexec steps. I've learnt SQL in this department and this is the only way I've ever known of doing things. Increasingly for my own development I try to write stored procs with error handling. And if I come across issues that don't throw errors, I do my troubleshooting by rerunning the code interractively on a dev server so I can monitor the step by step information. This is less convenient than the full logging we get from cmdexec but more secure. Do other people do more than this? Is there a better way? |
Meaning of "nonclustered located on primary" Posted: 10 Sep 2013 05:50 PM PDT When I run
I am more interested in the located on PRIMARY part, What does it mean? |
Posted: 10 Sep 2013 02:20 PM PDT I have MySQL 5.5 installed. I tried to install Joolma but it failed. I went into their sql and replace EGNINE=InnoDB with MyISAM and the install worked. InnoDB is listed under SHOW ENGINES; Any idea what the cause is or how to fix this so other InnoDB sites can be used? I had these errors: |
MySQL is running but not working Posted: 10 Sep 2013 04:20 PM PDT In an attempt to tune MySQL to make it work with a recent installation of Drupal I had to modify the MySQL settings on my server. After modifying the configuration file for MySQL (/etc/my.cnf) MySQL stopped working. After some attempts I make it start again but now all my php/MySQL webistes are not being able to connect to their DBs. Here is why is so confusing:
My websites using MySQL almost all say: Another say: This is my current my.cnf: I commented most of it to return it to its simplest version... How can I make the web side to connect to mysql? |
Mistake during Oracle 11g PITR Posted: 10 Sep 2013 12:20 PM PDT I tried using set time until.. and mis-typed the date. Can anyone help me understand how to get my backups into a manageable state? After the accidental recover, most of my backupset disappeared. I recovered them and used 'catalog recovery area' .. and they're listed in 'list backupset'. But something still isn't right. When I do a PITR now, I get messages that my dbf files aren't available and... the 'list backupset' seems to show backupsets. But they are listed differently than the files which weren't included in the 'bad' recovery. Gists with the error and the list of backupsets are here https://gist.github.com/akinsgre/5561254 |
Can't connect to SQL Server Windows 7 Posted: 10 Sep 2013 10:20 AM PDT TITLE: Connect to ServerCannot connect to localhost. ADDITIONAL INFORMATION: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 2) For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=2&LinkId=20476 I keep getting this error when trying to connect to sql server. I also ran a repair and I got this error. Could this be the problem and do you have any idea how I can repair it. I have looked all over Google and tried quite a few solutions with no luck. I am Using SQL Server 2008 R2 Developer Edition |
Posted: 10 Sep 2013 11:20 AM PDT In my MySQL DB I have one field called When the field is not set or left empty would you say it is better (alias more efficient for the DB) to set it to NULL or to empty string? I read this: When to use NULL and when to use an empty string? but it talks about empty strings in general (probably small strings and not I was wondering if with |
Best embed/reference/field strategy for many inserts (mongo) Posted: 10 Sep 2013 08:20 AM PDT I'm building a gaming backend with Mongo, and have some issues on how to best design the schema to maximize performance and database size. My models: User Match -ReferenceMany (User) -ReferenceMany (Score) Score -ReferenceOne (Match) -ReferenceOne (User) It takes 2 users to start a match. Say we get 10.000 users, and all play one match each day against another user, we get 5000 games a day. Each match has three turns, which gives 6 scores, so for 5000 games we get 30,000 scores. These scores can be inserted simultaneously (in each game), so I have to make sure one user doesn't overwrite another users score. I believe I've solved that by having the scores in their own collection, and embedding them on the match, like so: My issue with this approach though is that it takes 6 queries just to insert a score (there are some validating queries before the above code). With 30.000 scores a day, that's a whole lotta queries. My initial thought was to just add the scores to the match as an array, but what will happen the if two users submit at the exakt same time, updating the same match? I'd be really interested in hearing some opinions on this. Let me know if I need to clarify anything. I'm using Symfony2 with Doctrine ODM if that helps. |
You are subscribed to email updates from Recent Questions - Database Administrators Stack Exchange To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
No comments:
Post a Comment