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
0answers
44 views

SQL Server : error 15208 Level 16, State 1, Line 1

Trying to Backup a certificate from SQL Server causes this error: Msg 15208, Level 16, State 1, Line 1 The certificate, asymmetric key, or private key file does not exist or has invalid format. ...
1
vote
1answer
84 views

How can I design this database?

So I have a ton of transaction logs in pipe-separated format spread across a few dozen files. Concatenated into one file, it's around 2.4 million lines. Each transaction has a store number and a ...
0
votes
1answer
36 views

Stored proc getting ANSI_NULLS and ANSI_WARNINGS error when executed by application

I have a stored procedure that is getting the following error when executed via an application : Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the ...
1
vote
1answer
39 views

SQLAnywhere: Visualize in real time CPU and RAM consumption of sql connections

I want to keep track of which connection use most of resources. Within Sybase Central (SQL Anywhere 9, 12), for each server and database, we have pane to check in real time All Connected Users and ...
1
vote
1answer
19 views

Adding a “position” number in Mysql

I got the following query and result currently: mysql> SELECT songname,COUNT(*) as count FROM etrstats WHERE songname != '' AND `when` >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY ...
4
votes
2answers
113 views

How to store immutable, unique, ordered, lists?

I have an entity with millions of instances. Each instance has to reference an ordered list of items. The lists have to be unique so no list will be stored more than once. But once created, both lists ...
1
vote
2answers
67 views

Are there any special characters that are never allowed in SQL?

I am a Java programmer. We always make database-related things configurable so that they can be easily modified by the DB team as per their requirements. I want to make some queries as configurable, ...
0
votes
1answer
23 views

Design: Fitting variable hierarchy of text files into a relational db

I have a large data corpus (several TB) made up of data gathered through customer support queries. I've been asked to set up a database to make this data more accessible, but as I'm kind of new to ...
0
votes
1answer
28 views

SQL Server 2012 how to create new schema from existing database selecting only subset of database objects?

I'm looking for a way to create new schema from existing database selecting only subset of database objects. I.e. I want to have some "database representation" which only includes subset of tables ...
1
vote
1answer
41 views

Getting Time Duration

I have a table like below: I want to get time duration for each record which SPEED is greater than 100. I written a function for that, it’s working fine , but my problem was i have millions of ...
0
votes
0answers
23 views

How to CAST a value in PostgreSQL for use in WHERE with LIKE statement? [migrated]

