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)

3
votes
2answers
163 views

Does the Query cost in Sql Server account for buffering?

If I am comparing 2 queries by checking their relative "Query cost" as a high level indicator of performance, does the buffer status have any effect on the values shown in the execution plan?
4
votes
2answers
160 views

We are running database maintenace with indexing the system, indexing fails due to locking?

We have been trying to do re-indexing in our system, there are users still using the database during the indexing. While doing index for certain tables there is failure of indexing this seems to be ...
1
vote
2answers
390 views

SQL queries break our game! (Back-end server is at capacity)

We have a Facebook game that stores all persistent data in a MySQL database that is running on a large Amazon RDS instance. One of our tables is 2GB in size. If I run any queries on that table that ...
1
vote
2answers
203 views

Can this SQL be made more efficient and combined into one select?

I have the 4 SQL queries below that I combine into one result set at the end. I am guessing that since I am operating on the same tables in each of the SQL sections, there is a cool way to get my ...
2
votes
1answer
173 views

GRANT privileges to table elements

What happens if I GRANT priveleges (for example SELECT) ON a table TO some group role? What privileges will the table's elements have in this case: indexes, sequences, columns? Should I explicitly ...
0
votes
2answers
102 views

MySQL query optimisation advice for search query

We are currently in the process of trying to re-write a very large and nasty dynamic search query. The search term for this query was 'red christmas napkins' and these 3 keywords have been added to ...
2
votes
2answers
941 views

how to get avg() size by day using two decimal places

does this simple query result in grouping the attachments by day and giving me the total number of daily attachments as well as the average size? the only table i am querying is attachmentdetail ...
1
vote
1answer
1k views

MySQL error in where clause : Unknown column

When I try to execute the query below, I receive the error message: Unknown column 'have_discount' in 'where clause' My query is: SELECT DISTINCT(MP.item_id), item_title, item_user_id, ...
5
votes
1answer
341 views

How does SQL Server order results when joins are used?

How does SQL Server figure out the order of the records in the result set of query execution? I am trying to make heads or tails of it but find myself scratching my head. When I change the fields I ...
2
votes
1answer
243 views

Create Enumerated Function Parameter Type

I want to create a function similar to DATEDIFF in MS SQL Server 2008 R2. The first parameter in DATEDIFF is a datepart. Can I use datepart as a parameter in my function? If not, how do I create a ...
5
votes
2answers
497 views

Resolving DUPLICATE for a column with UNIQUE

I have a few column with UNIQUE INDEX. In some queries, duplicates should be acceptable, in which a postfix should be added to the value. For example, if test title exits, we change it to test ...
3
votes
3answers
2k views

Update field with new string made from characters in existing value

field is meta_value and current value is like 01/01/2006 i want to change it to a string 20060101 so thought i could get the value and update it with the characters in the correct order. ie UPDATE ...
2
votes
2answers
1k views

SQL Server 2008 R2 DDL Trigger to create DML Triggers on all new user tables

As the title says I would like to create a DDL trigger which in turn creates DML triggers for most new tables. The trigger I have so far will create triggers on ALL tables, which is not what I'm ...
4
votes
1answer
233 views

How should I model a worflow of status/activities ? (rules like “if is 3 go to 4, if is 4 go to 5” etc)

I'm trying to model a workflow (status and activities) to create "rules". Let me give you an example. The main "object" let's say are "vehicle requirements", I will have this table: idRequirement, ...
3
votes
1answer
550 views

Will one nvarchar column affect query performance?

I have one column that I recently converted to nvarchar(100) to store Asian characters. The other columns in this table, and the other tables in the same database, use varchar, int, bit and datetime. ...
0
votes
1answer
400 views

Average, between specific date/time, of the difference between current field and previous field

Im trying to calc the average, between a specific date/time, of the difference between the current field and the previous field. At present ive got a query which displays this but im unsure how i can ...
1
vote
2answers
645 views

Derby/SQL - How to increase performance when left joining and retrieving varchar columns

