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
1answer
17 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
61 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 [closed]

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
27 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
131 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
47 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
13 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 [closed]

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 [closed]

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
72 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
64 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
41 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
25 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
22 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
38 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
45 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
48 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
139 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
40 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
67 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 ...
2
votes
2answers
65 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
11 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,...
0
votes
0answers
48 views

How can you tell if a SQL Server instance max'ed out bottleneck is CPU or Memory?

How can you tell if a Microsoft SQL Server instance max'ed out bottleneck is CPU or Memory? This SELECT-INTO statement on a 8GB box with two 2.6Hz processors. CPU seems busy, goes up and down but ...
1
vote
2answers
42 views

Add function parameter to SQL query WHERE clause

I have a web application in java and it uses a query. I don't want to write the query into Java, so I made a function: CREATE OR REPLACE FUNCTION testFunc(inputs text) RETURNS TABLE(...) AS $$ ...
0
votes
0answers
25 views

LCK_M_SCH_M Blocking

I have 2 stored procedures (one vendor, one third party) that are constantly (monthly) stepping on each other. They both (for some reason) acquire a schema lock when all they are doing is updating ...
0
votes
2answers
27 views

good strategy for big tables and archiving in sql server 2012

I have a table with roughly ~500,000 rows a day getting added into it. The database supports an OLTP system. The make up of it is a bit like this: create table Stuff (StuffID int identity not null ...
-1
votes
2answers
32 views

Trimming the first and last characters from a field [closed]

I have a column like this DATE "112113" "011414" and so on.. I want to remove the first and last characters from the entire DATE column, i.e. I want to get rid of these "". Please help.
1
vote
1answer
23 views

MySQL Latest Deadlock Explanation

Can someone explain this deadlock to me? It seems as if there are 2 inserts happening within milliseconds of each other with the same Primary Key. I'm not sure how this can cause a deadlock. At most a ...
-3
votes
0answers
27 views

I want to reduce SQL Server Transaction log file size [duplicate]

I have 7 TB of db and this db having 3 data files and 5 log files. In this 5th log file having 1.2 TB space. And this db is in bulk-logged recovery model. Now what are the steps needs to do for reduce ...
0
votes
1answer
19 views

SQL query to aggregate data from three tables

I have the following three tables: The "users" table: user_id first_name last_name username password The "users_addresses" table: address_id user_id street country_id email The "countries" ...
0
votes
1answer
14 views

create insertion rule on view returning id

I have a table private.products and a view public.products representing that table. And I want to create entries in private.products while inserting into view, it all works right, except that I also ...
-1
votes
1answer
46 views

what is the syntax for insert trigger?

I am very new to sql. feel a little stupid to ask this question Say I have this table Warehouse(shipperid, name , state). Then I define another table warehouse_maine (shipperid, name, state) which ...
0
votes
1answer
40 views

Select Query takes more than a minute to retrieve data

I have a table that has 99 columns, all of them are not needed but they were there when we started. There is a Primary Key (Objectuid) which is a GUI and has the Clustered Index on the PK. The Table ...
2
votes
0answers
23 views

How to query for additions and deletions between two sets of rows (mysql)

I have tried several variant queries for finding additions/deletions between two sets of rows. Purely algorithmically, there is a straightforward algorithm that is O(N) for composing a list of ...
1
vote
1answer
28 views

SQL Server AlwaysOn to run updates and schema changes in 24/7 environment

First of all i have to say that this question comes from a software engineer-perspective. Unfortunately we have no DBA so we need to administer our own databases. We have SQL Server 2012 Enterprise ...
-2
votes
4answers
193 views

Is there a SELECT statement to subtract rows of the same column?

Column 1 is the mem_id, Column 2 is the Transaction type C and D, and Column 3 is the Amount Owed. So I want to return Column 3 "Amount Owed", but it has to be C-D in Column 2 for each member. ...
1
vote
1answer
73 views

Installation failed in installing SQL Server 2008 SP3 on windows 8.1

Overall summary: Final result: SQL Server installation failed. To continue, investigate the reason for the failure, correct the problem, uninstall SQL Server, and then rerun SQL ...
0
votes
1answer
38 views

SQL INSERT and UPDATE queries run far to slow

I have two queries that run far too slow and I have no idea why. Both tables contain about 500000 rows. Each call needs ~20 minutes and the they have a really high CPU usage (~90% on Mac). I have ...
0
votes
1answer
35 views

Select into existing table where ID is in another table [closed]

I have one table containing ~35k IDs (TableC), one table that features multiple columns (TableA), amongst others the ID from the before mentioned table and a third empty table, featuring the same ...
0
votes
0answers
32 views

Unique Constraint exception after dropping constraint

We had dropped a unique constraint using the ALTER TABLE DROP CONSTRAINT script, but it is still throwing the Unique Constraint exception while trying to insert. We drilled this down to two possible ...
3
votes
2answers
156 views

SET DATEFORMAT problems

I have some doubts about SET DATEFORMAT command. 1)Does this command is only used for inserting and updating date format and it does not effect the date format of that column? OR does this effect my ...
0
votes
1answer
18 views

Copy every entry from TableA to TableB where the ID is in a textfile containing a list of IDs

I have a text file (or an xls) with a 35k lines, each containing a single ID. I'm required to copy every entry of TableA to TableB where the ID is in said list. Would it be best if I'd create a new ...
3
votes
1answer
45 views

Counting repeated occurences for a group of fields

I am trying to count the continuous repeated value for a field in order to obtain the maximum repeated occurrences for each person in the table. eg: Time person Result 08:12:36 ...
-3
votes
0answers
33 views

Open tran for Select query [duplicate]

I have seen BEGIN TRAN on queries in my production db, but it is just a SELECT query with NOLOCK option in the transaction. Why would a simple SELECT query be placed inside of a transaction?
0
votes
1answer
46 views

GROUP BY Returning Different Totals [on hold]

I have two very similar queries that are returning different totals. The first query, where the total [of subscription_payment.price] is calculated with PHP (and verified in Excel), is the same query ...