DO NOT USE this for questions targeting Microsoft SQL Server, use the tag sql-server instead. "SQL" is an acronym for "Structured Query Language", it is used in relational database management systems (RDBMS) to query, update, delete, and insert data as well as modify the structure of the database. ...

learn more… | top users | synonyms (1)

1
vote
2answers
110 views

Should I set document version field to be part of a primary key

Should I set document version as a primary key I am working on a document management system, and I have these two tables representing part of the whole tables. On the DocumentVersion table I have ...
1
vote
1answer
38 views

Having troubles creating table SQL [closed]

I'm new to SQL and Im trying to create a simple database, but I'm having problems with second one, I'm using Oracle Database express 11 and when I try to run this code I get error: Missing right ...
8
votes
2answers
222 views

Are “out of the row” fields read when a clustered index is used?

I know that when VARCHAR(MAX)/NVARCHAR(MAX) columns are used the data is stored out of the row - the data row will have a pointer to another location where the 'large value' is stored. I have the ...
5
votes
1answer
333 views

Why not rebuild indexes with page count <1000?

I use Ola Hallengrens script for Index maintenance. Before I did that, I used the following query to see which indexes are fragmented most: SELECT dbschemas.[name] as 'Schema', dbtables.[name] as ...
0
votes
1answer
41 views

decrement all columns entry when row is deleted

I have a column in a table containing the row_number, some kind of id number to identify the row. When I delete one row, I need the other rows to have their row_number decremented, to keep them ...
2
votes
2answers
56 views

What is meant by churn?

I came across the following sentence in this blog post: Know your data - this helps you make the right decisions in terms of data types/nullability and churn helps with long term maintenance ...
0
votes
0answers
143 views

Unable to connect to or create SQL Server database using asp.net [closed]

In my asp.net project I have SQL Server database with some tables. Unfortunately my PC was not properly shut down and and after that I am unable to connect to my database from Visual Studio (I am ...
1
vote
1answer
91 views

What do these parameters mean at the beginning of my SQL Server query plan?

I'm looking at query plan in SQL Server Mgmt Studio and I see something like this: (@P0 nvarchar(4000), @P1 nvarchar(4000)) Update... What does the type mean beside the parameters? For this example ...
0
votes
2answers
390 views

Check if database has changed to determine need to perform backup

I want to check SQL server database is modified or not. Reason to check database is modified is for backup(sql database backup) purpose. So I will be doing a full backup first and if any data ...
1
vote
2answers
88 views

Understanding multiple table join with aggregation

I have a basic question on how JOIN works on multiple tables. I want to count occurrences of Foreign Key in link1 & link2 CREATE TABLE main ( id SERIAL PRIMARY KEY, name text NOT NULL ); ...
0
votes
2answers
35 views

sync 2 tables in a single database in mysql with no duplicacy [closed]

I have 2 tables in a single database of MySQL. The structures are like this: mysql> desc main_tbl; +-----------------+--------------+------+-----+-------------------+----------------+ | Field ...
0
votes
2answers
80 views

How can i automate the process of log shipping monitoring

I have log shipping configured between my Prod SQL server 2005 and QA SQL server 2005. Per the requirement from Business we need to provide them with a report at the end of the day for the LOG ...
0
votes
1answer
81 views

SSIS Dataflow Task issue, moving data from SQL Server 2008 to MySQL via ADO.Net

Can you please help me in getting this problem solved.. I'm trying to build a SSIS package where I'm moving the data from SQL Server 2008 to MySQL. However I'm getting a weird problem in dataflow ...
1
vote
2answers
58 views

Get the pais_id not associated to fabricante_distribuidor_id and producto_solicitud_id, the opposite from SELECT query

I have this query for get all the pais_id given a fabricante_distribuidor_id and producto_solicitud_id, the query works fine. SELECT DISTINCT nom.pais_id FROM negocio.fabricante_producto_solicitud ...
1
vote
3answers
108 views

How to see percentage of existing values for all columns in mysql table?

I have three large-ish tables (~20 columns each) and I want to know what percentage of rows have a value for each column. For instance, this table: ID | TITLE | SERVING | NOTE ...
1
vote
2answers
98 views

How to calculate a total by comparing current and next row

I have a table with some rows: I have a few questions to accomplish the task altogether. Is it possible to calculate total of transmitted and received based on checked_date and ip and connect_time ...
3
votes
2answers
367 views

Getting the number of Saturdays and Sundays in a month

I am trying to get the number of Saturdays and Sundays for a given month represented by an end_date and a start date. I have been trying to understand the algorithm in the SO question here . I have ...
0
votes
1answer
28 views

Update different oracle database from different oracle database

I want to update a CLOB column in B Oracle 11g database using a CLOB column in A Oracle 11g database located in a different server. What are the different ways to do that? and which is the best and ...
-3
votes
0answers
42 views

The SQL server Log folder is expanding because of the SQL Dump files (what to do with it ?) [duplicate]

The "Log" folder SIZE in the SQL server root directory (X:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Log) becomes too big , ~80 GB. When I checked it, I see that there are a lot of ...
-1
votes
1answer
93 views

The SQL server Log folder is expanding because of the SQL Dump files (what to do with it ?)

The "Log" folder SIZE in the SQL server root directory (X:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Log) becomes too big , ~80 GB. When I checked it, I see that there are a lot of ...
1
vote
2answers
74 views

Shrink logs in between user transaction in SQL Server

I have a database where there are like billions of rows and I need to delete the data based on some condition. Initially I was trying to delete the code in one transaction and log starts growing to ...
2
votes
1answer
61 views

MySQL WHERE if NULL select another column

This is my mysql table id date_created date_active 1 2014-06-07 18:24:38 NULL 2 2014-06-07 18:24:38 2014-06-07 18:24:38 3 2014-06-07 18:24:38 ...
1
vote
1answer
32 views

Finding out the exact size of the database after inserting records?

I have this query: SELECT table_schema "db.name" , Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB" FROM information_schema.tables GROUP BY table_schema; Does this ...
1
vote
2answers
97 views

How to tune the below query

I am currently working on below table structure to pull the data/ generate any one time report. Let us consider the table name to be ABC. ID Field Value 1 Name Nagarjuna 1 Gender Male 1 ...
1
vote
2answers
172 views

Will a non-clustered index on a column with covering index on all the columns of table affect the Delete statement Records)?

