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)

4
votes
2answers
2k views

Correct way to design a shopping cart websites database

I am in a web applications course. My instructor really didn't like the layout of my database, saying it was incorrect in pretty much every way. Fast forward 2 months when I'm remaking the website in ...
1
vote
3answers
154 views

Check of SQL Server upgrade success

I have performed SQL Server upgrade from 2005 to SQL Server 2008. Is there any tools/possibilities to check, whether the upgrade from SQL Server 2005 to SQL Server 2008 has been accomplished ...
4
votes
2answers
123 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 ...
4
votes
2answers
120 views

SQL Server update and database transfer

In my test network there is a database created with SQL Server 2005. I have to update SQL Server 2005 to SQL Server 2008. The data base should be used with SQL Server 2008. So it is to be moved. What ...
1
vote
1answer
976 views

Sybase SQL Anywhere 12 - Get all indexes which are unique -> ambigious sysindexes error

we are using a Sybase SQL Anywhere 12 db. In the db there are indices, which are unique, but shouldn't be unique. Therefore I search for a quick way to list all tables with unique primary keys. I ...
1
vote
2answers
262 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
185 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 ...
0
votes
2answers
2k views

Use of CASE statement in a MySQL query

I have 3 tables: TASK (id_task (PRIMARY KEY), name) PROJECT (id_project (PRIMARY KEY), name) PROJECT_HAS_TASK (id_project, task_id) PROJECT_HAS_TASK is the (n,m) relation between PROJECT and TASK. ...
2
votes
1answer
130 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 ...
2
votes
2answers
468 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
622 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
216 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
183 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 ...
3
votes
3answers
903 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 ...
3
votes
1answer
370 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. ...
3
votes
2answers
154 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
1answer
150 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, ...
1
vote
2answers
289 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 ...
1
vote
1answer
524 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; ...
5
votes
2answers
197 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
1answer
280 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
218 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 ...
4
votes
1answer
186 views

ERWIN create and use database

Im trying to generate physical database from my logical model using ERWIN 7. All is well in the script that is generated automatically, there is only the problem that the model is created in the ...
1
vote
2answers
93 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 ...
0
votes
2answers
92 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
205 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 ...
2
votes
1answer
216 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; ...
0
votes
0answers
43 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, ...
-3
votes
1answer
65 views

What is Better SQL Server Configuration? [closed]

First think : MDF and LDF separate on raid 1 Second think : All in one raid5.
3
votes
2answers
149 views

How to optimize a log process in MySQL?

In my project, I have about 100.000 users and can't control their behavior. Now, what I would like to do is log their activity in a certain task. Every activity, is one record which includes columns ...
3
votes
2answers
2k 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 ...
2
votes
2answers
144 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 ...
6
votes
2answers
332 views

How can I organize my tables?

My database contains more than 200 tables. When I want to modify or insert a table, I find it difficult to find it among all those tables. Is there any way to collect related tables in a folder ...
6
votes
3answers
560 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 ...
5
votes
2answers
471 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." ...
2
votes
2answers
114 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
281 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` ...
4
votes
1answer
59 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 ...
1
vote
2answers
2k 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 ...
4
votes
1answer
1k 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
3answers
765 views

query processor ran out of internal resources and could not produce a query plan

This is showing up in the logs several times a night. How do I find the query causing the issue? SQL Server 2008 R2 Sp1. Thank you
4
votes
1answer
166 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 ...
3
votes
2answers
231 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 ...
-1
votes
1answer
462 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
2answers
914 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 ...
2
votes
2answers
110 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 ...
0
votes
0answers
234 views

Problem with PIVOT [closed]

I am facing a small issue while using PIVOT table. My problem is as following. I have a single table with the procedures id and their steps and i want all the steps needs to be displayed in 5 column ...
1
vote
1answer
913 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
279 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 ...
2
votes
2answers
277 views

Should I use SQL or NoSQL for this specific design (surveys)?

Building a small web application to create satisfaction surveys with a default list of questions and responses. The application is for a small audience of people (5,000 max) with surveys sent out when ...