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
1answer
41 views

Help with SQLPSX output for replication

I am using the CodePlex project SQL Server PowerShell Extensions (SQLPSX) to generate script files for replication. Everything is working as I want except for one thing. I have looked through the ...
0
votes
2answers
37 views

DMV queries for capturing most frequently used queries and worst performing queries [closed]

Can anyone provide dmv query to achieve the following Query to capture frequently used stored procedure Query to capture frequently used ad-hoc queries Query to capture worst performing stored ...
1
vote
2answers
34 views

SQL Booleans vs ManyToMany

As I understand it, one way to 'abstract' a parent/child relationship in SQL would be to have a table set up with a joining foreign key table. Ie in this case, the swimsets are children of different ...
1
vote
1answer
50 views

How does the transactions interact if you set a different isolation level per connection?

I read that I can have different isolation levels per connection and in the server. The default isolation level is REPEATABLE-READ. So if I have a transaction that issues a SERIALIZED to the client ...
1
vote
2answers
53 views

Transaction basics. What is the result of 2 transactions running concurrently?

I have a rather basic question on transactions. Assume a table Account with a column amount. Now we have the following code: BEGIN $amount = SELECT amount FROM ACCOUNT WHERE id = 123; $amount = ...
1
vote
0answers
23 views

Will installing WebMatrix (and Consequently SQL Server CE) Break My Current Installation of SQL Server 2005?

We have a server that has (and needs to keep) SQL Server 2005. We are hosting intranet sites on one server (server 1), but have a database on another server (server 2). One of these sites uses AJAX ...
0
votes
1answer
49 views

Comparing execution plans [closed]

How does the optimizer compare different execution plans of the same query? Let's say we have two complex and structurally different execution plans, how can I know if they are providing the same ...
4
votes
1answer
83 views

Order by distance