Through trial and error I found that if I do a left join such as: SELECT firsttable.id, secondtable.id, secondtable.varcharColumn FROM firsttable LEFT JOIN secondtable ON ...
3
votes
2answers
5k views

command or query to ping SQL server

I have 2 windows 7 machines on a very high security domain one acting as a server, the other as a client. Each box has a SQL Server Express 2005 database and application "A", however I'm only using ...
1
vote
1answer
827 views

How to write signal function in MySQL that can be called from Triggers and Stored Functions?

In my Database I have a table: Employee with recursive association, an employee can be boss of other employee. The Table Description: mysql> DESC Employee; ...
3
votes
1answer
80 views

linking databases for reporting

I am attempting to design a simple reporting feature for some financial market data. I have a few sets of data, and I am trying to figure out what will be the best way to organize the tables, in ...
3
votes
1answer
414 views

Complex SQL Query

I'm trying to formulate a single query to return a nice list of a host's interfaces and the interfaces attributes from the Cacti MySQL DB. Here are the tables I am referencing: host_snmp_cache: ...
5
votes
2answers
323 views

Running queries against multiple servers

I want to use a Central Management Server, with a server group underneith, to run management queries against multiple server. I know how to run a query against the whole group through SSMS, but I ...
1
vote
2answers
96 views

Special Oracle Order

I have a table (emp) with two columns in ORACLE: COMPANY OFFICE EMP ------------------------ 9999 00001 emp1 9999 00001 emp2 9999 00002 emp3 9999 00002 emp4 ...
3
votes
1answer
127 views

Help to create indexes to improve query performance and reduce report generation time

The database in SQL Server 2008 has these tables below - the main table being the Master: Master A_ID (PK) SYSSerialNumber Bootlog SequenceNumber FileName Cfg Unique(serialnumber,sequencenumber) ...
-3
votes
1answer
71 views

What is Better SQL Server Configuration? [closed]

First think : MDF and LDF separate on raid 1 Second think : All in one raid5.
-1
votes
1answer
1k views

Connecting to database using Toad in windows

I am trying to connect to a database using Toad on windows 7. But I am not able to connect because I dont have SQLNET Editor, TNSNames Editor and LDAP Editor installed. Please help me with this. I ...
2
votes
1answer
339 views

Restriction on self referencing on insert in MYSQL?

How to restrict insert on adding self referencing rows in a recursive relation table (a table contains foreign key points itself). mysql> SELECT * FROM Employee; ...
2
votes
2answers
273 views

Invalid data types in restore headeronly resultset

I'm trying to write a SQL Server script to iterate through .bak files in a directory and then restore them to our server. In doing so, I've created three temp tables: #Files to keep track of the ...
0
votes
0answers
45 views

mysql select query optimization [duplicate]

