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)

2
votes
0answers
9 views

SELECTs in Database Change Log and Source Control

We are overhauling the way that we store our database in source control and keep a change log of it. I was reading the following article: http://thedailywtf.com/articles/Database-Changes-Done-Right, ...
0
votes
1answer
7 views

Creating Triggers to insert into a table where the table is altered by other application

I have a database in my local machine which is actually updated by an online application. I want to create triggers for a particular table ( say table1) such that it inserts values (From Table1) ...
-1
votes
1answer
17 views

MySQL Multi Count

How can i get this result? ╔═════════╦═══════╦═══════╗ ║ EventID ║ User1 ║ User2 ║ ╠═════════╬═══════╬═══════╣ ║ 1 ║ 1 ║ 2 ║ ║ 2 ║ 2 ║ 3 ║ ║ 3 ║ 3 ║ 1 ║ ...
0
votes
0answers
18 views

How to import data to a table with 14 columns via BCP if my data file has less than 13 delimiters? [on hold]

Sorry for the extremely awkward wording in that question. I'll explain. I have a table with 14 columns in which i'm trying to import data to via BCP. My data comes from a text file. This text file is ...
1
vote
1answer
27 views

Help with indexing narrow table with many millions of rows

I have a good amount of experience with SQL Server, but not much with Indexes and I fear I'm a little bit out of my depth in trying to figure out how to correctly structure a table that has 100+ ...
0
votes
0answers
5 views

Simple way to migrate application SQL database into an archive database?

I'm not super technically oriented. I've used SQL for many years, but primarily operating within databases and not so much managing them in total. Anyway, we have an application we're getting rid of, ...
0
votes
0answers
17 views

Elasticsearch missing nested data