If I have a query returning nearby cafes: SELECT * FROM cafes c WHERE ( ST_DWithin( ST_GeographyFromText( 'SRID=4326;POINT(' || c.longitude || ' ' || c.latitude || ')' ), ...
0
votes
1answer
39 views

Ms Access SQL problem

in this table Customer is actually storing CUSID (i have pleased the caption customer and made it display the name to which the CUSID corresponds to) now in the CUSnum field i want it to ...
2
votes
2answers
73 views

SELECT DISTINCT with another table

I want to use distinct to display my data. But I don't know how to do it.This is my code.I want to display table gtest_version field max(poly_version) select distinct on (rule_name) ...
1
vote
1answer
27 views

Methods for identifying differences in accumulating history table?

This question will probably be elementary to most DBAs. I'm doing light DB work which isn't my specialty and I'd like to create some kind of "change log" for a table that is copy/appended to a ...
0
votes
0answers
106 views

SQL Timeout to Principle Server Error

I am seeing a timeout to the Pricincipel SQL server (2008 R2) The exact error I am seeing is this: Timeout expired. The timeout period elapsed prior to completion of the operation or the server ...
0
votes
1answer
42 views

How to retrieve whether database has any tables?

Knowing to use SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE' to query for a list of tables, I'm currently finding no way to retrieve a list of non-system tables only. I.e. ...
0
votes
1answer
42 views

How can I get the latest five scores per user per subject?

There is a Postgres table in our system called "scores" which records test scores. It has test takers (users of our system), scores from 0-10, depts and dates each time a test was taken, like this: ...
0
votes
0answers
58 views

I'm trying to run an oracle database in virtual box under oracle linux

I'm trying to run a oracle DB in VirtualBox and access it from my host mac OSX , i am using port forwarding to access my guest, I can telnet my guest on the port, however when i try to connect from ...
0
votes
1answer
43 views

SQL tables relations

i'm making a MySQL data base , my tables are: users, activitylog, activitytype. to avoid repetitions i thought about including activitytype in each activity which is logged into activitylog table, ...
0
votes
1answer
64 views

How different clauses treat Null/Unknow in SQL Server 2012?

(relatively new to SQL and SQL Server) I am reading SQL Server 2012 T-SQL Fundamentals by Itzik Ben-Gan. Autor states that: SQL has different treatments for UNKNOWN in different language ...
0
votes
1answer
36 views

how service sid operate under the covers?

This question is out of curiosity and it left me in confusion whether service account as any role to play in sql server startup and shutdown? Can anybody explain how sql server 2008 Service Sids work ...
0
votes
0answers
24 views

How to generate TPC_DS queries for Oracle?

I have downloaded the DSGEN tool from the TPC-DS web site and already generated the tables and loaded the data into Oracle XE. I am using the following command to generate the SQL statements: ...
0
votes
1answer
55 views

advantages and disadvantages of using direct sql querying in application [closed]

could people please give their opinion on and give advantages and disadvantages on the use of sql queries directly within an application as opposed to creating procedures or functions within the ...
0
votes
1answer
17 views

Nesting inner to sum inner query's result

Suppose I have a query select a,b from xyz The result would be: a        b m1     10 m2     20 m3     30 Can I somehow ...
1
vote
2answers
53 views

Filter by value or show all if no value

I have 2 tables: records and access_rights Access table has list of permission for certain and should be used to filter records based on rules: function field is mandatory object field is ...
0
votes
1answer
43 views

MySQL DB structure with Main category and several nested sub categories

I am looking to create a set of fields on my webpage identical to what eBay uses on their category selection page when you are selling something. For my purposes I am doing motorcycles, power sports, ...
3
votes
2answers
103 views

select all rows with a minimum value

In Sqlite 3 I'm trying to figure out how to select rows based on a minimum value. I think that I'm limited by not knowing enough of the related terminology to effectively search google. The table ...
10
votes
3answers
382 views

Can IS DISTINCT FROM be combined with ANY or ALL somehow?

Is a postgres way of combining IS DISTINCT FROM with ANY or some other neat way of getting the same result? select count(*) from (select 'A' foo union all select 'Z' union all select null) z where ...
0
votes
1answer
63 views

Beginner table design

I have been coding in C# for a couple of years where I usually try to follow the 'single responsibility principle' which states that each class should ideally be responsible for only 1 goal. Now I ...
1
vote
0answers
120 views

Empty Space in buffer pool

I was doing some reading and came across this article from Paul Randal: http://www.sqlskills.com/blogs/paul/performance-issues-from-wasted-buffer-pool-memory/ Using the queries from that article, I ...
2
votes
2answers
168 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
63 views

PLS-00049 bad bind variable when compiling a trigger

I'm trying to implement a dedupe trigger to a table. CREATE OR REPLACE TRIGGER USER.TBL_ACTION_DEDUP BEFORE INSERT ON USER.ERRORTABLE REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW BEGIN IF ...
0
votes
0answers
84 views

SQL Server 2008 single-line PIVOT/UNPIVOT combo

I have a request to get information from a table with a stored procedure that shows all the necessary data for in one line. This table includes a hierarchyID, so I am trying to use the HID methods in ...
2
votes
1answer
129 views

What is the difference between MySQL and PostgreSQL in terms of writing SQL queries? [closed]

Other than performance and security is there really any difference between MySQL and Postgres like SQL queries, built-in functions, procedures and so on? I'm asking this because I'm familiar with PHP ...
0
votes
0answers
38 views
0
votes
1answer
30 views

Why does Oracle store time in DATE column?

I have a table with a date column. I used JDBC to save a java.util.Date object into the table. When I run following query I get date aswell as a time value: select To_CHAR(departure_date,'DD-MM-YYYY ...
1
vote
2answers
43 views

MySQL: Is it possible to order a query by a specific letter using ORDER BY?

What I'd like to do is order my query so that the results show every row found, but are ordered by showing results that begin with the letter 'D' first. Is this something that is possible to do with ...
8
votes
3answers
209 views

When a previously-fast SQL query starts running slow, where do I look to find the source of the issue?

Background I have a query running against SQL Server 2008 R2 that joins and/or left-joins about 12 different "tables". The database is fairly large with many tables over 50 million rows and about 300 ...
2
votes
1answer
100 views

Oracle Standby Database Techniques for faster application of redo logs

I am quite new with the concept of standby databases in Oracle and I am not really a DBA, so help me out. I have been reading a bit on the concept of Oracle standby databases and I am pretty much ...
7
votes
1answer
102 views

Deleting large amounts (4 million rows) of mysql data efficiently, on a very regular basis

We have a mysql table that at any given time has about 12 million rows. We need to delete old data to keep the size of the table somewhat manageable. Right now we are running this query daily, at ...
1
vote
1answer
44 views

complex update query postgres

I've got a bunch of ids from table messages and I want to update the table activities. This is how I imagined my query would work (so you get better idea what I'm trying to accomplish): update ...
2
votes
1answer
28 views

DB2 SUM / INNER JOIN question

I have a query that is the following: SELECT CMSTKY AS Customer, CMNAME AS BusinessName, WKMDL# As Model WKSLD# AS Sales FROM GPCMP INNER JOIN GPCM1P ON GPCMP.CMSTKY = ...
0
votes
2answers
117 views

Recommendations for a SQL Server 2014 Database Administrators Course [closed]

I am after some personal recommendations for a SQL Server 2012 Database Administrators Course with exams. Exam 70-461: Querying Microsoft SQL Server 2014 Exam 70-462: Administering Microsoft SQL ...
1
vote
1answer
191 views

Can I rely on this SQL shortcut to save a query?

Consider a table with a status field that holds one of two values: | status | set('active','default') | YES | | active | I need to know how many records are in the table, and additionally how ...
0
votes
1answer
46 views

rownum won't return records above 100

I have this query: SELECT * FROM ( SELECT v.*, ROWNUM recnum FROM ( SELECT hostaddress, modulename, severity, escalation, classification, ...
0
votes
1answer
32 views

Query causing Database lock problem (php/Mysql) [closed]

hi friends can anyone tell me what is the issue with my query. when i execute, it lock the Database for 5 to 10 minutes, please help me to optimize this query . SELECT u.username, ...
0
votes
1answer
54 views

Recommendations for how I should create my table based on data given?

I'm asking this as I'm kinda overwhelmed by the data presented to me (I'm still fairly new in programming and SQL). Basically I need to create a database to store warehouse equipment information, and ...
11
votes
1answer
507 views

GO After every T-SQL statement

What is the reasoning behind using the GO statement after every SQL statement? I understand that GO signals the end of batch and/or allows the reputation of statements but what advantage does it have ...
0
votes
0answers
21 views

How can I number my groups using an Access “Find Duplicates” Query?

I have a query created by the MS Access 2010 find duplicates wizard. It is: SELECT * FROM fbExpenses WHERE [expense_date] In (SELECT [expense_date] FROM [fbExpenses] As ...
4
votes
2answers
114 views

Order of columns in a compound index in PostgreSQL (and query order)

I have a table with 50K rows. It is actually a PostGIS table. The query has 4 parts (1 mandatory) (3 Optional) intersection box (a geography rectangle) with 4 lat,long (I use st_intersects) ...
2
votes
2answers
60 views

SQL Server - Recursive “find all FK connections for ID through the entire DB” query

I'm dealing with a DB with hundreds of tables, with interconnecting FK references producing potentially thousands of different permutations for how for example table A and table K can join together. ...
0
votes
1answer
23 views

Select cleaned Adress Data in an Database

I have 80.000.000 Entries about Persons. They are built up like: Max;Mustermann;Examplestreet;50;9900;City 88000 is one ZIP Code, 8800 Zip Codes exist. I want to find out the entry based on ...
0
votes
1answer
23 views

Check whether MySQL Innodb Rows are compressed

After setting the various variables to enable compression on the Innodb Barracuda tables, what query will you use to check that those tables are indeed compressed?