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

How can we create a table from stored procedure?

CREATE DEFINER=`root`@`localhost` PROCEDURE `create_tb_one`(In tableName varchar(255)) BEGIN CREATE table tableName( ID INT NOT NULL, SNAME VARCHAR(100) NOT NULL, ...
2
votes
2answers
59 views

TDE on Replicated Databases

I have implemented Master-Slave replication between two databases, now i have to implement Transparent Data Encryption(TDE) in master database. is it possible to implement TDE in master only? whether ...
2
votes
1answer
69 views

Postgres Count with different condition on the same query

EDIT Postgres 9.3 I'm working on a report which has this following schema: http://sqlfiddle.com/#!15/fd104/2 The current query is working fine which looks like this: Basically it is a 3 table ...
1
vote
0answers
7 views

postgresql: deleting from a view

In Postgresql 9.4, we're doing a view as a UNION of to tables A and B, and we'd like to have a single DELETED N ROWS message when we 'delete' the records in the underlying tables (via a a trigger on ...
0
votes
1answer
14 views

Restore Postgres Database on New Machine

Trying to restore a postgres database on a new Macbook Pro. I recreated the database using createdb dbname then tried to restore the old database using psql dbname < dbname_dump.bin but ended up ...
-2
votes
2answers
50 views

What does the FullAccess. infront of table mean in SQL Server query? [on hold]

What does the "FullAccess" in the below query refer to? I have a table named ReceivedClaimFact but I do not have any Schemas named FullAccess in my Database. The query runs successfully though. ...
1
vote
1answer
15 views

Query Relating Rows W/O A Corresponding Value

I have a table setup like this: ID Code DateActive DateInactive statusCode 15 20090413 null A 15 null 20090416 I 15 20100101 ...
-1
votes
0answers
33 views

How can I take table as input dynamically from user?

I am new to SQL server and want to take table name and column names as input from user dynamically. Also, need to perform cursor implementation of comparing records on it. I have completed the ...
0
votes
0answers
27 views

How do I sum the counts of entries from multiple columns? [on hold]

I have a table with two columns, id1 and id2. Such as this: I want to be able to get the total occurrences in the table of the ids, which would look something like this: +-----+-----+ | id1 | id2 | ...
1
vote
1answer
46 views

Aggregation by positive and negative values

I have a table called "PROD_COST" with 5 columns: +----+----------+------+-----------+-------------+ | ID | Duration | Cost | COST_NEXT | COST_CHANGE | ...
0
votes
0answers
10 views

How to download sqlplus for running sql commands in windows 8? [on hold]

I am sorry, for bugging you all with a very silly question probably, but I just started learning data base management system, and today I attempted my first sql class where I had to login by providing ...
0
votes
1answer
20 views

Joining two tables [on hold]

How do I select all data from one table, based on all data selected from a different table? For example: Table 1: categories +-----+------------+ | cid | category | +-----+------------+ | 1-9 | ...
0
votes
2answers
44 views

ORA-01830: date format picture ends before converting entire input string

I am trying to run the query on an Oracle database select to_date(trunc(sysdate) || '13:00:00','DD-MON-YY HH24:MI:SS') from dual; and get the error ORA-01830: date format picture ends ...
0
votes
0answers
33 views

column values combination

I have chains of nodes like A -> B -> C -> F D -> E and store them in an Oracle table pair with 2 columns left_node and right_node left_node right_node A B B C ...
-3
votes
0answers
23 views

Program scrambled the screen [on hold]

I am having problem with my program I purchased. Program is in vb and database used is SQL Server 2005. Problem is that when I used to enter or query certain no of data its screen scrambled and I ...
0
votes
0answers
25 views

Normalize to 3NF Question - Postal Codes/City [duplicate]

Normalize to 3NF and design an ERD for the following data: Name Street City Province Postal Code Home Phone Cell Phone Just want to see if I am doing this right. PERSON NameID Name Phone Number ...
2
votes
2answers
63 views

Add a flag when certain conditions are met

I have a table where when an employee works LEAVE1 and LEAVE2 paycodes on the same day then in the new column called 'FLAG' we need to put a 1 for LEAVE1 and a 2 for LEAVE2, when these paycodes are ...
0
votes
0answers
26 views

What's better and faster — MySQL or XML based Filesystem [on hold]

Good day, my boss is trying to push a project to be used with a CMS called "Weblication". Weblication is a PHP Framework using only files in XML and processing everything with XSLT and PHP. So all ...
0
votes
0answers
11 views

Is there a way to set the data source in Report Manager for whole folder rather than each report?

I have few reports under different folders in Report Manager. Is there a way to set the data source for the whole folder rather than each report individually? There is also a folder where reports ...
0
votes
0answers
10 views

Create Trigger to increase the latest duplicate number [on hold]

I'm using SQL DB I need to create a trigger that if find duplicate in a specific filed 'driver.encoding' the latest duplicate value should be updated by increasing the value of the record 7th digits. ...
4
votes
2answers
14 views

Improve performance for order by with columns from many tables

Using PostgreSQL 8.4, I'm trying to consult two tables with 1 million records using order by with indexed columns of the two tables, and I'm losing performance (with 1 column takes 30 ms and with two ...
-3
votes
1answer
47 views

How does Oracle handle types in this UNION query? [on hold]

SELECT 1 FROM DUAL UNION SELECT '2' FROM DUAL; what does this give? knowing dual is default table and is a single row table.
1
vote
1answer
14 views

MySQL get previous record and compare

Need to make a Comparable between the records of this table and take the total times the value calledstationid 42 preceded the value 34 (this is a system log table and calledstationid is not an ...
0
votes
1answer
13 views

How to use a value from insert in conditional insert in postgres

insert into addresses(street, city, user_id) select 'street1','LA', 2 where exists (select * from users where users.id = $$$$$ AND users.storeaddress='true')) I want to insert address for a ...
2
votes
1answer
62 views

Scramble the data output of a stored procedure

I have a stored procedure that produces data for a call center system every morning. However, the data is sent in the same order daily. Is there a way to send the day in a different order every day ...
0
votes
0answers
17 views

Line terminators \r and \n

As i am working on this project i have couple of questions about line terminators and how to know which one to use when. 1) when i load data into two tables using just "\r", all desired data is ...
-3
votes
0answers
27 views

database is not getting restored second time with this query [closed]

USE master GO ALTER DATABASE Tfs_CoeTest SET SINGLE_USER WITH ROLLBACK IMMEDIATE; GO RESTORE DATABASE Tfs_CoeTest FROM DISK = 'D:\Backup123\Tfs_CoeTest' WITH MOVE 'Tfs_CoeTest' TO ...
0
votes
1answer
33 views

SQL Server 2012 - Can't detach database on mirror server

I'm running SQL Server 2012 in a mirror configuration and I need to move the mirror's transaction files. I deleted the mirror setup on the primary but I can't detach the databases on the mirror, the ...
1
vote
1answer
69 views

Matching data in two tables

I'm teaching myself SQL and I ran into a question that may be related to joining tables. I'm just a bit unsure. Say, you have two tables, one listing the customer's creditcard_number, and one listing ...
1
vote
2answers
65 views

Select highest id of each type in mysql

I am creating a database that keeps track of backups on our various servers. The query that I am using actually seems to work for the most part. The only issue is that it isn't getting the highest ...
0
votes
1answer
23 views

Slow query - just error count

I deal with slow queries in whole project. I indexed heavily but the results are nowhere. I had a lot of logs (thousands per minute) from SCADA systems and I am trying to count them for each SCADA ...
4
votes
1answer
36 views

Calculating daily growth using previous row value in new column - SQL Server

I have the following query below that shows size of a database and when this data was collected. I am trying to create a new column that has "average daily growth" which would be determined by the ...
1
vote
2answers
41 views

Noob questions on tables in a sql model

I'm a noob when it comes to SQL or PHP and I'm a creating a rather simple car-sharing web site. The user can engage a trip someone created and can himself create a trip. Now I'm currently designing ...
0
votes
1answer
46 views

Artificially increasing query time

Very weird question: Is there any way to artificially inflate the amount of time a query will take? An infinite loop would be great. SELECT CLAIM.UNIT_PRICE FROM CLAIM WHERE ...
3
votes
1answer
47 views

identify gaps and islands

I have a database that has the following structure +---------------------+------------+---------------+ | timestamp | EngOilP_sd | CompOilLVL_sd | ...
3
votes
2answers
51 views

Computed Column Update when Table Value changes

I have environmental sensors collecting some raw data from environmental stations. In addition to the sensors, there is a physical gauge measuring water height (staff gauge). I'm trying to set up the ...
-3
votes
0answers
20 views

duplicates of part.num to be summed and add another column called user [closed]

There are 3 columns part num, Qty and MO. Each MO has part numbers.So there might be same part numbers in MO's. Each part num has qty. So, if I group by part num, I get Qty. 1.There are duplicates of ...
2
votes
1answer
36 views

Case When over 2 columns return results into 1 output column

I have an issue in SQL Server (using 2014 but not sure that's relevant). I have 2 variables Q20 and Q46 which depending on result I want to output a value to the same column for each result. For ...
1
vote
0answers
17 views

Looking for a DR-like solution to enable full data warehouse re-load while having secondary copy live

I am looking for suggestions/ideas to the following problem. We have a number of data warehouses for each of our clients (on SQL Server 2014). These data warehouses are maintained fairly fresh with ...
2
votes
1answer
33 views

Oracle: REGEXP_LIKE: Strings with angle brackets aren't found (whether they are escaped or not)

The following question will answer my original question, plus many others. What would the correct syntax be to do a REGEXP_LIKE search (in Oracle Database 12c) for this string (which exists somewhere ...
3
votes
2answers
69 views

Query to calculate database growth

I have the following query that outputs some good information from MDW data collectors regarding database space usage. I am wondering with the following columns (db size, reserved space, unused space, ...
0
votes
1answer
29 views

A form including content from two tables

I am working to create a database of all the places or administrative entities of one country. Most work will be about adding new districts. I have to detail which region every district belongs to. ...
-1
votes
5answers
61 views

How to apply two different where conditions for two different tables in same select statement

select a.column1, b.column2, d.column3, d.column4, d.column5, d.column6 from table1 a left join table2 b on a.colx = b.coly left join table3 c on a.colx = c.colz left join table4 d ...
-4
votes
0answers
53 views

i want get all left and right user with all details [closed]

Sample data: CREATE TABLE [dbo].[binaryUser] ( [id] [int] IDENTITY(1,1) NOT NULL, [joiningDate] [date] NULL, [placement] [varchar](100) NULL, [pId] [int] NOT NULL, [cId] [int] NOT ...
0
votes
0answers
17 views

Using pipelined order by while fetching only first ten rows

PostgreSQL 9.2 I have the table table: id user_id amount PK integer integer and I need to fetch the first 10 rows as follows: SELECT user_id, SUM(amount) s FROM table GROUP BY ...
4
votes
0answers
53 views

Find Shoe Size Selection

I'm developing a feature that allows users to input their foot dimensions and have the proper shoe size returned to them. I'm having difficulty deciding on the best way to implement this feature. The ...
1
vote
1answer
32 views

Calculate column running total

Given the following schema and dummy data: CREATE TABLE transactions ( id SERIAL PRIMARY KEY, memo VARCHAR(255) NOT NULL, amount INT NOT NULL, tx_date DATE NOT NULL ); INSERT INTO ...
4
votes
1answer
71 views

Better database design

I'm using a MySQL database to store data from my java application. In java I have two classes: The VocabularyList class has a name and holds a list of vocabularies. A Vocabulary has a vocabulary ...
1
vote
0answers
19 views

Update remote MySQL database upon changes in local SQL Server database

I have a Web store running with MySQL on the remote host. And I have inventory management software using Microsoft SQL Server on my local system. I want to update product stock in the web store when ...
3
votes
1answer
67 views

SQL Joins and Relationships

I am confused by joins. I want to know how to choose the join based on the relationship between tables, or do joins have no dependency on relationship? if relationship is "one-to-one" then "Inner ...