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
8 views

count for time periods?

I have a table with [ComputerGroupid], [Computerid], [Userid], [loginTime], [logoffTime] and I want to get a table with [ComputerGroupid], [StartTime], [endTime], [numberOfcomputerBeingUsed] I am not ...
0
votes
1answer
13 views

join on just the next closest date?

I want to get a table of [file], [folder], [DateAdded], [DateRemoved] I have a log table of changes that has [file], [ChangeDate], [OldFolder], [NewFolder] Files have moved in and out of ...
0
votes
0answers
7 views

Slow Query Performance - Can't Debug

I have a MySQL query that I am trying to debug the performance issue but cannot. I know that the majority of the query is reading/processing rows (Sending Data state). However, in the explain output, ...
2
votes
0answers
24 views

How do I create a partition using a bit field in SQL Server 2014

I have a table where data is archived. I need to keep this data as it is rarely viewed. Instead of moving archived data to a separate table, I wanted to create a partition on the Archived field. When ...
2
votes
2answers
40 views

Help with SQL Query to XML output

I have the following query: SELECT [ID] AS [NewID] , ( CASE WHEN LEN([MiddleName]) > 0 THEN [LastName] + ', ' + [FirstName] + ' ' + LEFT([MiddleName],1) + '.' ...
0
votes
1answer
13 views

DELETE from OPENQUERY alias not working

I'm trying to use the following code to execute a DELETE statement on a linked server. I'm trying to delete all records from the remote server where there is a match on a certain ID field in both the ...
0
votes
0answers
11 views

Merging 2 queries together

I have 2 query results that need merged together where periods are alike, adding a the column 'seats', using a '0' the period doesn't exist. Before: tdate period staff ...
0
votes
0answers
16 views

Suspended query causing high CPU usage

Environment detail: SQL Server 2008 R2. I have applications running on JBoss that access the DB using JDBC driver. Issue: My online DB server was experiencing high CPU usage. Using the ...
1
vote
2answers
26 views

Filling in date holes in grouped-by-date SQL data

The actual problem involves far more data and joins, but I've created a small sample to demonstrate the issue: -- create example table DROP TABLE dbo.EventRecords GO CREATE TABLE dbo.EventRecords ...
0
votes
1answer
21 views

SQL Server Chain Permission

We have the 2 databases. Reporting HR There are some users who want to extract data from HR database. But we don't want to give direct access to that HR database. So, we created the special ...
-1
votes
2answers
23 views

How to Shift a column up in a ring buffer?

I am amazed this question doesn't seem to have been asked before, but if so, my pretty exhaustive searches have not discovered it. I have a simple ring buffer of temperatures in a column from which I ...
0
votes
1answer
15 views

can I use many-to-many relation with weak entity

I have an entity, for example employee(key employee ID), and every employee can have multiple responsibilities. Every responsibility can be tasked to multiple employees. I have 3 options: 1) Create ...
-6
votes
1answer
42 views

SQL Request SQL Count, larger than a value as condition [on hold]

I have a database with a table name products. How do I find the number count of listings (products) with a price value that is stored in (column name = "price") that is larger than $10. So I just ...
0
votes
0answers
9 views

How is it called when a DB supports FOR XML and XQUERY?

I have my SQL Express 2008 R2 database, on which I heavily rely on two features: Generating XML from relational tables (using FOR XML) Generating relational data from XML (using XQuery) I wonder ...
3
votes
1answer
23 views

the <set clause>'s <multiple column assignment>

I just know a little sql basics and need to write a plain sql syntax highlighter/checker So I'm fighting through the standard... I stumbled over somthing I'm not sure I understand it right, as I never ...
0
votes
0answers
16 views

How to compare between two values in one field depending on another field in SQL* / Oracle Reports?

I have three fields in a table named table_family. One is "relation" it has 3 kinds of values 1 for person, 2 for parents, 3 for son. Other field is "age" and it contains the ages of all the ...
0
votes
0answers
13 views

How to copy architecture of an existing database to a new database in SQL Server

I'm using Microsoft SQL Server 2012 (SP1) - 11.0.3153.0 (X64) Express Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1) (Hypervisor) and I need to copy the database ...
0
votes
1answer
27 views

Postgresql recursive CTE to find unique slug

