Tagged Questions

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
1answer
51 views

How can I get all orphan records in a single query?

I just noticed few tables that has orphan records (foreign keys) that no longer point to any primary key. How can I query the tables to get a list of all such rows? When these parent records got ...
1
vote
0answers
56 views

How to represent directed graph with multiple parents?

http://dirtsimple.org/2010/11/simplest-way-to-do-tree-based-queries.html provides an algorithm for inserting and deleting from a Closure Table. I'd like to model a similar data structure, except that ...
0
votes
0answers
52 views

Column encryption/decryption using encryptbykey

Working on a project where I need to encrypt a few sensitive columns in a table but make the data available through a procedure that a user can execute through either a report or excel. In looking ...
1
vote
1answer
36 views

Choice of clustered key when almost all columns would be part of a unique index anyway

I am creating the following table CREATE TABLE dbo.COMM_SHELF_BLOCK_ACCESS ( KeyId uniqueidentifier NOT NULL ROWGUIDCOL CONSTRAINT DF_COMM_SHELF_BLOCK_ACCESS_KeyId default NEWSEQUENTIALID(), ...
0
votes
1answer
91 views

Conversion failed when converting the varchar value to data type int in SQL Server

While getting some data input, for below query, encountered Convertion failed error:- SELECT a.ProcessInstanceAppianID, a.ProcessInstanceDescription, CONVERT (INT, ...
0
votes
0answers
40 views

Please anybody help me with oracle db importing?

I try to import .DMP file with impd comand. root@HP:~# impdp SYSTEM/xxxxxxxxx log=4.log file=as.DMP and i get this ;;; Import: Release 11.2.0.2.0 - Production on Thu Oct 2 12:21:14 2014 ...
1
vote
2answers
47 views

Build Restore History table

We restore a database daily that we download from an FTP site. I would like to build a history table that tracks when the database is restored on our SQL Server. This is easy. My issue is sometime ...
1
vote
1answer
53 views

Populate one table with data from another one on selected cells

I have a problem with filling empty cells in one table with data from another one. I got a table with user emails - some of the fields are empty, some are already containing emails. I gathered the ...
7
votes
1answer
124 views

T-SQL - OPTION (FAST x) and trace flag 8722

I have searched a long time and still haven't found the answer to my problem. Our Dynamics AX is generating queries with the query hint OPTION (FAST x), which sometimes forces a bad execution plan to ...
0
votes
1answer
88 views

How to split one big table that has 100 million data to multiple tables?

I have one database in Sql server 2012 and in that there is one table that has more than 100 million data and I wanted to split that table to multiple similar table with 1 million data in each table. ...
-4
votes
1answer
62 views

When you type an SQL query in interpreter, what does happen? [closed]

Actully this question is asked in an interview from me . When you type an SQL query in interpreter, what does happen? How is the query processed?
0
votes
0answers
55 views

Intermittent errors when calling stored procedures with linked server references from SQL Agent jobs

Environment: Windows Server 2008 Standard without Hyper-V Service Pack 2 - 64 bit SQL Server Enterprise 2008 R2 SP2 - 10.50.4000.0 - 64 bit Problem: I am receiving intermittent failures from ...
2
votes
0answers
43 views

Checking for multiple identical values in a Posgresql array

I have a simple table in Postgresql: CREATE TABLE data (id integer, values integer[]); INSERT INTO data VALUES (1, '{1,2,3,4,5}'); INSERT INTO data VALUES (2, '{1,1,2,3,4,5}'); INSERT INTO data ...
1
vote
1answer
40 views

How can I log the way in which a job was started?

Using SQL Server Agent, I've created a Job that runs some SQL. This SQL does some work on one database, then adds a row to a logging table on a separate database. The Job is run on a couple of ...
1
vote
1answer
48 views

how to group data against more than one conditions

I have a table named Employees with below two columns. ================== Employees 1- EmpId (auto incremental id) 2- EmpName (varchar) There is another table named 'LateDays' with below five ...
0
votes
0answers
12 views

Assigning Parent Node Value using IDs

I am using iReport to build a report and I am trying to find the parent node "group_name" value based on a parent_id given, and return the value the parent, as the child's value. For example: Table: ...
0
votes
0answers
36 views

Update Duplicate record in select query of access

I have a select query (test) in access with below mentioned column ID 2561 2562 2563 2343 2561 2563 2563 Now in ID, i have duplicate records , for example here 2561 , 2562 , 2563 are ...
1
vote
1answer
108 views

Database design for an online babyShop ,Toy shop

Hi i'm designing a database for a toy shop this shop offer many products with different categories. boystoys,girlstoys,puzzles,beds,stroller, etc i designed my database as it is consists of 5 tables ...
0
votes
1answer
35 views

ORA-00838 error after increasing MEMORY_TARGET

I've increased MEMORY_TARGET in pfile and then create spfile. I'm getting the same problem as before: ORA-00838: Specified value of MEMORY_TARGET is too small, needs to be at least 3084M The ...
0
votes
2answers
51 views

Complex query: find all users who rated all the movies rated by user_id='1234'

So we have the following relational schema: users(user_id, ..) movies(movie_id, ..) ratings(user_id, movie_id, rate) So, we want to find all the users who have rated all the movies which are rated ...
2
votes
1answer
38 views

Supertyping Inventory Transactions

I am trying to wrap all interactions with inventory items into one transactional table. Currently I calculate QoH by querying multiple fact tables (production, acquisition, shipment, return order, and ...
1
vote
2answers
31 views

PostgreSQL - summing arrays by index

I have an array of doubles column (double precision[]) in PostgreSQL that keeps half hour values for a day. So each array holds 48 values. I need an efficient query that is summing all this array ...
0
votes
1answer
26 views

SQL Server data, logs, backups files in mounted foldersin C:\

I know that is a good practice to have data, logs and backups files of SQL Server in diferent disk, for example D:\ for Data files, E:\ for Logs files, F:\ for backup files. But if I want to use this ...
0
votes
0answers
25 views

MYSQL Tables Join Filtering For Favorites

I am in need of some help figuring out the best way to join separate tables I am using. I am essentially trying to output a list of schools (first table in MYSQL) where one column is an empty star ...
0
votes
1answer
5 views

SQL Server : low disk space impacts CPU?

Is there any relation between disk space and CPU utilization? We experienced the issue with very high CPU utilization on SQL Server 2008. At the same time, we were in lack of free space on the ...
0
votes
1answer
50 views

MySQL dies when trying to access a specific database

For some reason, whatever I do I cannot access one of my databases (through command line or through something like phpmyadmin). However, the application that depends on this database is not having any ...
0
votes
0answers
25 views

How to store multiple vendor data in Google Cloud SQL?

I am designing a mobile app in which I need to host my vendor data and give access to that data after analysis to only the specified users. Since I will have multiple vendors with different set of ...
1
vote
1answer
63 views

Backup the whole SQL Server databases in one .bak file - SQL Server 2005

First I asked my question here: Migrate all databases from one SQL Server 2005 to another Many friends replied to it and I gathered lots of useful information. I have another scenario in which we ...
0
votes
1answer
18 views

SQL: Repair With Keycache

Now my MySQL server running a REPAIR TABLE, table is almost 15gb size. Status - Repair with keycache. How I can restart REPAIR TABLE with normal (repair with sort) mode?
0
votes
2answers
33 views

Subquery or multiple left joins, or both?

I have two tables, for simplicity table1, with id as Primary key, and a field name, and table2 with the same. Each table has quite a few records, but during a complicated form process, the user is ...
1
vote
1answer
25 views

SQL: SOS: MySQL indexes overloads disk

My server is down now, 'couse indexes of 84GB DB are overloads disc. Here is output of df-h: /dev/ploop58097p1 193G 187G 16M 100% / tmpfs 2,0G 0 2,0G 0% /lib/init/rw ...
1
vote
1answer
33 views

How much should I care about prepared statements for simple queries?

I wonder how much I should care about prepared statements (and therefore try to optimize my code) in case of pretty simple statements. The question originates from the fact that I recently noticed ...
0
votes
0answers
15 views

MySQL Case always executes the same [duplicate]

What I want to do is to set DATE_REACT a value when the first condition is satisfied, and a different value when the first condition is not satisfied. The problem is that the first condition is ...
0
votes
2answers
27 views

MySQL Case problem

I am trying to run a SQL code (I use MySQL). What I want to do is to set DATE_REACT a value when the first condition is satisfied, and a different value when the first condition is not satisfied. The ...
0
votes
0answers
17 views

pgAgent does not run

I referred this to set up a scheduled job and did everything as it mentioned(ran the pgagent.sql as well) I need a very simple task to run periodically. In the 'Definition' tab in the steps, few ...
0
votes
2answers
23 views

Set of datetime versioned rows, how to build the most up to date row

I created this SQL fiddle with the sample data The sample data is this: -- -- Table structure for table `dogs` -- CREATE TABLE IF NOT EXISTS `dogs` ( `version_stamp` datetime NOT NULL, ...
4
votes
1answer
119 views

Order by bug on SQL Server 2005 vs SQL Server 2012

I have a query generated by entity framework that returns wrong results on a SQL Server 2005 db (Microsoft SQL Server 2005 - 9.00.5000.00 (X64)) but good on SQL Server 2012 (Microsoft SQL Server 2012 ...
18
votes
3answers
740 views

Are RANK() and DENSE_RANK() deterministic or non-deterministic?

According to official Microsoft BOL DENSE_RANK is nondeterministic (RANK()). But according to Ranking Functions by Itzik Ben-Gan "... the RANK() and DENSE_RANK() functions are always deterministic". ...
0
votes
0answers
11 views

MySQL Replication problem with VIEWS and “Sub-Databases”

I've got three servers that should do a master-master replication. On server 1 i got "01_maindb" which holds the master tables. I replicate this table to the two other servers without problems. ...
0
votes
0answers
27 views

Accessing values of dymanic cloumn

I have a table which has 16 fields whose of alternate name to city. Below is my table structure: CREATE TABLE CITY_DATA_TO_CHK ( COUNTRY_CODE VARCHAR2 (100), REGION ...
1
vote
1answer
46 views

Options for Index Defragmentations For Critical Tables

I wonder if this is a suitable solution for index defragmentations. scenario is like this; There is a table named 'Events' which is very critical and has 4 indexes which are not done maintenance ...
0
votes
1answer
45 views

If I assign a NVL constraint to a nullable column will it display an error or it will retrieve the records?

I have a database in which some tables have to be joined to fetch the data. The problem is that in one table the column is nullable (nullable is set to yes or no constraint given for that column) and ...
1
vote
3answers
83 views

convert nvarchar to int

I have a table in access linked to SQL.I am doing a query where I am using a field named comment from this table. The field is designed in SQL as nvarchar(255) . I am writing integers numbers in this ...
2
votes
2answers
13 views

PostgreSQL query slows due to ORDER BY even with an index

I have the following query to find offices that service a given area. When I run this query without the "ORDER BY" clause, it takes a less than 0.1 seconds. When I add the ORDER BY clause, it takes ...
1
vote
1answer
16 views

Find the number of where statements that matched in postgresQL

Right now I have a query that looks something like this SELECT id FROM products WHERE products.details->'make' = ? OR products.details->'model' = ? OR products.details->'year' = ...
0
votes
1answer
48 views

Select complete next row based on the current row

Hi i have a complicated condition. I have a table lets say 'Test' ID Partner Type Amount 143854 CSTC Purchase -0.81 144029 CSTC Purchase -0.69 144030 CSTC Purchase ...
0
votes
1answer
33 views

SQL “select” query for getting 0 instead of null?

In the database I have some value as null . So while fetching these null value from database it should be treated as 0 not as null. Note:- I don't want to be it done by code but from SQL query.
0
votes
1answer
18 views

How to change the mount point for a column in postgresql table?

This is my scenario I have a table t with following columns id int link varchar(500) name varchar(20) sal text In the link column we will store the location for the pdf files(mount point) ...
1
vote
2answers
79 views

How can i resolve this problem of taking more time to execute then the previous?

I'm working in DWH environment Every day many data gets extracted transformed & loaded But from last week i see that there are taking more time then previously executed. I don't have a option to ...
0
votes
0answers
19 views

MS Access using MYSQL database and error in SQL (memo, hyperlink OLE)

I have a SQL statement that works fine in MYSQL workbench but when used in Access it produces a "invalid Memo, OLE or Hyperlink Object in subquery 'custom_values.value'. SELECT ccr1.value, ...