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
2answers
5 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 ...
0
votes
0answers
6 views

Sending an automated email through a nightly job

I had the following SQL query: select substring(PostOfficeBox,1,4) as 'Postcode' , COUNT(CASE WHEN New_accounttype = 1 THEN New_AccountType ELSE NULL END) as 'New Connections' , COUNT(CASE WHEN ...
1
vote
1answer
124 views

how to group data against more than one conditions

I have a table named Employees with below two columns. ================== Employees 1- EmpId (auto incremental id) 2- EmpName (varchar) There is another table named 'LateDays' with below five ...
0
votes
3answers
448 views

Mysql - How to Optimize Retrieval Time in a Table

I have query like this! which has 200 million Records in a single table.. I am using BTree Indexes in my table... mysql> select COUNT(DISTINCT id) from [tablename] where [columname] >=3; ...
0
votes
1answer
239 views

Data Analysis with MongoDB or MySQL

I have a need for processing some data in order to come up with some statistic. This is the scenario: Each user can answer several questions from the question list. They pick their answers from a ...
3
votes
2answers
118 views

Postgres is a performing a 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 ...
4
votes
1answer
87 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
0answers
16 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: ...
3
votes
1answer
61 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 ...
-7
votes
1answer
35 views

Store 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 ...
-4
votes
0answers
27 views

Why isn't my query returning the correct results?

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 ...
3
votes
1answer
14 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 ...
2
votes
1answer
2k views

Extract MySQL information from a compressed tar.gz file

I have a back up-of a MySQL database which is contained in a .tar.gz file - I need to restore it. I've never had to do this before. The only way I can access the database is through phpmyadmin. There ...
4
votes
2answers
114 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
6 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 ...
1
vote
1answer
1k views

SQL Server 2005: Integration Services Stored Packages is empty. Why?

I am trying to import, export SSIS packages. I know they are there. When I query msdb.dbo.sysdtspackages90 I get 22 packages. But when I connect to Integration Services on the server, the stored ...
2
votes
3answers
26k views

Oracle password has expired, however I have no way of changing it

When I connect to my local development database, I get an error saying the password has expired. I've been trying to change it with sqlplus to no avail: C:\>sqlplus ...
1
vote
4answers
63 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
vote
1answer
29 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 ...
3
votes
2answers
85 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 ...
3
votes
3answers
136 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
55 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?
4
votes
2answers
3k views

Query across multiple schemas, unknown until execution time

I have multiple schemas that I need to query across. The schemas are not known in advance, for example: U111 U222 U333 I need to select across these three schemas from a specific table in each of ...
-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
3answers
146 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
27 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 ...
0
votes
3answers
89 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
1answer
162 views

Connect by prior - multiple fields and query efficiency

I have 2 tables one of which defines the hierarchy for the other equipment id desc 1 item1 2 item2 3 item3 4 item4 5 item5 6 item6 7 item7 8 item8 ...
0
votes
2answers
52 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
20 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 ...
0
votes
0answers
89 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 ...
12
votes
2answers
166 views

What programming language is this?

:#PCA=Campaign//CampId//CampDesc//CampBusId = 2 :#PE=PubEdition//EdId//EdCode//EdCampId = :#PCA :#PCT=ContactType//ContTypeCd//ContTypeDesc//ContTypeUsrId in (21, 25) ...
1
vote
1answer
16 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`, ...
1
vote
2answers
121 views

Is unique index better than unique constraint when an index with an operator class is required

Postgres docs say: The use of indexes to enforce unique constraints could be considered an implementation detail that should not be accessed directly. One should, however, be aware that there's ...
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
41 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
55 views

How to get data of two column from two table?

I have two Table MATCH_MASTER and TEAM_MASTER MATCH_MASTER |---------------------------| |M_ID | TEAM1_ID | TEAM2_ID | |---------------------------| | 1 | 1 | 2 | And Another table ...
0
votes
1answer
163 views

How to check mysql password change and other events logs

Recently someone change my phpmyadmin password and drop database I think it was sql injecting. Now I want to find information about this like when, how and who change my password Please tell me ...
1
vote
1answer
29 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 ?
0
votes
2answers
702 views

Netezza Error Record size 120000 exceeds internal limit of 65535 bytes

I have a column PARAM that has JSON data that looks like this: JSON:{"Name":"RES_InformationalIssues","StepName":"Page_1","StepData":"f601e9fe-d68a-4ed7-bbaa-f40c9cbc4d12=General Product ...
0
votes
2answers
32 views

Query of multi-valued field

I have 2 tables: Contacts and 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
23 views

sql query group by data of certain range in continuous date

I want to Write a sql to query group by data within a certain range in continuous date.I'm usig T-SQL. Table: Date | MeterNo| Data | ---------|---------|---------| 01-06-15 | 12345 | ...
2
votes
1answer
26 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
1answer
213 views

Not able to update MySQL table using Oracle: Unknown column in 'where clause' {42S22,NativeErr = 1054}

I have the following tables: MySQL table: jti_member_interact CREATE TABLE `jti_member_interact` ( `INT_MEMBER_ID` int(11) NOT NULL, `INT_ID` int(11) NOT NULL AUTO_INCREMENT, `INT_SOURCE` ...
0
votes
2answers
217 views

Idea for manking tables for a pharmacy

OK I'm not into Database management, but I got this problem, also not sure if I'm posting it at the right place or not. So, my Dad works in a pharmacy and all the work there is on paper and is done ...
0
votes
0answers
23 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: ...
1
vote
2answers
946 views

Unnest multiple arrays into rows

I have been shown a great way to bulkinsert with this example: WITH p AS ( INSERT INTO parent_table (column_1) SELECT $1 RETURNING id) INSERT INTO child_table (parent_table_id, ...
0
votes
0answers
32 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
112 views

How to merge two databases, both with primary keys

I have two databases, both with the same tables, but the data is out of sync. I need to add data from database A to database B, but not overwrite any data in B that exists in A, instead add it with a ...
0
votes
0answers
14 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 ...