I'm trying to fix a SQL query for later convert it to Doctrine2 DQL since it's part of a Symfony2 project. This is what my DDL has: CREATE TABLE "nomencladores"."norma" ( "id" int4 NOT NULL, ...
-1
votes
1answer
39 views

SQL Server edition support [closed]

Does anyone know whether Microsoft supports SQL Server 2005 Enterprise Edition SP2 anymore? The following is from reported from @@version Microsoft SQL Server 2005 - 9.00.5000.00 (X64) Dec 10 2010 ...
0
votes
1answer
41 views

Insert record only if a combination of column values doesn't exist

I have a simple MYSQL insert query: INSERT INTO table('col1','col2','col3') VALUES('123','456','some text') I want to insert only if the above combination of columns does not already exist and this ...
0
votes
0answers
34 views

Help writing the following query to relational algebra

Can someone help me in writing the following query to relational algebra, I am studying DBMS and I am stuck on this exercise. Query: SELECT a.name, d.name. d.grade FROM student a, enrolled i, class ...
1
vote
1answer
32 views

Matching a value with every element of a set of values - Postgresql

I'm new in Postgres and I can't achieve what I'm trying to do. I have a list of films in a Films table ID_FILM FILM NAME 1 Terminator 2 Forrest Gump 3 Nueve reinas A ...
0
votes
1answer
20 views

Select Ingredients of a product based on unit type

I have three tables UnitType,NutritionMaster, NutritionInProduct UnitTypeID UnitName 1 100ml contains 2 250ml contains NutritionID Name Description 1 Energy NULL 2 ...
-1
votes
3answers
87 views

How to load multiple values in cell from Excel to SQL Server many to many table [closed]

I have values in excel like this. StudentNumber| Subjects 1| english, science, maths 2| maths, biology 3| history, zoology I have Student table in database ...
2
votes
2answers
53 views

Call UPSERT function multiple times to different inputs

I have a function: merge_vehicles(vid, cid, vname, reg_no, name, name_1st) Can i call it multiple times on inputs like (2335, 55, '246BDH', '246BDH', '811', 1), (2336, 55, '038THX', '038THX', ...
0
votes
0answers
25 views

query to pull one row per id when multiple rows of each id exist in table [migrated]

I have a table holding email addresses where some people have more than one email address listed. I want to query the table to only pull a single email address per Individual. Columns are: ID ...
0
votes
1answer
20 views

moving binary database folder is causing issues with innodb tables

so I have a mix of myisam and innodb tables on a database. (its a pretty big db 30gb) I copied the folder of the database from one server to the next /var/lib/mysql/databasename well the myisam tables ...
3
votes
2answers
85 views

Why postgres is using an odd index with no relation to the query

(Debian 7, Postgres 9.3, dedicated machine with huge cache) I have one big table called process_data (14gb) and another tiny lookup table called process_location. I'm doing a query between these two ...
1
vote
0answers
36 views

Increasing 4 vCPUs to 8 vCPUs [closed]

Can anyone share their experience if they encountered any issues trying to provision extra CPUs for SQL Server running on VM ?
0
votes
1answer
26 views

multi-column FKs with NULL values

I understand that in PostgreSQL if there is a multi-column FK from table B to table A and one or more of the FK columns in table B are nullable then the FK is still considered as "honored" for the ...
0
votes
1answer
21 views

MYSQL improve query performance when using OR

I have a very simple MYSQL table with 2 columns and I run this query: SELECT * FROM table WHERE (col1 = '123' AND col2 = '456') OR (col1 = '456' AND col2 = '123') Col1 and ...
1
vote
2answers
27 views

MySQL improve query syntax

I have this simple MySQL query: SELECT * FROM table1 INNER JOIN table2 ON table2.col = table1.id WHERE table1.id = '123' id is the primary key in table1. table2 has composite primary key of two ...
0
votes
1answer
13 views

“No Current Record” when using COUNT() in Access 2010?

Okay, so, I'm trying to get a count of how many customers each service provider has billed for over the last year or two. Our database's data is slightly imperfect, so I'm trying to kludge together a ...
0
votes
0answers
25 views

Crazy SSRS Issue

We are working a data center migration and are to the SSRS boxes and I am having trouble. SSRS is installed on a server alone pointing to the ReportServer and ReportServerTempDB on a different SQL ...
0
votes
1answer
15 views

MySQL - Arrange a table so that it shrinks as much as possible?

I'm a newbie and I have +10 million articles(200 to 1000 words) in a InnoDB table. I use this to select them: SELECT article,title,other_fields from table where id=123; There is no full-text search ...
-1
votes
2answers
50 views

about latest row in sql server

I have table like id name When I inserted new row after that, I want to know which is the latest record in my table .. How to write a query for this ? I don't want to use any primary key or ...
0
votes
1answer
38 views

Oracle Nested Query with Group By and Having Clauses

So here's the question Find the IDs of aircraft which have flown more distance for a destination than the average distance of all flights for that same destination Here is the schema ...
0
votes
1answer
69 views

Stored procedure to compare two columns from different tables and make the insert

I have two tables: Project with fields fld_id (integer), fld_allocated_hours (integer), fld_project_id (integer) Timesheet with columns fld_id (integer), fld_allocated_time (integer), ...
1
vote
0answers
53 views

Optimizing SELECT queries

I'm not very experienced with database query optimization. I've been reading through similar questions here and Postgres tuning articles online, but unfortunately I haven't had any luck. Here's what I ...
0
votes
0answers
20 views

How to insert a row which contains a foreign key in mysql

Here's the original question regarding PostgreSQL. I'd like to know of a similar solution for MySql. The simplest syntax provided in the answer works fine as long as the relevant rows already exist ...
1
vote
0answers
25 views

MySQL not using multicolumn index on self join

I'm trying to optimise a query that performs an inner join with itself. The table size is currently 10GB ~50 million rows. /* Count all occurrences between start and end site id of a given speed ...
0
votes
1answer
20 views

For each record, count records dated earlier in PostgreSQL

I have a table that contains a column year. I need, for each row, calculate the number of entries where the year is less than that in the row. So that the output would look like: col1 | col2 | ...
0
votes
0answers
17 views

How can I import “.sql” file into a new database? (using Python or even IPython)

all! I have a "bakupdb.sql" file which contains tables from a web page (created with Django) and some data (that is inserted into the tables). It's a dump back up data. I don't have anything else - ...
-3
votes
1answer
95 views

Best design to handle multiple query keys [closed]

I am designing a postgresql database for an online card game. I want to provide users with the option to access their play history - users can see log of their games. The data I want to save has the ...
1
vote
1answer
61 views

SQL Server Query performance with window function

We write a query that include unpivot, partition by and order by.Query is: SELECT PersonId ,SalaryDate ,ID ,Type ,SalaryValue ,ROW_NUMBER() OVER ( PARTITION BY PersonId ...
0
votes
1answer
43 views

Steps or evaluation order of the SQL statement

How the SQL statement containing simple statement like Select x From y Where z Having, order by , group by etc. are evaluated.( In which order they are evaluated.?)
0
votes
0answers
16 views

Intermittent MySQL 5.17 issues - extremely slow queries

I am experiencing major issues with intermittent mySQL issues. To give some background the website runs optimally for the majority of the time, however 3-4 times a day queries that should take a split ...
0
votes
1answer
34 views

COUNT() and link between tables

I have some difficulties to make a query. Basically, I have a 3 tables: member, build and up: member --+--- id|... build --+-----------+--- id|member (fk)|... up --+-----------+--------- id|member ...
1
vote
1answer
47 views

How to sort rows to appear alternatively (e.g. A B A B … )?

Suppose I have a column x with values A and B. For example, Row X 1 A 2 A 3 A 4 B 5 B 6 B Now, I want to sort them into this fashion: Row X 1 A 2 B 3 A 4 B 5 A 6 B Of ...
0
votes
1answer
29 views

SSRS Domain Migration

My company is currently going through a data center migration. We are now down to the SQL Servers and this includes SSRS. The bad thing that is going to hit us is the current SSRS server is being ...
0
votes
2answers
112 views

Error Grouping By Multiple Columns using CASE

Is it possible to group by multiple columns in a CASE statement? I get error "Incorrect syntax near ','." in below code... SELECT CASE WHEN Type = 'Test' THEN Description ELSE ...
0
votes
1answer
43 views

In a banking organization, why would account balance be declared as varchar and not decimal?

I worked in two organizations where I found money related columns are defined as VARCHAR data type. I didn't get correct explanation from anyone. As the database team is totally isolated with our ...
0
votes
1answer
26 views

Only Filtered condition gets deleted from index after datatype change using SSMS

In SSMS if I create a filtered index we can see filtered condition in index properties. But if I change column type of a column involved in filtered index using SSMS , then after column type changes ...
0
votes
1answer
43 views

12 hour format time in SQL datatype

I can convert time datatype to 12 hour format using convert etc. But is there any option to save the time in 12 hour format in SQL tables using any settings or property or any other methods?
0
votes
1answer
27 views

Reducing size of datatype involved in index fails where as increasing size work

This question is related to my previous question Database events that will cause deletion of index For example if i create a table like CREATE TABLE dbo.Customers (ID INT IDENTITY(1,1) PRIMARY KEY ...
0
votes
1answer
14 views

How can I Use Access to combine tables of information

I have two tables in access with a common ID number in both. One table has mail to info and the other table has account information. The account information can have multiple listings per ID. The mail ...
5
votes
3answers
443 views

Speed of MySQL query for the most recent 800 entries in chronological order

I have a MySQL database running on an Ubuntu box that pings 250 clients once a minute (24x7). My column names are: ip_address varchar(16), status varchar(7), timestamp datetime Been running it for ...