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)

1
vote
0answers
41 views

Handling SQL updates for production deploys

I'm researching for quite a long time now (about two months) and haven't found a good approach for this, so I'll ask you experts out there in the hope of some enlightenment. I run a pretty ...
1
vote
2answers
72 views

TSQL substitute for MAX() string ranking

I have a table with repeating values (col1) and I need to return col2 based on a ranking system. In my example the ranking system is handled by MAX() giving me the highest value. I then return the ...
0
votes
0answers
10 views

SQL Server 2008 R2 - Replication - Multiple Publications on a single database

I have hit a problem and I need an idea of where to look or how to resolve. I have setup a publication and 2 subscriptions to it, 1 running on a schedule and the other running continuously. I need ...
0
votes
0answers
40 views

Thoughts on further optimizations

So I have this application. It runs on a server. There is a portion of the code that is taking around 10-15 seconds to run, it contains some queries, logic, as well as some code to update the ...
1
vote
3answers
84 views

Clustered Index improvemens for particular queries

I found a table that looks like this: CREATE TABLE [dbo].Table1 ( id INT primary key IDENTITY (1, 1), [idUser] INT NOT NULL , [Amount] INT NOT NULL , [Attempts] INT NOT NULL , ...
3
votes
4answers
262 views

Keep track of time intensive stored procedure with prints

I am no database admin nor is my SQL-foo any good (yet), but have a few tasks to get done in MSSQL, and one is a rather time intensive procedure where I fetch from a CURSOR and WHILE @@FETCH_STATUS = ...
1
vote
1answer
27 views

MAX (id) function with MySQli

How can I use the following statement to return only the record with the maximum PersonID from the table? /* Create the prepared statement */ if ($stmt = $mysqli->prepare("SELECT Max(PersonID) AS ...
0
votes
1answer
54 views

how to select first 9 numbers from other table from database using sql query?

I want to fetch first 9 numbers from matching with other column please help me to find out thank you....? SELECT MAINFILE.facno,GLMAST.fglhead FROM MAINFILE INNER JOIN GLMAST ON ...
0
votes
0answers
36 views

Should I create a Factless Fact Table or Denormalise my table

I am creating a data warehouse from a store database and I have a question regarding the design of my dimensions and facts. In the store database a table exists for Person, Person_Address and ...
0
votes
1answer
24 views

MySQL Loop Through Each Row

I have two tables, division & template, in a MySQL database. division - DivisionID - DivisionName template - TemplateID - TemplateName Here is an example of my current data ...
2
votes
1answer
54 views

How to get all logged in users to SQL Server database for this week?

I'm using SQL Server 2008R2 and I setup a testing database that I need to know who tried logging in so far. Is there a stored procedure or a View or anything that I can gather these type of ...
0
votes
1answer
21 views

Drop/Create database and create schemas all in the same script at PostgreSQL it's possible?

I'm working on a project where all the time I need to repeat this tasks: Drop database sis_db Create database sis_db Create database schemas by running a custom SQL file which contains this code: ...
1
vote
2answers
86 views

SQL Backup tuning large databases

I am tuning SQL backups using compression, writing to multiple files, and changing the BufferCount and MaxTransferSize options. I have SQL instance with a 4 TB database and several smaller databases ...
0
votes
0answers
26 views

Paging via Number of Result Record vs COUNT(*)

I have been working on fixing a piece of code for a customer that has been very slow for them. I have made that fix, and thats all lovely, but I noticed something odd in the paging. When the query ...
1
vote
1answer
49 views

Case with multiple conditions

I need to change returned value, from select statement, based on several conditions. I tried something like that: ,CASE i.DocValue WHEN 'F2' AND c.CondCode IN ('ZPR0','ZT10','Z305') THEN c.CondVal ...
1
vote
1answer
33 views

Select statement for selecting every week's log record

Here is a simplified version of the table in question: +------------------------------------------------------+ | DatabaseName | LogRecordNumber | LogTimestamp | ...
0
votes
1answer
45 views

Store the resulting list of a SELECT in a variable to count AND use the result

I have stored procedure that uses a cursor and for every fetch a duplicate SELECT, once to determine the number of IDs found (SELECT COUNT(ID) FROM TableA WHERE something.. @cur_var) and if the ...
0
votes
3answers
67 views

Get latest status of an item in the database

I have this table: ID|Item-FK |timestamp|status ============================= 1 | 123 | ... | OK 2 | 123 | ... | FAILED ... I want to query get all items which last status was FAILED. ...
0
votes
0answers
45 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
90 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
37 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
40 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
114 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
24 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
43 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
54 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
27 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
70 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 ...