I have an article table where I want the slug to be unique. CREATE TABLE article ( title char(50) NOT NULL, slug char(50) NOT NULL ); When the user enters a title e.g. News on Apple, I want ...
2
votes
1answer
12 views

Suspect (Torn) Pages recorded in TEMPDB? (SQL Server 2005 SP3)

I have a virtualised SQL Server 2005 (SP3) server that reported the following msg: Database_Name, Database_Id, File_Id, Event_Type, Event_Type_Desc, Error_Count, Last_Update_Date tempdb, 2, 1, 3, ...
-1
votes
1answer
19 views

Sorting a table based on nullable Position field that has to match the position on the result set

I'm using SQL Server 2012 I have a simple table that has a Nullable (int) Position and a (datetime) Created field. I would like to do a select * from this table order by created desc but ...if a ...
0
votes
1answer
7 views

Trigger syntax on phpmyadmin

I can't make this work. I want to create a trigger that deletes the child foreign keys before I delete the parent primary key. This is the code that I am using on phpmyadmin: delimiter // CREATE ...
1
vote
1answer
44 views

Delete back ups more than 2 weeks in sql server

I am not a DBA, I need to delete the USER_DATABASE backups older than 2 weeks. Is this below stmt work for this scenario? EXECUTE dbo.DatabaseBackup @Databases = 'USER_DATABASE', @Directory = ...
1
vote
0answers
38 views

I can't divide 2 count(*) values without returning zero

The statement I'm using is for a KPI in Maximo and I currently have this statement: select (select count(*) from incident where incident.slanum = 'USERADMIN' and incident.actualfinish > ...
1
vote
1answer
16 views

Create a log file for check which time import has been done and to split the import files

How to create a log table for when does the last import has been done and also for Query for split the records in to 1000 while importing. to avoid the bulk insert For example : If the data ...
0
votes
3answers
59 views

I do not understand SQL Server Transaction Logs

I understand that a Microsoft SQL Server Database has two components: A database file A transaction log file Whenever I make a change to a table, does it get written to both the database file AND ...
0
votes
1answer
49 views

SQL command to copy over 8,000 table entries [on hold]

I have an SQL Server 2008 database, I want to copy the items from one table (about 8000 entries) to a new table, an this be done with the parent ID to link it to the correct record. I'm using a ...
2
votes
2answers
25 views

Get all (non repeated) distribuidores with their paises given a producto_solicitud

I have this schema: And as title says I need to get all records from fabricante_distribuidor by given producto_solicitud.id value. I'm doing in this way: SELECT ...
2
votes
1answer
125 views

Alter table and update in sql server transactions

I'm trying to do an alter table to add a new column on a table, then I would like to do some update on the existing rows in the table to add a value to the recently new added column and finally do a ...
-1
votes
1answer
46 views

How to know which columns value is different between two rows

I am trying to compare two addresses from the same ID to see whether they match. For example: Id Adress Code Address 1 1 123 Main 1 2 123 Main 2 1 ...
0
votes
1answer
6 views

Select Count on Big table take 15 minutes

I try to run select Count on table with like 16M rows, with MySql 5.5 and workbench 6.2. The query running almost 1000sec . Is it normal? The query : SELECT COUNT(1) FROM My_Table when I run ...
0
votes
1answer
41 views

getting null result from table with data [on hold]