I am trying to delete thousands of records say 35K from a table which consists like 10 million records. Delete * from Table where ScenarioID=859 I have also tried bulk deletion DECLARE ...
2
votes
0answers
68 views

Storing URLs in a database

I am thinking about storing URL's in my database, but I am not sure whether the way I use is an efficient way to do things or not. Table name : url url_id (Primary Key & Auto Increment) url_value ...
1
vote
1answer
51 views

SP how can I sum the amount of all leftchild in parentid

I have this data and table structure,I am creating MySQL stored procedure to sum all the amount in the leftchild of the parentid, I don't have enough knowledge in stored procedure.and I need some help ...
1
vote
1answer
27 views

SQL Server 2008 R2 - Change distributor schedule

We have configured SQL 2008 R2 replication. Distributor is configured in continuous mode, publisher is scheduler is set to execute after every six hours. Now we want to change distributor schedule ...
2
votes
2answers
59 views

How to get the sum of a particular item id in a column

Item ItemName PackageID Specifics brandname GRNQty UnitPric GRNValue 102814742801 ALL BRAN FLAKES 1PKT Bran. KELLOGS 7 15.9 111.3 102814742801 ALL BRAN ...
1
vote
0answers
21 views

pgAdmin-III - Option to load a favorite automatically when opening query window

pgAdmin-III - Query window option Does pgAdmin-III has any option to load a default favorite file automatically when opening new query window? This would be much useful to have commit/rollback ...
1
vote
1answer
83 views

SQL Server : scheduled JOB issue

I have one issue in my live server ... Issue is: I created a job for log file shrink & I have scheduled it for every day run with sa user When I run this job manually from Management Studio, it ...
3
votes
2answers
50 views

Selecting minimum value in top grouping only

I have a query built in Oracle 10 which produces a set of data like this: EMP_ID WORK_DT TIME_TYPE ---------- --------- --------- 12345 19-DEC-14 10 12345 18-DEC-14 10 ...
0
votes
2answers
32 views

Get all the users that are managed by a targeted manager

I have the following model: Table user: (id, name, direct_manager_id) Table customer: (id, name, managed_by_id) i.e. users can have another user as their direct manager, Customers can be managed ...
-3
votes
1answer
50 views

Finding users with database owner role in sql server 2005 or so [duplicate]