I'm trying to set up my river with nested data, however I'm facing some issues. My _river query looks like this: { "type" : "jdbc", "jdbc" : { "driver" : ...
1
vote
1answer
6 views

Mysql update adding subquery field value to field

I want to update a field adding it the value of a subquery field. I'm trying this: UPDATE table a SET a.field=(a.field+b.subfield) INNER JOIN (SELECT subid, subfield FROM subtable WHERE ..... ) AS ...
1
vote
0answers
16 views

Veryfing integrity of custom order column with pure SQL

I have two tables, one stores structure (using so called parent field), the other entities that can be embeded into that structure. As certain level of structure can contain both entities and deeper ...
1
vote
1answer
26 views

need to replace the blank value as 0

need to replace the blank column into 0 for example the table is i have tried this query to bring the output but it is taking more number of time because i have put this table in to procedure ...
1
vote
1answer
18 views

at least one member of a list within another list when querying over a join

assume the current layout in a Mysql datbase Activity (id,etc) [id is primary key] AcitivityMapper (activityID, targetYearID) [composite key] Years (targetYearID, targetYearName) [id primary key, ...
3
votes
1answer
135 views

Get list of characters in column

I have a database table (UTF-8) with a lot of names in different languages with lots of special characters. In another script I use these names and one part is to replace the special characters. To ...
0
votes
0answers
13 views

multi aggregated sql query functions

I have the following query: SELECT u.username, t.pack_id, COUNT( t.id ) transaction_count FROM `transaction` t INNER JOIN `user` u ON t.customer_id = u.id GROUP BY ( t.customer_id ) HAVING ...
0
votes
1answer
16 views

Dump all binary fileds in a table as files

I have a table in a postgresql database with a column of type bytea. I want to drop each binary entry as a file using the id as filename. What would a SQL query look like for this?
0
votes
0answers
13 views

How to design a demographics database?

I have a bunch of stores. Each store has the same properties (ethnicity, marital status, income, and so on). Each of those properties has subproperties like (white, black, asian for ethnicity and ...
0
votes
0answers
5 views

How to split a large table in Teradata

I'm trying to load data from a very large table (200 million rows) into a Presentation Datamart (PDM) for an Enterprise Data Warehouse using Teradata 14.10. I want to split this large table into ...
0
votes
0answers
16 views

preventing FullTextSearch from using wildcards

I am using FTS in a sql2008 sql server and had a user complain about some searches breaking. after root cause analysis we found only searches like U.S.A. fail because FTS tries to run wildcard matches ...
0
votes
1answer
36 views

SQL Server - Error 3202 during Restore

While attempting to restore a 4 TB MDF/data database with a 1.8 TB LDF/log file, I'm receiving the following error: Write on '???' failed: 1117 (The request could not be performed because of an I/O ...
0
votes
1answer
30 views

Move/Copy unique entries only from TableA to TableB, if it's not in the destination table

I'm required to move every unique entry from TableA to TableB, it the unique entry from TableA is not already in TableB. Both tables look the same, they don't have any keys, but the combination of to ...
0
votes
3answers
47 views

Duplicate values

Here is my table : PlayerId NoOfTeams 1 3 2 2 3 2 4 NULL 5 NULL I want to display PlayerID having same No.OfTeams including NULL values. Could any one please ...
0
votes
0answers
28 views

SQL Query to get the Sales Qty of the Item and the its Returned Quantity for past 6 Months

I want retrieve the Sales Qty and return qty of the Items in the following format for the past six months. From two different tables,I TxnInvoice Table :Invoice header TxnInvoiceLine Table :Invoice ...
1
vote
0answers
38 views

How to recover Database System MDF and Ldf files and transaction ldf lifes [on hold]

Here is something as new to DBA i had to face that put me in a fix. There was an encryption activity that was scheduled to happen on System and User DB Data files in Drive: x as well as Transction log ...
-1
votes
0answers
47 views

Stored procedure generating duplicate rows

I believe I have a logical error, poor coding or both in the handling the selection of user emails based on their User.ID and a replaceable config value of Mail+1234@domain.com where 1234 is the ...
0
votes
1answer
14 views

Select all results from two independent tables

I have two tables: Comments -------- id comment_content time_stamp Activities ----------- id activity_content time_stamp And I would like to combine the results from both, ordered by their ...
-3
votes
0answers
21 views

Clearing log files

How to clear/Shrink the Log file of a database when the database is in stand by mode. How to make a database from recovery mode(normal mode/with recovery) to standby mode.
1
vote
2answers
39 views

Delete duplicates with specific columns as identifier

I'm required to delete all duplicate entries of a table. The duplicates are identified by two non-key values num (int) and com (varbinary(512)).. My amateur-ish SQLfoo lead me to this non-functioning ...
0
votes
1answer
48 views

What is my database name?

I'm trying to connect to a microsoft SQL database but I dont know its name. I suspect it will be something of the form servername\databasename It would be good if I could just use SELECT ...
1
vote
0answers
20 views

Clustered Column store table Delete error

I am getting the below error when we tried to delete records on clustered column store table using OPENDATASOURCE. DELETE TOP (1) OPENDATASOURCE('SQLNCLI','Data Source=Server Name;Integrated ...
3
votes
3answers
76 views

How long to learn PostgreSQL?

I want to learn PostgreSQL and How to make the learning process efficient, but really don't know how long it would take even after googling my question. I used MySQL before and knew relational ...
0
votes
2answers
41 views

SQL Query: Selecting a person who is a member of all existing groups

I'm tinkering around with my very first SQL queries and am completely baffled by a problem I encountered. Let's say I have the following database: PERSON(PID, Name) MEMBER(PID, GroupID) How would ...
1
vote
0answers
86 views
+100

How to recursively find gaps where 90 days passed, between rows

This is a kind of trivial task in my C# homeworld, but I don't yet make it in SQL and would prefer to solve it set-based (without cursors). A resultset should come from a query like this. SELECT ...
0
votes
0answers
26 views

Continuously copying an SQLite table

I have a SQLite database associated with an online application (Skype) on my computer, which is often changed by that application when I am using Internet. These are the columns of the database: ...
0
votes
3answers
37 views

SQL MAX function

Suppose I have a table with attributes Name, Age as follows: MyTable (Name, Age) Now, to get the oldest age I can write the following query: SELECT MAX(Age) AS "Oldest Age" FROM MyTable; ...
1
vote
0answers
15 views

reports on history table

Assume Trucks which travel between Cityies. I store the Cityies that a Truck has traveled to in TruckLocationHistory table, if the Truck is passing the City, State = Passed and if it gonna stays for ...
0
votes
1answer
13 views

check numeric column for empty cells

How can I check for a numeric column for empty values I want something like this: select * from table where column_numeric = '' This does not works obviously, but what can be the equivalent of ...
-1
votes
1answer
33 views

how to select from two tables [on hold]

how to select data from two table like this table 1 ---------------------------------------------------------------- proid | uid | problem | prostatus ...
0
votes
1answer
36 views

self referencing tables with SQL and entity framework

I have many tables in a database and the tables are nearly identical. There are limitations currently on what objects reference other objects. For example I have company,contact and project. Contact ...
-3
votes
0answers
39 views

How do I show all records related to a user? [on hold]

I have a table in which a few records are stored, among others CSR and user. What would be the correct way to get all records where user's value = test? My SQL file: -- phpMyAdmin SQL Dump -- ...
-2
votes
2answers
52 views

What's wrong with my SQL statement? [on hold]

I'm trying to execute: create table `certificates`( `id` INT NOT NULL AUTO_INCREMENT, `common_name` VARCHAR(100) NOT NULL, `csr` LONGTEXT NOT NULL, `type` VARCHAR(100) NOT NULL, `certificate` ...
0
votes
2answers
41 views

Summarizing Pay Checks Based on Employee's Job Code

What I'm trying to do is summarize an employee's earnings for each job code they worked in for the year. Employees are assigned a job code based on an effective date. I'm trying to line up the job ...
0
votes
1answer
38 views

Database Normal Form (financial statement)

I would like some advice on how to design the database for financial statement data which objectively addresses the tradeoffs between usability, performance, maintenance and adherence to normal form. ...
0
votes
0answers
26 views

problem in connecting SQL Server for internet access

I'm having a problem connecting SQL Server for internet access. I have built a test server so that I can play at home and not kill the works server. I've been trying for days and so far I have: My ...
0
votes
0answers
42 views

Size of Table Now vs 2 Years ago [on hold]

I am trying to Analyze the growth of the data/tables within a database. I would like to analyze how much Data is currently present in a table and how much there was 2 years ago. There are date fields ...
1
vote
1answer
59 views

How to combine two queries? [on hold]

I can't explain this very well except by spelling it out. I start a query on ID, and from there I can get TITLE, DATE, and REGNUMBER. The problem is I also want to get 'where,' which is also stored ...
-2
votes
0answers
46 views

Joining Multiple Tables in Sql Query [closed]

I have four tables with their attributes; namely Check_Gauge, Storage_Facility, Product, Product_Brought. The first three tables are related through their primary keys. Product_Brought is not ...
2
votes
2answers
47 views

How can I simplify this UNION?

Here's the case - I have the following query: SELECT DISTINCT post_id FROM ( ( SELECT DISTINCT rp.post_id, pm.meta_value AS premiere_date FROM wp_related_people AS rp JOIN ...
1
vote
2answers
48 views

Remove duplicates and connect relations to the first one

Guess I can use some help over here. I have split a products table into two tables, products and prices. This is the original table: products: +----+--------+-----------+-----------+-----------+ | ...
1
vote
0answers
31 views

Allowing users access to SQLPLUS and to compile PLSQL [duplicate]

As a DBA - assuming my users are knowledgeable with PLSQL and SQL - why would I not grant my users privileges to compile and run their own PLSQL code. We have an MI database environment where the data ...
1
vote
3answers
23 views

Allowing users to compile / run PLSQL and SQL

As a DBA - assuming my users are knowledgeable with PLSQL and SQL - why would I not grant my users privileges to compile and run their own PLSQL code. We have an MI database environment where the data ...
1
vote
0answers
14 views

Convert a list into one row with dynamic column in MySQL [duplicate]

I have a list of row to be converted into a dynamic column that depends on the record in one particular column. From this statement FID |Steps | Action ---- |------|-------- 1416 | 1 | Sit ...