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

Create an “int” column forced between 0 and 3

I would like to create a table with one column that would be of type "integer", and locked between 0 and 3. Is this possible? My goal would be to have this column so that I could just execute a ...
1
vote
1answer
33 views

Nightly Excel Spreadheet import into mssql database

I am currently working with a nightly import that I need to create, but am not sure what the best route would be to update/insert into the current table. This is all done in MS SQL Server 2012 and ...
0
votes
2answers
78 views

How to compare dates in SQL?

In a database table I have made a date attribute, but I have set its type to varchar and not Date. My question is: will I still be able to compare such dates in a SQL Query? Dates in my DB are stored ...
1
vote
2answers
35 views

Group by month in result columns?

I'm using this DBMS: Caché I've never used a pivot table in SQL and I'm not even good at it in Excel, but I assume that's what I need. Given the following sample data: ID Name Result Date ...
0
votes
2answers
37 views

How to match regular expressions in Oracle?

I'm using the following query: select * from table WHERE POSTAL_CODE LIKE '[a-Z][0-9][a-Z] [0-9][a-Z][0-9]'; However, this is not capturing anything. For example, a typical POSTAL_CODE looks like ...
1
vote
1answer
18 views

How can I insert procedure results from server 1 into table in server 2?

The goal is to link our website to the database. The database the website will connect to will be different then our production db. In fact, a separate instance of SQL. How can this be structure to ...
0
votes
1answer
29 views

combining 2 sql queries based on different conditions

I have a table : Person : (integer) (varchar) (Date) (date) id state d1 d2 1 'ALIVE' '2015-08-07' '2015-08-08' 2 'DEAD' '2015-08-08' ...
0
votes
3answers
70 views

Min(date) in sum case statement [closed]

I'm trying to write a statement where the settled date is less than the min(duedate) but I'm getting this error: Msg 130, Level 15, State 1, Line 32 Cannot perform an aggregate function on an ...
0
votes
2answers
57 views

simple mysql query design help

Simple query design help. Below is my query: SELECT tkt.ticket_id, tkt.`number`, val.field_id, FF.name, val.value FROM os_TICKET tkt, os_form_entry_values val, os_form_field FF where ...
3
votes
3answers
113 views

Proper way to store a value that could be multiple different types

I have an Answers table and a Questions table. The Answers table has a value, but depending on the question, this value could be a bit, nvarchar, or number (so far.) The Question has a notion of what ...
0
votes
1answer
47 views

Is there a database tool that bashes data with HUGE excel files?

Ok this is hard to explain and im not sure if this is the right place to ask it but. Im 2 weeks in on my new work and I feel like our work can be a lot more easier if we dont rely on just Excel for ...
-1
votes
1answer
31 views

combine multiple rows into single row when its id is same [closed]

i tried this query select subject_id,Register_No, Stud_Id, Std_Id, Roll_No, Chachani_1,Gruhpath_1,Practical_1,Tondi_1,Lekhi_1,Total_1,null Chachani_2,null Gruhpath_2, null Practical_2,null ...
1
vote
2answers
223 views

Help with recursing self-referencing table

I have two tables: Datasource ( A self referencing table) ------------------------------ Id, Type, ParentId, Name 1 A NULL Foo 2 B 1 Bar 3 C 1 FooBar Variable ...
0
votes
1answer
26 views

PostgreSQL to MS Access

Is it possible to create a database in PostgreSQL move it into other computer and use this database with MS Access? How to do that?
0
votes
2answers
48 views

Oracle Error: the sga requires more space than was allocated for it

(Oracle SQL 12c running on Windows 10) My installation has previously been working fine. I was trying to set up one of my tables to use the In-memory option available in 12c. I was following this ...
1
vote
3answers
50 views

Query for lowest price for product in same row

I have two tables: first for products and second for prices. I need to calculate and display the minimum price from all 5 prices for one product. I already have query to select five prices and ...
1
vote
1answer
49 views

Why is FORCE JOIN option slowing down query and forcing execution plan to sort prior to joining tables?

I'm linking Orders data with the Results data for those orders. Here's the SQL query for joining and selecting the ; with orders as ( select o.*, otr.*, oo.* from Order o inner join ...
1
vote
2answers
55 views

How does ORDER BY FIELD() in MySQL work internally

I understand how ORDER BY clause works and how the FIELD() function works. What i want to understand is how the both of them work together to sort. How are the rows retrieved and how is the sort ...
1
vote
1answer
25 views

convert 1 row as column and concatenate the results to the corresponding column

I have 2 tables table 1 - apps ----------- id | name ----------- 1 | abc ----------- 2 | sdf ----------- 3 | dfg ----------- table 2 - contacts ------------------------ id | cnt_type | ...
1
vote
1answer
49 views

Selecting 1st and 3rd Tuesdays

So here is my situation. I am trying to write a script which will (among other things) allow me to measure prime time block utilization. For reasons unknown to and unchangeable by me, various ...
2
votes
2answers
40 views

How can I count all children & grandchildren until the 7th level?

I have 3 tables right now 1. members 2. members_parents 3. members_status How can i count the children & grandchildren until to the depth level and separate the count() for the status 0 = ...
2
votes
0answers
29 views

Upgrading SQL database resulting error [closed]

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

how to select the date from the tables?

I have two tables: CSS533 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 tables should be ...
3
votes
0answers
41 views

Efficiently computing aggregate functions over subqueries with incremental data

I have a PostgreSQL database (version 9.3.6) 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 ...
0
votes
2answers
108 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
1answer
30 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
16 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
29 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
51 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
114 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
65 views

Dynamic Filters in SQL server [closed]

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 ...
1
vote
1answer
23 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
60 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
47 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 ...
1
vote
2answers
100 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 ...
1
vote
1answer
29 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
21 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
97 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
51 views

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

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
34 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
32 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
vote
2answers
92 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
69 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
29 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
41 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
36 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
26 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 | ...
1
vote
1answer
16 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
35 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 ...
1
vote
1answer
32 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 ...