An acronym for "Structured Query Language" (it's not the name of a specific DBMS product), SQL can be used in relational database management systems (RDBMS) to query, update, delete, and insert data as well as modify the structure of the database. It can also be used to manage schemas and data ...

learn more… | top users | synonyms (1)

0
votes
3answers
454 views

Setting up SQL Server service broker from one database to multiple databases

I would like to set a SQL broker service whereby DatabaseA sends the same data to DatabaseB and DatabaseC. In this case, all databases reside on the same instance. I have looked at the following ...
-3
votes
1answer
6k views

How to get MAX and MIN in GROUP BY query?

In a simple query SELECT col1, col2, col3 FROM table1 GROUP BY col1 each row includes the first value of col2 and col3 for each unique value of col. How to select MAX and MIN for each value of ...
0
votes
2answers
81 views

Understanding multiple indexes with MySQL (and performance)

I have a "phones" table with around 120 000 records, it contains phone_id, phone_number, phone_user_name, phone_last_contacted, etc. The phone_id is index and looks like: 1,2,3,4 ... 120 000. But I ...
-1
votes
2answers
95 views

How do I avoid duplicate rows using FREETEXT?

I have the following query: SELECT cat.CategoryId,cat.CategoryName,cat.CategoryImageURL,cat.CategoryImageData, ap.AppName,ap.AppImageData,ap.AppDetails,ap.AppId FROM Category cat,App ap WHERE ...
0
votes
1answer
45 views

Query Optimization for added value

I have a query that's behaving a bit oddly. In my database I have a table called "records". It tells me a bunch of information about what applications a user ran on my company's machines. I'm ...
0
votes
3answers
1k views

Can I give the same name to a table and a stored procedure?

Is it possible to name a stored procedure the same as a table? I have an existing table named 'buyers', and I'm trying to create a stored procedure named 'buyers', but I'm getting this error: ...
3
votes
1answer
386 views

Restoring database to UNC path on local drive

When I try to restore a database using a restore command with a local UNC path: RESTORE DATABASE [dbname] FROM DISK = N'\\PC91\D\backup.BAK' WITH FILE = 1, MOVE N'test' TO N'\\PC91\D\dbname.MDF', ...
1
vote
1answer
106 views

Suppress repeated performance condition alerts

I have set SQL Server performance condition alert with details as follows: Object : SQL Server:Databases Counter : Percent Log Used Instance : My database name Alert If ...
2
votes
2answers
243 views

How to create Combination of records (Order does not matter, no repetition allowed) in mySQL tables

I've got a table that has hundreds of rows, each row is a recipe with nutritional information, for example: recipe_table: id | calories | protein| carbs | fat recipe1, 100, 20g, 10g, 2g ...
2
votes
1answer
267 views

Grouping over multiple data dimensions (pivot)

I am logging an Events table, and want an output (as seen at the bottom of this answer), the issue is that I am getting the data in rows, but want them to be displayed column-wise. The two dimensions ...
0
votes
1answer
52 views

strange “using where” in simple query

I have a table with this structure: mysql> describe user_groups; +----------+----------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | ...
0
votes
2answers
283 views

How to index for a query with independent range conditions?

What is the best way to index a table that I query using independent range conditions? E.g. WHERE X < ? and Y > ?
6
votes
2answers
198 views

Should I add a column or 1-1 table if property is usualy null

There's a new unique property we need to add, which is relevant only to a specific subset (less than 1%). We thought it's better to add a new table which will be 1-1, than to add a new column which ...
1
vote
2answers
90 views

Sub-query in update function

I have a really terrible set of data that I've inherited and part of my job is going through and cleaning it up to something that's actually usable. Currently, I'm trying to update a column in my ...
1
vote
1answer
75 views

DB Certificates [duplicate]

I hope this is the right place to as this question. I just earned a Bachelor's degree in Management Information Systems and I'm interested in becoming a Database Admin. However, I'm a little confused ...
0
votes
1answer
600 views

How to Drop tables being a SYS user

I am not being able to drop my tables using : drop table <table_name>; command. It says "the table is referencing primary keys of some other tables as foreign keys." , and when I tried to ...
1
vote
2answers
80 views

Read committed snapshot:Finding lock on table

IF update command is run on a table and commit is pending then another user cannot be able to update the table. Is there any query to get the user or PC which caused lock on the table.
1
vote
1answer
127 views

How to link a customer to a country when the city/state isn't known

We have a situation where medical systems are sold to hospital groups, but at the time of the order, we don't always know into which state and city the system will be installed. We always know the ...
0
votes
1answer
354 views

Grouping and counting rows by existence of matching criteria in any of several columns

Disclaimer: I've inherited a database which is probably not quite as "normal" as I would like, and I'm limited to Jet/MS Access 2010 for my db backend and interface, as well my choice of reporting ...
-1
votes
1answer
391 views

how to export postgresql database table into mysql

I am trying to get data from a Postgres database, but I am totally new to using Postgres. I am here to ask my question to get some ideas from the best answer on how can I can do this. If possible, I'd ...
0
votes
1answer
286 views

How to set CHECK_POLICY OFF in the sql script

While installing our software in a HP laptop, we got a SQL error stating "The password does not meet windows policy requirements because it is too short." When I checked, the local security policy in ...
1
vote
1answer
311 views

Distributed - across multiple databases or servers - Transactions

I have some doubts related to transactions in SQL. I perform below steps. Connection 1 open for DB1 database Begin transaction for Connection 1 Run the commands on Connection 1 Connection 2 open for ...
11
votes
7answers
3k views

How to query a database for empty tables

Due to some 'developers' we had working on our system we have had issues with empty tables. We have found that during the transfer to the cloud several tables were copied, but the data in them ...
1
vote
0answers
47 views

A pre-existing hierarchial table as relational

Currently the database contains something like so (these are the main fields but there's a large amount more): +----------+----------------+----------+ | Agency | parent | main_term ...
1
vote
1answer
2k views

Converting ER diagram to tables and relationships in sql

Department : Branch is 1 : M Branch : Course is 1 : M Branch : Student is 1 : M Branch : Applicant is M : N Applicant : Student is 1 : 1 These are the conditions prescribed in the ER diagram. ...
0
votes
3answers
535 views

Indexing for query containing xml column

I have below queries which performs little slow.So i am planning to create index.I created primay xml index and now performance improved little bit(by looking at execution plan) .Queries are shown ...
1
vote
1answer
115 views

How do I get value from parent row

I have two tables. One contains a hierarchical structure of topics and another table that contains optional configuration of that topic, that controls it's visibility in several contexts (one column ...
3
votes
1answer
857 views

PAGELOCK Conversion Deadlock From Update to Intent Exclusive

A customer of ours is experiencing frequent deadlocks. The deadlocks are mostly on the same UPDATE statement. The deadlocks follow a pattern in which both SPIDs have acquired an update (U) lock on a ...
2
votes
2answers
148 views

how to make a particular field into seperate columns?

Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production. I have this table in the below format: No | User | Value 01 | Port | Funds 01 | Vip1 | Systems 02 | Port | Bank ...
2
votes
2answers
54 views

Viewing the SQL of a view from a backup set

I have a full backup of my database from 4 days ago. It is a standard SQL 2008 .bak file. What I'd like to know is if its possible to view the SQL to a View that is in the database I backed up without ...
1
vote
1answer
25 views

MySQL Grouping Error

I'm trying to run a query on a table to see how many unique users have a usage record in the system at a given point. I've been working with the following query, but I've yet to see a proper result. ...
2
votes
1answer
171 views

SQL - I have just Differential backup but database exists

I have Differential backup from my database.one table is deleted.my data is lost.i create that table again but i cannot restore Differential backup because sql wants a full backup first.if i get full ...
3
votes
3answers
553 views

Simple XML .query SELECT statement times out on 1 SQL SERVER instance

I dropped and recreated a stored procedure on a DB on a SQL Server 2012 instance (SERVER1/INSTANCE1), after which the sproc started hanging on a line. Using profiler I have reduced a recreateable ...
0
votes
2answers
210 views

“an agent job has not been created for this subscription”

I have set up merge replication with a publisher on my SQL Server 2008 R2 box with the distributor on this box too; in Express I have created a subscriber but the subscriber won't run because of the ...
2
votes
2answers
129 views

Is there really any benefit in wrapping random ad-hoc queries in a transaction?

I am no db expert, but I was very surprised when someone working at our client's company asked us to send all queries wrapped in a transaction like below: SET TRANSACTION ISOLATION LEVEL READ ...
3
votes
2answers
923 views

SQL Query too slow on SUM function

I've a table with around 32 million rows having clustered unique index on CountryID,RetailerID,ProductID,DateID,EventID,TypeID and query is SELECT f.RetailerID , TypeID ...
0
votes
1answer
449 views

Selecting from an excel spreadsheet into SQL Server table

This question has been asked before but I tried giving full admin rights to the SQL Server user on C:\temp\ folder location (I am using Windows authentication into SQL Server Express). So for the ...
0
votes
3answers
1k views

SQL Server Database grew too much too fast

I have an issue with one database. The issue is as follows: The database is being running on SQL Server 2000 Standard for the last 6 years in Full Recovery mode. In the beginning of this summer the ...
0
votes
1answer
1k views

How to create an Sql table from SELECT with a multiple row DISTINCT constraint?

I want to create a table from a SELECT statement based on a multiple row DISTINCT, but PostgreSQL does not allow me to do it. I need to create a table where the elements were previously selected from ...
2
votes
1answer
125 views

How can I connect to a database after its disk has come back online?

I have problems with database after reconnecting a hard disk: .Net application works with database. Disconnect hard disk with physical files. Make any request to the database (of course we will have ...
6
votes
2answers
2k views

How to optimise T-SQL query using Execution Plan

I have a SQL query that I have spent the past two days trying to optimise using trial-and-error and the execution plan, but to no avail. Please forgive me for doing this but I will post the entire ...
1
vote
1answer
56 views

Make database use more than one file

I have to following problem: since my database runs out of memory in a few days, I am looking for a way how to make the database use more than one file. I would like to store upcoming data in another ...
0
votes
3answers
4k views

How to solve ORA-011033: ORACLE initialization or shutdown in progress

I have followed link to solve the problem. When it is giving ORA-00600: internal error code, arguments: [kcratr1_lostwrt] then I am using: SQL> startup mount the above line should return ...
7
votes
3answers
1k views

Does disconnecting the network stop a query?

I recently executed an update query against 100,000 records. I realized I'd made a mistake while the query was running and quickly unplugged the network cable. Does the update query stop ...
3
votes
3answers
890 views

Select rows after a specific ID

I have the following query, it chooses from a news articles table. Due to multiple sorting factors, I cannot locate the next page of date. The parameter I have is the last ID in the query result set, ...
1
vote
1answer
334 views

postgres+JDBC: fire trigger with non autocommit transaction

i have a jdbc client that make an two INSERT query on database whitout autocommit, and a trigger on database that fires when a insertion is done on a certain table public foo() throws MyException { ...
0
votes
0answers
54 views

How do I get let SQL Server 2005 know that I changed host name in Amazon AWS server?

I am using an Amazon AWS SQL Server 2008 R2 server for dev purposes. In order to follow a new naming convention, we changed the name of the host. I then tried to let SQL Server know about this ...
5
votes
2answers
221 views

SQL Server Tuning a table for massive inserts

I'm trying to solve a performance issue and I need advice. I have a table, which about twice a day has a massive surge of inserts coming in, and exactly at the same time everybody is trying to read ...
0
votes
1answer
100 views

Query to get reposts from people the user is following

I have a table posts where all the posts by users are stored, the structure of this table is as follows. | post_id | post_user | post_content | post_date | The users table is as follows. | user_id ...
5
votes
5answers
3k views

How to select from a table without including repeated column values?

In a previous question How to merge data sets without including redundant rows? I asked about filtering redundant historical data during import, but @DavidSpillett correctly replied that I couldn't do ...