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
11 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
15 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
47 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
30 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
2answers
41 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) ...
5
votes
1answer
19 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
20 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
31 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
38 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
27 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
23 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
100 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
126 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
8 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
153 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
73 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
156 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
57 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
148 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 [on hold]

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

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

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
46 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
102 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 ...
0
votes
3answers
90 views

Is it better to use an ID (int) or a Name (varchar) as PK for a table? [on hold]

Let's suppose I have an ORDERS_LINE table and a PRODUCT table and the ORDERS_LINE table must have the information of which product was ordered. I prefer to use a Primary Key based on the Name since it ...
0
votes
0answers
33 views

SQL Server Management Studio greyed out

We have an issue where Object Explorer will not display. When we choose View > Object Explorer, New Query, or press F8, we get: A generic error occured in GDI+.
0
votes
1answer
20 views

Printing comments or statements when executing script to a output file using TOAD/ORACLE

Coming from a SQL SSMS enviorment, I would like to duplicate their 'Print' Command which allows you to print commands or variables while executing a query. I am looking for this feature to help ...
1
vote
4answers
65 views

SQL retrieve last elements of table using group by like behaviour

I am trying without success to retrieve the last version of all articles in a table. The table structure: CREATE TABLE `journalarticle` ( `uuid_` varchar(75) DEFAULT NULL, `articleId` ...
-1
votes
0answers
3 views

cannot get 2014 cluster to start up

I am trying to get node 1 of a new 2014 FCI to start up. I just did the first node install and at the end of the install it says it can't start up the cluster. I thought about the CNO and VCO and ...
3
votes
2answers
89 views

check when last backup was taken

Brent Ozar had an interesing newsletter on 2015-06-22; How do you manage dbas measuring backups, where he thinks that a good DBA should check when the last backup was done it was last restored ...
0
votes
0answers
15 views

unsigned right shift '>>>' Operator in sql server [closed]

How to write unsigned right shift operator in sql server? The expression is like value >>> 0 Here is the e.g. -5381>>>0 = 4294961915
0
votes
0answers
22 views

http vs sql queries [migrated]

i have big problem deciding what approach to take, i have many pages on my site that uses tabs. for example a page with 5 tabs (horizontal tabs). now every tab takes data from different table in the ...
0
votes
0answers
33 views

How can I write a query to aggregate multiple strings into one field? [migrated]

I am trying to merge three tables. The first table has id and data_name, second table data_id, option_id and property, third table user_id, data_id. For example: first table +----+-----------+ | ...