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)

2
votes
0answers
16 views

Upgrading SQL database resulting error

I've currently updated my SQL environment and moved everything over to a new database. This includes the BizTalk service we are using. However, when I retired my old database, I started to received ...
0
votes
0answers
11 views

how to select the date from the tables?

I AM HAVING TABLE CSS533 I AM HAVING TABLE CSSSERV I want to select SERV_ACCT_NUM and BID_TYPE_CODE from CSS533 and SC_START_DATE and SC_END_DATE from CSSSERV where SERV_ACCNT_NUM for both ...
2
votes
0answers
10 views

Efficiently computing aggregate functions over subqueries with incremental data

I have a PostgreSQL database containing a large number of orders. As the orders are processed, scan_events are triggered and stored, with multiple events per order. Scan events have a boolean ...
0
votes
0answers
19 views

What is the best way to find out the sum of a field from a table?

I am making a accounting software. I have a table debit_credit that contains double entry accounting data.Table is: debit_credit_id | tran_id | ledger_head_id | debit | credit | dr_cr | commission | ...
0
votes
0answers
27 views

how to select from the two tables?

I am having table 1: I am having table 2 I want to select PRIMARY_ENTRY_NUM from table1 where TABLE_ABBRV_CODE FOR BOTH TABLES SHOULD BE SACT AND TABLE_ENTRY_NUM for both tables should be same and ...
0
votes
0answers
15 views

SQL Login import [on hold]

I am attempting to create a SQL login for a connection to my database. Background: I took a database from server 2005 and upgraded it on SQL Server 2008 and then moved it to 2014. Its original ...
-3
votes
1answer
33 views

Finding uniqe values from one table and calulating total number from another table that have unique values from first table [on hold]

I stuck on calculating values Name of table: dabase_123 Demo of table: program | quantity windows xp--------30 windows xp--------30 windows xp--------30 linux ubuntu -------80 I can filter ...
0
votes
1answer
16 views

how can I count by week, month, and YTD with postgres?

under PGSQL 9.3 I am trying to run a query to summarize some data from table a: | Entry date-Date | Customer ID-charvar | received-Boolean | Processed-Boolean | finalized-Boolean | billed-Date | I ...
0
votes
1answer
12 views

Long full scan hasn't returned but session is gone from V$SESSION

I have a query on a big table purposefully hinted with /*+ FULL() */ and uses partition pruning, and for a while the scans for each partition can be seen in V$SESSION_LONGOPS. After a while no more ...
1
vote
0answers
27 views

How to represent multiple unique constraints across hierarchical tables?