I need a script which will list out all the users with DataBase Owner persmission for a specific database. Thanks
0
votes
1answer
109 views

Run CDC Cleanup job at specified time

I have enabled cdc and using it , it works fine now the problem is that we have many tables in a database and also we have many databases so how to configure cdc cleanup job to run again and again ...
0
votes
0answers
24 views

Is there a DDL/DML statement auto checking tool?

As a DBA, before applying DDL/DML statement written by developers to an online database I have to analyse and check potential limits or danger in these statements, such as: 1.whether a "create ...
1
vote
1answer
63 views

How to insert values into a junction table?

I add values into my two tables using the code below, but I also have a junction table called book_main_cover and I want to add data into this table to make a connection between book_id and ...
0
votes
1answer
36 views

Why Does the Update Statement also updates indexes?

I am currently learning about SQL queries and how indexes work with them, and I ran into a situation that I don't understand. Let's say I have this query for that updates a tables' values with another ...
1
vote
1answer
58 views

Deleting duplicate rows with condition [duplicate]

I have posted a similar question before, but this one is a little modified. I have a table with 4 columns as shown below. ITEMCHARGE CPT4 EFF_DATE CPT4MOD 326.8 29075 ...
5
votes
2answers
177 views

T-SQL brain teaser: find non-overlapping sets

I would like to ask for help coming up with a query, which can identify groups on non-overlapping records. Here is a sample scenario (admittedly contrived). Let's say I have employees who are ...
0
votes
1answer
36 views

optimizing a select query of 1.5 million entry

I have the following query: SELECT s0_.id, s0_.lowresimageurl FROM app_instagram_shop_picture s0_ FORCE INDEX ( idx_deleted_shopId ) LEFT JOIN app_instagram_shop s1_ ON s0_.shop_id = s1_.id AND ( ...
-1
votes
1answer
38 views

How to manage two tables in SQL Server [closed]

i have two tables offer1 and offer2 The two tables are Offer1 Offer2ID|OfferName|OfferExpiryDate Offer2 Offer2ID|OfferName|OfferExpiryDate now i have third table which keeps record ...
1
vote
2answers
135 views

Deleting duplicate rows with condition(Using SQL and LINQ)

I have a table with 5 columnsID,CPT4,CPT4Mod,ItemCharge,Eff_Date. Deletion Condition: When rows exists with duplicate CPT4and CPT4Mod field values but different ItemCharge and Eff_Date values, ...
1
vote
1answer
35 views

How to Select the First (or last) entry for a specific day

I have a table "AttendanceRecords" with entries like this EntryID UUID PRIMARY KEY, StafID UUID REFERENCES staffmembers(ID) NOT NULL, ArrivalTime TIMESTAMP NOT NULL, DepartureTime TIMESTAMP For one ...
0
votes
1answer
25 views

How can I aggregate multiple results from another table using something like BOOL_AND?

I'm using PostgreSQL as my database. CREATE TABLE users ( id SERIAL NOT NULL, name TEXT NOT NULL, PRIMARY KEY (id), UNIQUE (name) ); CREATE TABLE groups ( id ...
0
votes
2answers
36 views

SQL Query Help to get Quiz statistics

I'm coding a quiz web application and i need help. I've got three tables Nicknames : |USER_ID|NICKNAME| that stores USER_ID(auto increment) and NICKNAME registered to my system. Questions : ...
0
votes
0answers
24 views

Sub queries in Apache Hive

I have a table with following structure col1 col2 col3 col4 category 300 200 100 20 1 200 100 30 300 2 400 100 100 70 1 100 30 200 100 ...
0
votes
2answers
101 views

insert inserted id to another table

Here's the scenario: create table a ( id serial primary key, val text ); create table b ( id serial primary key, a_id integer references a(id) ); create rule a_inserted as on insert to a do ...
1
vote
1answer
71 views

Performance of single vs multiple column unique constraint

I'm using PostgreSQL 9.3. I want to understand if I have an option to make a constraint unique across the entire table vs. unique across a subset of the table (i.e. by using 2 columns in the unique ...
3
votes
2answers
79 views

New Index on table cause table to be locked really often

Here are my tables : CREATE TABLE [dbo].[Trackers] ( [IdTracker] INT IDENTITY (1, 1) NOT NULL, [IMEI] NVARCHAR (16) NULL, [CreationDate] ...