So i have those two tables: DROP TABLE Ticket CASCADE CONSTRAINTS PURGE; DROP TABLE Store CASCADE CONSTRAINTS PURGE; DROP TABLE Employee CASCADE CONSTRAINTS PURGE; CREATE TABLE Employee ( emp_ID ...
0
votes
1answer
22 views

Syntax error debugging [on hold]

I have a logically sound insert statement, but always getting "integrity constraint (%s.%s) violated - parent key not found" and couldn't find why I get it. Everything seems alright to me, no typos. ...
-1
votes
3answers
66 views

Should tables with very large records quantities be split into multiple tables

I'm working on an application (asp.net) that deals with a very high record count -- let's estimate about 75 million events per year coming in fairly evenly throughout the year, and each of these ...
3
votes
1answer
61 views

Database design for an exam system

I am working on creating a simple exam system, in which you are going to be basically able to store students, classes, exams, questions and scores(and some other stuff that those depend on). I am also ...
1
vote
3answers
39 views

How i can export just structure of mysql database

I use ubuntu 14.10 Phpmyadmin I have ''big'' mysql database, 900mb, I need just structure of this database, how i can export just database structure/empty database without remove data or download ...
1
vote
0answers
24 views

Delete Query throwing warning db2

I am trying to delete multiple records from view The view has Instead of Trigger defined .. The view has records consolidated from multiple tables. [db2inst1@testServer001 ~]$ db2 "delete from ...
0
votes
2answers
17 views

ASPStateTempApplications and ASPStateTempSessions tables creation in tempdb after sql server restart

I have a implemented SQL server session state management. So created ASPState database and ASPStateTempApplications and ASPStateTempSessions tables in TEMPDB database. When I restart SQL Service, ...
1
vote
1answer
37 views

why when i run my sql code, the terminal stop on some wired number?

I am creating a trigger code is : CREATE TRIGGER TRIGGER01 AFTER INSERT ON WAREHOUSE REFERENCING NEW AS NEWWAREHOUSE FOR EACH ROW WHEN (NEWWAREHOUSE.STATE = 'MAINE') BEGIN INSERT INTO ...
1
vote
1answer
35 views

Which keyword i should use?

I have two tables I1( A B C) I2( A C) I2 has some tuple of data that I1 doesn't have. Now I want to create a table I3 that only has the data( A C ) that both exists in I1 and I2. which keyword I ...
0
votes
1answer
41 views

Change execution plan in Oracle

I have a large table called Table1 and another table Table2. A query is scehduled every day which inserts data into Table2 by selecting rows from Table2: INSERT INTO Table2(Cola,Colb,Colc..)SELECT ...
1
vote
2answers
47 views

One to many join, Sum from both table

I have two tables: orders and ordersdetail...(partial table) orders- id(primary key), amount, date( index) orderdeails- id(primary key), skunitid, quantity, order_id Each order has multiple order ...
2
votes
4answers
134 views

Identical tables, identical columns, identical records, but why different record sizes?

Identical tables, identical columns, identical records, but why different record sizes? USE [test] GO CREATE TABLE [dbo].[mybit]( [col1] [bit] NOT NULL, [col2] [bit] NOT NULL, [col3] ...
2
votes
1answer
36 views

How to speed up slow query using GROUP BY and CASE?

I'm not very experienced with MySQL and and trying to figure out how to speed up a slow query using GROUP BY and CASE statements. CASE 1 -- GROUP BY and CASE SELECT SQL_NO_CACHE m.id, m.sku, ...
1
vote
1answer
37 views

Mirroring SQL error log - Error: 8474, State: 11

I'm getting these errors in SQL error logs: An error occurred in a Service Broker/Database Mirroring transport connection endpoint, Error: 8474, State: 11. (Near endpoint role: Target, far ...
5
votes
1answer
63 views

Sort by number of related rows in referencing table

Let there be two tables: Users id [pk] | name --------+--------- 1 | Alice 2 | Bob 3 | Charlie 4 | Dan Emails id | user_id | email ----+---------+------- 1 | 1 ...
1
vote
1answer
33 views

Identify unattached File Size in SQL Server

From a similar post on this forum, I have modified the below code as per comments and able to get the orphaned files in the drives. The code is : EXEC sp_configure 'show advanced options', 1; ...
1
vote
1answer
27 views

Splitting 1 record on one table to become two records on another table

I am REALLY very new to this so please excuse my ignorance, but I could really use some help! I've got two tables: BillsFiled and Authors On BillsFiled, there are the columns: ID, Symbol, Filedate, ...
1
vote
1answer
23 views

SQL Server - Log Shipping Into an AlwaysOn Availability Group

I have a requirement to build an AlwaysOn Availability Group, which I have done. Now the user wants me to set up log shipping from another server into the AlwaysOn Availability Group. I’m not sure ...
0
votes
1answer
29 views

How to get the row number where its ID is 'n' and rows are ordered by some column?

I'm trying to get the row number, knowing the row ID, smomething like this: Get the row number (position) from Table1 order by Col1, where this row ID is 263 ID | Col0 | v Col1 | Col2 ...
-2
votes
0answers
10 views

MariaDb join 2 table with diffrence storage engine [closed]

As you know, MariaDb has a lot of special storage engine like: Cassandra, TokuDb, ... Can I join 2 table with different storage engine in one SQL query? eg: 1 cassandra join 1 tokudb,...