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

would you help me understand errors and bad exercise containing in the query?

A customer called technical support for a DBMS, saying that the DBMS had a severe bug and was crashing the operating system. On investigation, it was found that the ‘crash’ always happened when a ...
1
vote
2answers
27 views

Charindex, Getting specific data from a string

Hello I am very new to charindex and have tried to create a query that would extract my needed information but am running into an error. I searched for similar problems on stackexchange as well as a ...
1
vote
1answer
23 views

How to use an alias name that has RANK() OVER in a WHERE clause

I have a query that has a RANK() OVER function inside it but I would like to use the results displayed on this column in the WHERE clause that follows. How do I write that as all the other questions I ...
3
votes
2answers
34 views

Conditional Foreign Key Relationship

I currently have a foreign key between two entities, and I would like to make that relation conditional to the entityType of one of the tables. Here's the hierachy of tables, this is done via FK ...
1
vote
1answer
19 views

Query to know who paid more than 10k

I have a table with payment informations, like this: ID COSTUMER_ID DATEPAID AMOUNT 1 1 2012-01-01 50 2 1 2012-02-01 100 3 1 2012-03-01 70 4 2 ...
1
vote
1answer
18 views

Recording history of ranks

Once per day, this is being executed to rank everyone in the database based on points. SET @r=0; UPDATE ranks SET previousRank=rank, rank= @r:= (@r+1) ORDER BY points DESC; The field ...
-3
votes
1answer
47 views

Retrieve result for all the users

I have one query which returns particular user total hours for a month. I want to return for all the users in an org. UserRegistration table contains UserID. My code for particular user is, SELECT ...
0
votes
2answers
24 views

select where column with a %

How can I select all records with a % in? Goes code below works? SELECT * FROM table WHERE column LIKE '%%%' first and last % for zero, one or more chars second % for the percent skinn If not ...
0
votes
0answers
26 views

How come MySQL LIKE is faster then FULLTEXT?

So, I was trying to optimize my MySQL queries, but found out that i'm actually doing this wrong. I've changed my query from using SELECT * FROM test WHERE tst_title LIKE '1%' To: SELECT * FROM ...
0
votes
1answer
27 views

How to prevent insert row duplicate value in a column and equal the any value

I have table TABLE1( id number (primary key), IDAccount number, status char(10)) Table can have 2 row duplicate (IDAccount, status) with status=disable as well as id IDAccount status 1 ...
1
vote
1answer
133 views

SELECT COUNT(*) to html table

This may be a very simple but its still not clear to me. I'm writing a SQL Agent job to generate output in html format. I need to get results of a query SELECT COUNT(*) FROM TABLE_NAME. I'm able to ...
-6
votes
0answers
26 views

i want to join the sum but different LIKE CONDITION [on hold]

Below is my table this is fill on the training_transaction table
0
votes
1answer
63 views

Is there a way to run this query in all databases ? ( SQL Server 2008 R2 )

How can I use this query for each database? I can easily use sp_msforeachdb but it breaks the results for every database. So I tried to insert the results in a temp table, but it's giving me syntax ...
1
vote
1answer
30 views

PostgreSQL, how to extract all the possible couples of a primary key in a table?

I would like to find out a PostgreSQL command that reads the content of a table, and returns all the possible couplings of the primary key of the table. Something like this: input_table (ID is the ...
6
votes
3answers
179 views

Find data size of table for several identical databases on a instance

I have several identical databases with the same schema/table structure within a instance. I need to find the size of one table that they all have. For example, I have 30 databases on a instance and ...
0
votes
1answer
41 views

Update if exist in other table

I want to update column in table A if the value of column A1 exist in one column of B table for example B2 update A set A1 = 'F' WHERE A1 in (SELECT B2 FROM B ); I tried somethig like this but no ...
0
votes
0answers
23 views

SQL TDE Key Format

I'm trying to find the Key Format that SQL TDE uses. Is it PKCS? If so, what #? I haven't been able to identify this based on research done on MS website. And, there is no mention of key format during ...
1
vote
0answers
14 views

Can i use PGP for securing My database

I have considered TDE and cell level encryption mechanism for securing my database. but these two cannot fully satisfies my requirements.through surfing i found that PGP may help me, but it is mainly ...
1
vote
1answer
336 views

Can we use TDE as an anti-injection technique

TDE prevent unauthorized access to the data by restoring the files to another server, because it requires the original encryption certificate and master key. If i applied a table level encryption ...
6
votes
3answers
79 views

Totals(sums/counts) across multiple child tables query optimization

We have 12 types of expenses in our database, some have fairly differing data minus the Amount fields. We have multiple places in the application and reports that require single and multiple expense ...
3
votes
1answer
47 views

GROUP BY uninterrupted sequence of logs for same location

I'm having a hard time describing my problem or finding it via Google. I want to be able to group rows based on location and employee, but the group should be split if a row with the same location ...
-1
votes
2answers
51 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, ...
3
votes
2answers
89 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
80 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
17 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
51 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
36 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
11 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
22 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
53 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
35 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
24 views

Program scrambled the screen [closed]

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
64 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 ...
-1
votes
0answers
28 views

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

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
15 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 [closed]

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

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

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
64 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
21 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
28 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
36 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
71 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 ...