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
4 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, ...
0
votes
1answer
13 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
33 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
16 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 ...
1
vote
1answer
18 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 ...
2
votes
3answers
25 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 ...
0
votes
1answer
36 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
35 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
35 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 ...
2
votes
3answers
59 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
33 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
1answer
13 views

Sum of points and rank according to points with join three tables

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
2answers
53 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
26 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
35 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
21 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
40 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
28 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
34 views

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

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

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
101 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
127 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
48 views

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

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

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

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 [on hold]

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
160 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 ...
0
votes
2answers
58 views

Would like to know why this query is behaving this way?

I have an emp table, with schema and some initial values like below: emp_id | name | last_name | role_id --------+------+-----------+--------- 1 | hell | bell | 1 2 | well | ...
0
votes
0answers
22 views

Object refernce not set… Maintenance plans SQL server 2012

I need to perform a backup but while executing the existing maintenance plan, I recieve the following error message (also after creating new maintenance plan): Object reference not set to an ...
3
votes
3answers
154 views

INSERT/UPDATE in same query from previous SELECT with some singularities

I'm trying to perform a INSERT|UPDATE by selecting data from another DB and this is what I have so far: INSERT INTO pdone.reps (veeva_rep_id,display_name,username,`first`,`last`,email) SELECT ...
0
votes
2answers
44 views

SQL Server Database recovery from corrupt database [closed]

Last week I backed up my SQL Server by using Backup Exec 2012. I named the file "SQL Server BAK" which contained copies of my SQL Server databases. A few days ago I lost some part of my data due to ...
2
votes
3answers
44 views

How to show multiple names for one record but not duplicate the record?

I have a database structure like so: Car - id - carname - image - category - status Parts - partid - partname CarParts - carpartid - carid(fk) - partid(fk) - amountid(fk) Category - ...
1
vote
1answer
18 views

update query field order guaranteed

Is an UPDATE query in MySQL guaranteed to execute the field updates in order that are presented? e.g. UPDATE `table` SET `first_to_update` = `second_field`, `second_field` = `third_field`, ...
2
votes
1answer
33 views

How can I pass object to procedure from trigger? [closed]

I am using mysql 5.6. After insert or update, inside the trigger I am calling procedure, So how can i pass NEW and OLD object from trigger to procedure ?
2
votes
1answer
28 views

Table structure for validating data using category and subcategory fields

I am creating a simple budget application, and the primary table will be a transaction table that contains things like the amount of the transaction, date, account, the category and subcategory (the ...
1
vote
2answers
47 views

Query of multi-valued field [on hold]

I have 2 tables: Contacts Helpers The Helper field (which is linked to the Helper table) in Contacts is a multi-valued field so more than one helper can be selected and displayed in a report. ...
0
votes
0answers
24 views

Re-installing SQL Server 2008 R2

I uninstalled SQL Server 2008 R2 and I am trying to re-install. I get this error. Here is the part of the Detail Landing Page.txt: 2015-06-26 13:07:42 Slp: Running Action: ...
0
votes
1answer
107 views

Datediff with many dates causes poor performance?

I am a system programmer and entered the forum to understand a little more of the database. Currently I picked a query with a lot of data and I had to check there is a gap between today's date and the ...