My (shortened) table definition is: CREATE TABLE bus ( id integer NOT NULL PRIMARY KEY, name character varying NOT NULL CHECK (name<>'') ); CREATE TABLE network_node ( id ...
1
vote
2answers
47 views

Compatibility level 100 on SQL Server 2008 R2 [duplicate]

I'm upgrading my databases to compatibility level 100 on SQL Server 2008 R2. My next step is to check if my stored procedures, functions, views, triggers are still working properly. Running each of ...
0
votes
0answers
40 views

The target principal name is incorrect. Cannot generate SSPI context - SQL Server 2012 error

I don't understand why this error is popped up suddenly. It was working till yesterday. It is a stand alone env. Problem is when me or any user wants to connect from their machine locally it is ...
0
votes
2answers
50 views

Dynamic Filters in SQL server [on hold]

I have problems with my dinamic filter in 'sql server'. My problem is that the filters aren't working. When I try to execute the store procedure I just get all the data without filtering. I'm new ...
0
votes
0answers
39 views

How to fetch two column different row values in sql [on hold]

I need emp table column name is ename 'Martin' and 'jones' details and in job column who every working as 'clerk' they both want to fetch Martin and jones are working in different jobs
1
vote
1answer
12 views

Replication with fail over cluster in SQL Server 2014

Presently I am Using Replication Feature in SQL Server 2012 .I want to migrate to SQL server 2014 .I want to use fail over cluster feature .Does it effect the replication feature which we are using ...
0
votes
2answers
57 views

Select statements during long update

I've a table MESSAGES id (long) | attach_data (image) | ins_date | flag this table contains all messages of my application. During night, my job cleans old attach_data with query update messages ...
1
vote
0answers
41 views

SQL Server Profiler

I had run a SQL trace on SQL server 2008 r2 and had originally saved it to the table format. This table now resides in the database and I was wondering could I export the contents of the table to a ...
0
votes
0answers
11 views

i have a roll_no,semister_id and marks of semister i want to show result like roll_no semister_1 and semister_2 [on hold]

I have a roll_no,semister_id and marks of semester, and want to show result like roll_no , semester_1 and semester_2 [As shown below]
1
vote
2answers
79 views

How to tune a stored procedure that is fast on test data but slow in production

If you have a SQL Server 2012 database with test data in development and preproduction phase and the real from the company's server take place only in the production phase. In other words, the real ...
0
votes
1answer
25 views

Deleting near duplicates based on one varchar field

I'm getting around to cleaning a database but I need some help with deleting near duplicates in MySQL database but is only off by one character in a column. I've searched and found ways to remove ...
0
votes
0answers
18 views

Compare values between columns in different tables

I have two tables that looks exactly the same: CREATE TABLE `_sync_history` ( `id` int(11) NOT NULL AUTO_INCREMENT, `object_name` varchar(45) DEFAULT NULL, `sync_time` datetime DEFAULT NULL, ...
2
votes
1answer
74 views

select n values per group

Lets say I have the following table ----------------------------- | user_id | comment | ----------------------------- | 2 | thats cool | | 2 | awesome | | 3 ...
0
votes
2answers
46 views

How many passes of a table are done with UNION ALL? [on hold]

I am trying to run a single query that will make a single pass through a table, and was wondering if by using UNION ALL to make counts of total row unioned with counts of unique rows so I would be ...
2
votes
1answer
24 views

How to write a query that counts rows by date?

I have a database named emp1. There is a table named tx_feeder. I want to get the count of rows from that table. I have used the following query to get the data of single day, select count (*) ...
0
votes
0answers
23 views

Creating a trigger to update field in 1 table based on values in another table using data in multiple rows

I'm new at SQL and need to create 2 triggers between 2 tables. Table 1 has the following columns: tbl1.ContractID char(6) tbl1.ContractFulfilled char(1) Table 2 has the following columns: ...
-1
votes
1answer
17 views

T-SQL Trying to create a trigger that uses joins across 2 server instances [on hold]

I am trying to complete a trigger on 2 instances of SQL Server. I am running MS Dynamics ERP set CRM & GP. I need to remove data from one server once an update happens to another table. I have ...
-1
votes
0answers
44 views

Design for fast database query over millions of rows [closed]

I want to query in a database like : Let us consider a student table with the following attributes: (Id, Age, CGPA, Address, Gender). Our table contains record for all the student in the world (so my ...
1
vote
2answers
71 views

Minimum value on most recent date per account MS ACCESS SQL

I have a MS ACCESS DB table Riskscore with the three fields: CHACCTBS, CHRQDATE, CHSCORE and want to find the lowest CHSCORE on the most recent CHRQDATE per CHACCTBS where it is possible to have ...
1
vote
1answer
48 views

Update Table Query: Automatically handle “Enter Parameter Value” prompts?

EDIT: Here are two database Files that demonstrate an applied example of the problem: Example_DBs.zip (Zipped due to 2 link limitation.) Note: The missing Field in "Not Working.mdb" is ...
1
vote
1answer
28 views

Modulo operator with nonintegers - unexpected results

MySQL 5.5.32, Oracle 11g MySQL returns strange results for queries involving mod() with noninteger moduli. Why is this? I have a column defined thus: ...
1
vote
2answers
29 views

MYSQL find if a default value has been set for a table (DateTime Specifically)

I am trying to internationalize a database, but there are places where the timestamp that gets set is using NOW() instead of UTC_TIMESTAMP(), and it's using Amazon's RDS with multiple MySQL servers. ...
0
votes
0answers
29 views

INSERT INTO SELECT causing data to double

I have strange issue. I am working in a Teradata database. In a procedure I am populating a main table by processing data via multiple intermediate tables. But in the end only one table is populating ...
0
votes
1answer
23 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 | ...
-4
votes
0answers
23 views

what is update cascading exactly in sql? [closed]

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 ...
1
vote
1answer
14 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
24 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
25 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 ...
-1
votes
0answers
39 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
30 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
42 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 [closed]

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 ...
7
votes
2answers
80 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
24 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
30 views

Correction of a complex query [closed]

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

Modifying a query for the UPSERT command [closed]

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
16 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 ...
2
votes
4answers
108 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
30 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
46 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 ...
2
votes
2answers
35 views

Ensure only one of the several records for a given item has a column with true value

I have a table called Computer with columns: id NIC_name is_primary My primary key is (id, NIC_name) and is_primary is a bit field for a boolean value. I would like to ensure that for all ...