Possible Duplicate: mysql select query optimization I have two tables, testa and testb. CREATE TABLE `testa` ( `id` INT(10) NOT NULL AUTO_INCREMENT, `name` VARCHAR(50) DEFAULT NULL, ...
6
votes
3answers
1k views

Is it possible to see the (completed) SQL Statements executed by a specific session?

Is it possible to see a list of all past SQL statements executed by a specific session (or number of sessions)? For example, the following query gives me all currently executing statements from all ...
2
votes
2answers
171 views

Is it always bad to use SELECT * FROM?

It is widely recommended NOT to use SELECT *. I understand this, as it is not a good idea to bring the entire row into memory, when only a few cells are needed. Is it still bad to use SELECT * when ...
2
votes
2answers
137 views

Sql Server memory issue

As soon as i start SQL Server with no application querying ,in the task manager it starts to consume memory very fast till it consumes around 15GB. Can any one tell me how to resolve this issue. ...
3
votes
1answer
432 views

How to Update same table on deletion in MYSQL?

In my Database I have a table: Employee with recursive association, an employee can be boss of other employee. Following is query I used to create table: CREATE TABLE IF NOT EXISTS `Employee` ...
5
votes
2answers
804 views

One Complex Stored Procedure Causes Estimated Cost Exception

In SQL Server, I'm getting the following error "The query has been canceled because the estimated cost of this query (5822) exceeds the configured threshold of 300. Contact the system administrator." ...
4
votes
1answer
76 views

Selecting Without Repititions

I have table with observations of objects moving along edges in a graph, this table has the following form: PK | TIMESTAMP | object_id | from_id | to_id where object_id is the id of some object and ...
4
votes
1answer
2k views

Best way to increase no of partition in SQL Server Table

I am maintaining a database with a big big table, which portioned for each month. There is already tens of partition there but its till January 2013, So its time to create new partitions. Can anyone ...
2
votes
2answers
6k views

Error on SELECT - Primary filegroup is full

A SQL Server 2008 R2 database view unions several transaction table. The query has been slow over the couple of months and the dev team is planning to recreate the query. I need to ETL the results ...
2
votes
5answers
301 views

How define select, if bridge pair may have 3 players?

Normaly a pair has 2 players, but if there is an odd number of players at the club, one 'pair' has 3 players. Table, members: pair, player_id 1 1 1 2 2 3 2 4 3 5 3 6 4 7 4 8 5 9 5 10 6 11 6 12 6 ...
4
votes
1answer
198 views

250 billion rows - computing interconnectedness on a really huge scale

I have a table of approximately 700k rows, each identified by a unique itemnumber. Each row/item can be associated with any of the other rows/items in the table by calculating a single numerical ...
5
votes
2answers
471 views

Introducing an 'age' category in a patients database

I want to do the following in my DB related to patients: when patient inserts his birthday it shows his age category as: infants, children, adult, elderly... etc. to help me classify my patients how ...
3
votes
2answers
303 views

Backup SQL DataBase to C$

Another simple SQL backup question from me.... I've got a SQL Server database running on SSMS 2008 and am trying to configure some backup jobs. I am now seemingly fine with backing up and restoring ...
2
votes
2answers
114 views

HELP with SQL WHERE syntax

I have to pull out a range of entries of a database, all based around two pieces of data. In itself thats fine. An example of the data is: Record ID Tags 1 1423 Day, Sun, Warm 2 ...
1
vote
1answer
598 views

How to alter primary key constraint for 2 columns in same table in SQL Server?

In SQL Server, I already created a table called tblDatabase with some columns. I want to add a primary key on the two columns DatabaseName and Servername. I tried to add: ALTER TABLE tblDatabase ...
1
vote
1answer
1k views

How to model entities in an entity relationship diagram?

I'm a beginner Database designer and wondering if anyone can help me understand this. Let's say we want to design a system that has, among other entities, an entity called Vehicle, and another one ...
1
vote
1answer
795 views

SQL query to get the syntax of an existing table

Is there any SQL query to get the syntax of an existing table in my MySql database? Intent: Iam in the early stages of working with databases and I am using the MySql workbench for creating tables ...
11
votes
4answers
3k views

Is it possible to increase query performance on a narrow table with millions of rows?

I have a query that is currently taking an average of 2500ms to complete. My table is very narrow, but there are 44 million rows. What options do I have to improve performance, or is this as good as ...
0
votes
1answer
112 views

Oracle scheduler max_jobs_Slave_processes is set to null, how many will be allocated?

Executing the following query against my database: select value from dba_scheduler_global_attribute where attribute_name='MAX_JOB_SLAVE_PROCESSES'; yields a value of NULL. My question is what ...
6
votes
3answers
1k views

Query performance degrades with time and use

I have been fighting a problem for several weeks now where the performance of my SQL Server queries degrade over a few days of use. In addition every few days, a query will simply not return from my ...
2
votes
1answer
212 views

SQL ISO Standard for group concatenation

Is there an operator in the latest standard SQL:2011 (or earlier) that will handle group concatenation the likes of which we currently have to resort to these tricks for? GROUP_CONCAT in MySQL FOR ...
4
votes
2answers
409 views

MySQL check duplicate with group by using wildcard?

+----+--------------+-----+-----------+----------+ | ID | NAME | AGE | ADDRESS | SALARY | +----+--------------+-----+-----------+----------+ | 1 | Ramesh Olive | 32 | ...