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)

0
votes
1answer
17 views

inner join on true

My table: abc +--------+ | letter | +--------+ | a | | b | +--------+ Query: SELECT * FROM abc t1 INNER JOIN abc t2 ON true Result: +--------+--------+ | letter | letter | ...
-3
votes
0answers
16 views

what is update cascading exactly in sql? [on hold]

We have three table declarations for P1(A), Q1(B) and R1(C) with referential integrity in SQL. create table P1 (A primary key); create table Q1 (B primary key references P1(A) on update ...
0
votes
1answer
12 views

Address Windowing Extensions Overhead

I just found another SQL Server (2008r2) with AWE enabled on a 64-bit OS/SQL combination. Has anyone done an research as to the overhead created by enabling AWE on the 64-bit OS/SQL combination? It ...
1
vote
1answer
10 views

SQL Server restore database file access error

I am trying to restore a database from a file on a remote machine. The script I am using is as follows: RESTORE FILELISTONLY FROM disk = '\\server\path\to\file.dmp' RESTORE DATABASE MyDB FROM ...
0
votes
1answer
21 views

Virtualized SQL Server Memory Oddity

I've not seen this before, though perhaps it is common. I am looking at a virtualized (VMWare 5.5) SQL Server (2008R2 on Windows 2008 R2). What I am seeing is that in Task Manager, sqlserver.exe is ...
0
votes
0answers
23 views

Select query for finding jobs started at same time

I have a 'Job_Status' table with 3 columns: Job_ID (numeric) Job_Time (datetime) Machine_ID (numeric) At a regular interval (1 min), entries are inserted in the above table for the Jobs running on ...
1
vote
1answer
24 views

MySQL Matching records across tables discrepancies

I have a database called match, within this database I have a number of tables. Of which in particular I need to marry up two datasets in different tables to identify email addresses that are not ...
1
vote
1answer
25 views

How to optimize the sort in Postgres query

I've been trying to optimize the sort in the following query. I ran EXPLAIN ANALYZE and the majority of the time is during the sort when it arranges the output by distance. I've tried converting the ...
0
votes
0answers
16 views

Selecting the correct database engine [on hold]

I am looking for a database engine/system that will allow me to do the following things: Query in SQL Use key-value store or document-store I am trying to setup an intentionally vulnerable server ...
5
votes
1answer
46 views

Find rows where integer sequence contains a given subsequence

Problem Note: I refer to the mathematical sequences, not the sequences mechanism of PostgreSQL. I have a table representing sequences of integers. The definition are: CREATE TABLE sequences ( id ...
1
vote
3answers
19 views

Access Query Design View: Show results in two columns from one table

Lets say I have the follow Tables: Outfits: ID | Top Color ID | Bottom Color ID 1,2,1 2,3,4 Colors: ID | Name 1, Red 2, Blue 3, Green 4, Orange I'd like to have a query in design view to have the ...
0
votes
0answers
28 views

Correction of a complex query [on hold]

I don't know if this question is appropriate on this forum. I have a huge query : SELECT threshold.id, brand.id, COUNT(brand.id), threshold FROM current_stock, article, product, brand, delivery, ...
-1
votes
0answers
20 views

Modifying a query for the UPSERT command [on hold]

Here is the current query select pt.name, slr.name from stock_route_product srp inner join product_template pt on srp.product_id = pt.id inner join stock_location_route slr on srp.route_id = slr.id ...
0
votes
1answer
15 views

Replicate update statement as Insert in Mysql 5.6

I want to replicate all update statement from Master as a Insert at slave end. 1. Is it possible like in SQL Server ? 2 If so , how ? I want to do it because , if any record on master is ...
1
vote
3answers
84 views

Finding all date ranges that overlap a target date range

Say I wish to store when staff are on holiday (FromDate, ToDate) and then I wish to find all staff that are on holiday between two given dates (QFromDate, QToDate). Now assume that I have many such ...
1
vote
0answers
27 views

Why does my query search datetime not match?

select * from A where posted_date >= '2015-07-27 00:00:00.000' and posted_date <= '2015-07-27 23:59:59.999' But the result contains a record that has posted_date today: 2015-07-28. My ...
2
votes
1answer
37 views

Row with latest timestamp

How to get the row with the latest value in a TIMESTAMPZ column? Is an index needed? Does an index change the strategy? Would behavior vary by database (I'm using Postgres 9.4)? My app records data ...
1
vote
0answers
32 views

I need to find the “rank” in a sub-set of entries

I am currently working on some sort of a highscore list. But values displayed are individual for each user, ie. limited by constraints. One constraint that I am currently working on is "being part of ...
1
vote
1answer
31 views

What is the correct implementation of handling concurrent SQL inserts while ensuring a non-primary key column (i.e. wid) unique and auto-incremental?

What is the correct implementation of handling concurrent SQL inserts while ensuring a non-primary key column (i.e. wid) unique and auto-incremental? Note: There was a design constraint that led this ...
1
vote
2answers
36 views

group result of multiple table to get unique result after count operation

survey_categories +---------------+-------------------+ | survey_cat_id | survey_cat_status | +---------------+-------------------+ | 1 | 1 | | 2 | ...
0
votes
1answer
24 views

Is it necessary for rownum = 1 with Query.createQuery().getSingleResult()? [on hold]

I'm a newie and I'm not really sure if MIN(My_Date) returns just one row if 2 or more dates are identical. Reference is a FOREIGN KEY. so to limit query: SELECT MIN(Shipping_Date) FROM ...
-1
votes
1answer
39 views

How to do superscript in SQL Server 2012 query? [on hold]

I am trying to change superscript in SQL query string. Example: Select 'Your submitting date is 2nd January 2016'; As above query, I want to change nd to superscript.
3
votes
1answer
33 views

MySQL query WHERE IN + ORDER BY, which EXPLAIN is better and how to avoid filesort?

This is my table definition, without any special index for now: CREATE TABLE `filter` ( `field_name` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `category_id` varchar(32) COLLATE ...
1
vote
2answers
27 views

How to select only those records that have different/multiple for a particular field

Below is an example of my membership table. There some records having multiple values in the email field. I only want to select those records that have multiple email values: Member table ID ...
2
votes
0answers
24 views

Join duplicates on T-sql

Background: This is largely a learning exercise. I am working on a task scheduling program. Part of the program requires making a report to print out. I am working with the original version of the ...
0
votes
1answer
21 views

How to see query executed for a specific user from V$SQL

I am trying to have the queries used for a specific user at the end of the day. But it seems the queries in this view V$SQL are deleted every short time. I am not sure how much time. Also i dont know ...
0
votes
0answers
13 views

Should setting up SQL Server transactional replication require schema locks on published articles?

I'm attempting to setup transactional replication in a production environment. When adding columns to an article (calling sp_articlecolumn stored procedure), it appears to want to lock the published ...
0
votes
1answer
28 views

Is it possible to convert mssql to mysql?

I've mssql.sql file I need to convert to mysql schema. Any ideas how? I'm on mac, I guess my choice is very limited. Tried workbench but it asks me for a live server connection to mssql which I don't ...
0
votes
3answers
77 views

SSIS - Best way to insert large number of rows

So here's the scenario: I have an XML file, which is in size of 500GB, and with data of around 600 million rows (once on a database table). I'm using SSIS for the operation, and since it consumes a ...
3
votes
1answer
119 views

How to get exact year difference between two dates in SQL Server?

I have a date of birth column to which I need to compare the current date and return the difference as age. Currently I am using the following query : DECLARE @DateOfBirth date = '2000-07-27' DECLARE ...
0
votes
2answers
44 views

How to JOIN each row ON NOT IN ( SELECT … )?

Say I have a table of users, songs, and songs played. users id: int songs id: int songs_played user_id: int song_id: int If I want to, for each user, find a song that has not yet been played. How ...
1
vote
1answer
50 views

Row_Num Partition in WHERE clause

I've successfully written in the a row_num function but get an "invalid column name" when I try to reference the column I made with the row_num in my WHERE clause. Query: SELECT DISTINCT ...
1
vote
4answers
91 views

Mysql - Select next x records even if reaching rowset end

I have a table with an ID field, unique, autoincremental. I need to, given certain ID, retrieve next 3 records even when given ID is the last one. Table: ID 1 2 3 ...
1
vote
2answers
36 views

Having trouble with insert query on linked server

Two servers. Server A and Server B both has database named KPS. KPS has two tables complaint and attachment. KPS database on server A gets the value from the Web. Both table if the submitted value = ...
0
votes
0answers
21 views

Linq Query Optimization [on hold]

Urgent,I am really in trouble. can anybody help me? my query is slow: I have created a view in sql server containing nested loops like this: Tis is my view: SELECT dbo.VE.V, dbo.VE.Operation, ...
0
votes
1answer
14 views

Full text search on two tsvector columns

I'm trying to do a full text search across two columns of two separate tables in PostgreSQL 9.4.2. The tables and columns are: article.article_title keyword.keyword Where there is a many-to-many ...
0
votes
1answer
13 views

Do we have logging feature for SQL AUDIT like we have it for transaction and error logs in SQL server 2008?

Do we have logging feature for SQL AUDIT like we have it for transaction and error logs in SQL server 2008 ????
1
vote
1answer
23 views

Unexpected results with soundex() function when combined st_distance()

select soundex(A.name), A.gid, A.name, soundex(B.name), B.gid, B.name, st_distance(B.the_geom,A.the_geom) * 111.325 as dist from (select name, ...
-1
votes
0answers
34 views

Query tuning and index creating [closed]

I am going to create indexes in one table using Oracle SQL Developer. The table has 60 columns, but on which column(s) do I need to create index(es)? Based on belevel or distinct or date or names or ...
0
votes
1answer
18 views

How to use explode mysql function in where condition with cakephp

I am using cakephp 2.6. I have payment_method fields in mysql table which store the values like 54,52,59,57 . Now my question is that how can i check if new posted payment method id is available in ...
0
votes
1answer
26 views

Need to run query if value in tb1 col1 is 1 and value in tb2 col1 is 1 than run the Insert into query otherwise don't run it [closed]

Two servers. Server A and Server B both has database named KPS. KPS has two tables complaint and attachment. KPS database on server A gets the value from the Web. both table if the submitted value = 1 ...
1
vote
0answers
111 views

Generally unsolvable problem? How to ORDER BY aggregated columns GROUPED BY many possible columns very fast?

Is there general solution or some best practises or at least some vague hint, how to solve following problem (general, but concretised in following example)? I think this must have been solved many ...
1
vote
0answers
16 views

SQL Agent job history not found for few jobs

I have;backup ,rebuild Indexes , Update Stats and few other jobs like space alerts, replication jobs etc which run frequently on SQL Server 2102-SP2, Build Number:11.0.5058.0 and I do not see any ...
2
votes
1answer
47 views

Selecting max(date) from union query

I am having a bit of trouble getting accurate results from a query that looks to me as if it should work. RDBMS is MySQL. I am trying to get the max last login date from a union select on three ...
0
votes
2answers
102 views

How can i use the same query for all codes?

I use this query in PHPmyAdmin, i have date that contain(date,hour),supp, price and code_product (it repeated many times) : I want to return the last price for the last date of product code ...
3
votes
1answer
41 views

SQL Server 2008 R2 Mirroring issues

I have this very frustrating problem that I've been trying to figure out for almost a week now. I have two SQL Server 2008 R2 STD w/SP3 box running on Windows 2012 R2 with two instances each, Server1 ...
1
vote
3answers
85 views

Get rows changed between two dates (latest and previous)

I have a table _sync_history with this data: +----+----------------+---------------------+ | id | object_name | sync_time | +----+----------------+---------------------+ | 1 | territory ...
12
votes
1answer
859 views

Best way to write SQL Query that checks a column for non-NULL value or NULL

I have a SP with a parameter that has NULL as default value and then I want to do a query like this: SELECT ... FROM ... WHERE a.Blah = @Blah AND (a.VersionId = @VersionId OR (@VersionId IS NULL AND ...
0
votes
2answers
65 views

Two columns into three and add rows automatically

I need help with a SQL query that it is very complex for me. I have a table with two columns where the first column is the order_id and the second column is for the products added to that order. It ...
0
votes
0answers
8 views

how to find and replace text in phpmyadmin

we are migrating from one domain to another domain. usually we will foloow the procedure of "open the database file in notepadd++ software and find and replace old-doamin-name to new-domain-name. ...