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
0answers
10 views

how to avoid duplicate record with certain conditon

I have a table with data like below +----+--------+-----------+----------------+ | id | name | testfield | status | +----+--------+-----------+----------------+ | 1 | raju | 11 | ...
0
votes
0answers
11 views

Weed out certain rows where timestamp is within interval

Given a table structure: create table contacts ( contact_id int(8) not null auto increment, #primary key pid int(8) not null, #personal id contakt_time datetime, ...
0
votes
0answers
5 views

missing rows with empty value in hibernate query

I have two tables with foreign key references: Comm TABLE: +----+------------+ | ID | NAME | +----+------------+ | 1 | comm name1 | | 2 | comm name2 | | 3 | comm name3 | +----+------------+ ...
0
votes
1answer
20 views

select row where a couple of column values is different

I have a table A with thoses columns : date, ip, created_by. I would like to display date, ip and created by of rows where for one ip it exists different created_by. Thank you I explain more : ...
1
vote
2answers
15 views

sql join with laravel query builder

I have a transactions table with the following field: Transactions ID | amount | branch_id | supplier_id 1 | 1,200 | 2 | 1 Subsidiary ID | Name | Type 1 | supplier1 | 0 2 | ...
2
votes
1answer
14 views

How to do housekeep the database in sql server 2008 by specific date range?

I have database with around 160 GB size. The database contains the data is from 2013 to until today, there are 180 tables, I want to remove the records in specific date range like 2013 to 2014 in all ...
2
votes
0answers
11 views

How do I keep a postgres table up to date using instagrams api?

I want to update a table in postgres with the response I get from the instagram api. I saved the response as a json file and imported it using navicat but when I saved the import job in navicat it ...
0
votes
0answers
8 views

Reading from the sysaudits table - Sybase ASE 15.7

I am currently trying to collect the audit logs from the Sybase ASE 15.7 sysaudits table. A SIEM will be using a query to read the audit logs. Since the sysaudits table can be read by users with SSO ...
0
votes
0answers
18 views

Complicated MySQL table reorder

I should do really complicated tables reorder. ****The main table looks like:**** id - some data 1 - ... 2 - ... 3 - ... 6 - ... 9 - ... 12 - ... As you can see, there are "empty" IDs (no 4, 5 ...
-3
votes
0answers
7 views

a phpMyAdmon database question [on hold]

I have two tables in database of phpMyadmin. One table is symptoms table, and 2nd is diseases table. The symptoms table has two columns: smpid and symptom The diseases table have three columns: ...
4
votes
0answers
22 views

Is this a sane model for a network provisioning system?

I'm sketching out a model for a network setup, where I have the following conditions: 1. There are multiple nodes which contains a number of switches each. 2. Each switch has multiple services, which ...
3
votes
1answer
21 views

Single table or multiple table design when records have a clear distinction but are queried together?

Let's say I have the following types of recurring data (all types periodically come in). Post (Title, Summary, Text, Timestamp) Image (URL, Caption, Timestamp) Event (StartDate, EndDate, Title, ...
3
votes
1answer
24 views

Importing via sqlcmd errors out

PS C:\Users\administrator.INTERNAL\Desktop> sqlcmd -S SQLMAIN\MSSQLSERVER -i rdmdb.sql Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : SQL Server Network Interfaces: Connection string is ...
4
votes
1answer
36 views

Select a count with some conditions

Using Postgres 9.4, I have a table page_views which has a page column. I'd like to select all the distinct pages and have a count before them and sort them descending. I'd also like to have a minimum ...
1
vote
1answer
17 views

Trigger is failing with no errors at all, why?

I need to UPDATE territory_id column at pdone.reps table by using and filtering results from veeva_new.userterritory so based on the answer I got here I am trying to build my own and this is how it ...
3
votes
1answer
22 views

Information about a column and the data it holds?

I'm working with a table that has 3 different dates associated with each item in the table. I don't understand what each time is so I want to know if there's a standard place that the person who made ...
3
votes
3answers
34 views

How to select a row based on the maximum value of a column, when ties are expected

SUBSCRIBER DATE TIME VALUE aaa 23-04-2015 04:04:07 10 aab 23-04-2015 12:04:32 5 bbb 23-04-2015 01:04:05 20 bbb 23-04-2015 ...
1
vote
1answer
56 views

My SQL Server table identity is incrementing way too fast

I have a table with pretty basic design: 1 primary key (id), 1 unique column (filename) (the filename of the file I am tracking) The primary key is an identity column (bigint) (I had to make it ...
-6
votes
0answers
20 views

How to join more than one table [on hold]

I'm stuck with one SQL query, the result as the image below : Could you help me to solve this problem? I already tried but the result is repeatly. And I don't know why? I followed the link How to ...
1
vote
1answer
36 views

Update records from one table to another in different databases where condition is accomplish

I have two tables stored in two differents DBs and I need to perform some sync between both tables based on lastmodifieddate and lastSyncAt. Let's call them as db1 and db2. This is the DDL schema for ...
3
votes
1answer
36 views

How to get the difference in days between 2 timestamps in PostgreSQL

I have a table named accounts. I am interested in retrieving those accounts whose status has not been updated since more than 10 days. I thought about this query and it seemed to work but I am not ...
3
votes
3answers
64 views

Insert data between 30 minute time intervals

I want to divided my to my time interval depending to the start time and end time. To explain it further, let me have this example. I have this table: User Elapsed Time Start Time ...
-1
votes
0answers
34 views

How to execute stored procedure from other database?

I have 2 databases. Example: db1 and db2. And db1 has a stored procedure sp1 with an input parameter. db2 has a stored procedure sp2. I am trying to execute sp1 in sp2. I tried below: I know it ...
2
votes
0answers
15 views

Sum of points and rank according to points with join three tables [duplicate]

I am creating a game where I am calculating the user points on the basis of user activities. Everything working fine I got the sum of points and on the basis of points I calculated the rank. I have ...
2
votes
3answers
56 views

Sum of points and rank according to points

I am creating a game where I am calculating the user points on the basis of user activities. Everything is working fine - I got the sum of points and on the basis of points I calculated the rank. I ...
0
votes
1answer
27 views

default constraint issue

I have a table say tempTable with one column having a default constraint ALTER TABLE [dbo].[TempTable] ADD CONSTRAINT [DF_TempTable_Version] DEFAULT ((1)) FOR [Version] Version decimal (18,1) ...
6
votes
1answer
39 views

How can I combine two event tables into a single timeline, in PostgreSQL?

Given two tables: CREATE TABLE foo (ts timestamp, foo text); CREATE TABLE bar (ts timestamp, bar text); I wish to write a query that returns values for ts, foo, and bar that represents a unified ...
-1
votes
2answers
36 views

Creating Stored Procedure with TableName as parameter

I am attempting to create a stored procedure where a table name is passed as a parameter, as well as updating contents of the table. Here is my code I have so far. ...
0
votes
1answer
22 views

Formatting a DATE type in an Oracle database to only accept MMDD

Is there a way to limit the inputs into a DATE type in an Oracle database to only accept inputs formatted with only the day and month (not including the year)?
-1
votes
0answers
5 views

SendObject Command

So I have sorted out alot of the problems with query etc. Is it possible to have a DoCommand Send object to send a report to the emails in the query. I need the report to be the one referenced in the ...
1
vote
1answer
32 views

Alter of stored procedure and execution performance

I would like to understand how an alter of a stored procedure without modifications can impact performance. I had a situation where a production environment had its database schema updated and a ...
0
votes
0answers
7 views

ALTER SESSION from a Control File

I am using a Control File to import data from a CSV file into a table, using sqlldr to import the data, where a large number of fields are numeric values with integer and decimal part separated by ...
0
votes
0answers
20 views

Getting TEXT data from postgres throught linked server to MSSQL

I'm using MSSQL 2008 R2 with linked server to postgres 9.4. My problem is: when I select column with data type text it shows me only XXX first chars and adds (...) on the end. select description from ...
-2
votes
1answer
41 views

Recursive cte addition in SQL

I need to add the total value to the parent nodes.(totaling the total value to base to top levels). 118 records are there and 1-8 levels. Root ACCCODE='00001' Root ACCPARENTCODE='0' Eg: adding ...
2
votes
1answer
31 views

table structure for events

Got a bit stuck, need a hand. I need to store events at the database, and events may happen at different location multiple locations at the same time so these are my tables CREATE TABLE ...
1
vote
2answers
24 views

Select data where column value exists in seperate rows for same reference id

This is on a MySQL database. Locations have services. What I want is to get all results where service_id is 2 AND 3, not OR so using IN is out I believe. Database ---------------------------- | ...
-5
votes
0answers
35 views

Why isn't my query returning the correct results? [closed]

I am trying to get information from several tables that I need in order to produce a report of all the stopped services on our critical servers. This query for some reason works if you switch the ...
-4
votes
0answers
19 views

SQLPLUS QUERY HELP [on hold]

Please help to create what might be a simple query for you; very tricky for me. Maybe a nested query?... or maybe a "For Loop". Thank you! Table name: WO_OPERATION Relevant Columns: ...
4
votes
1answer
102 views

Find rows where data resets

So I have a table tbl where I'm trying to pull data that increments at a variable rate. I need to identify when the data resets so I can make a cumulative value. Here's an example table: ID VAL ...
4
votes
2answers
128 views

Reseed identity column in all empty tables [duplicate]

I need to write a query that resets the identity on all tables that have an identity column and are empty.
0
votes
0answers
9 views

Why are some of my migrated tables showing “The given key was not present in the dictionary” in WebMatrix's interface?

I'm having an issue while using the SQL Server Migration tool to convert Access accdbs into SQL Server 2014 Express. I am converting the tables using SQL Server Migration Tool and I have a connection ...
-9
votes
1answer
52 views

Stored Procedure which INSERT, UPDATE, DELETE any table(for any table) where table name and its values are passed as parameter [closed]

Stored procedure which performed operations like inserting data to table, updating data, and deleting data of table where table name is passed by parameter. Parameters of stored procedure: table name ...
5
votes
3answers
157 views

Postgres is performing sequential scan instead of index scan

I have a table with about 10 million rows in it and an index on a date field. When I try and extract the unique values of the indexed field Postgres runs a sequential scan even though the result set ...
3
votes
1answer
22 views

How to change location of SQL Server 2012 database which is already configured with a merge replication

I have SQL Server 2012 configured with merge replication. currently the location of the replication database and the .mdf and .ldf files reside in C:\ drive. The C:\ drive is now full due to that ...
0
votes
2answers
59 views

Is it sensible for a web app to log every DB command? [closed]

Trying to figure out what my web app should log. From a security perspective and a storage perspective, does it make sense for it to log every SQL DB command? If not, what should it log?
-2
votes
0answers
13 views

Updating data from one database to another [closed]

I have two database, PLAYEMASRTL and TmsEPly, I need to update the former with information from the latter. I am currently trying to use this update statement but am running into a lot of invalid ...
3
votes
1answer
75 views

MySQL: UNION query to get a line for each date

Table1 DATE SKU QTY 2015-06-20 ABCD 3 2015-06-20 ABCD 1 2015-06-21 ABCD 5 2015-06-23 ABCD 2 2015-06-20 EFGH 1 2015-06-21 EFGH 3 Table2 DATE ...
3
votes
3answers
162 views

Make a column for each count(*) in a day of the week

I have a table of people who are doing piece work. Every entry in the table has a user-ID, name, and a Date for each report they enter. I need to make a weekly report of what these people have done ...
0
votes
1answer
28 views

Query Access Question

With one table tblBids containing BidId field with the relationship bidID has multiple contractors from tblContractors, I am trying to create a query which will list each contractor and email address ...
1
vote
1answer
30 views

Order By with duration strings having time units

I have a SQLite database with a table "Rate" who has a column "timeToMaturity". This column contains strings such as : 7Months 26Days 3Years I'd like to order a query results by timeToMaturity ...