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)

2
votes
1answer
69 views

Is a SQL query still called a “query” when doing a deletion, update or insertion?

I'm not sure what to call a query that... isn't really a query; is "statement" a better word to use in place? Or how about "script"? Or would something else be more appropriate? Note: I've seen ...
1
vote
1answer
188 views

SQL Query Rewrite - Help Needed (Oracle)

Need help in re-writing the below SQL. The Query works fine for smaller database below 400 GB, but spends too much time for larger database above 600 GB. Oracle - 11.2.0.4 Database - Oracle ...
-1
votes
1answer
167 views

Access table field on creating a trigger postgresql

How can I access table field on creating a trigger? CREATE TRIGGER foo_trigger AFTER INSERT OR UPDATE OR DELETE ON foo FOR EACH ROW EXECUTE PROCEDURE proc(foo.field);//here goes the parameter
1
vote
0answers
15 views

How to enable Parallel Data WareHouse? [duplicate]

How do I enable Parallel Data Warehouse on my Microsoft SQL Server. I am trying to run this SQL statement below and received this error. ERROR: Msg 11305, Level 15, State 10, Line 2 The Parallel ...
0
votes
0answers
38 views

more queries vs storing results in database

Environment: Embedded (smartphones) Data Structures: Object Table A: id, field1, field2... Object Table B: id, field1, field2... Object Table C: id, field1, ... , Object A, Object B ... many ...
0
votes
2answers
457 views

How can I limit a hierarchical query to the point where there are multiple children?

This question is related to my previous question about hierarchical queries. I have a hierarchical query in Oracle 11gR2 that returns something like this: - Level 1 - Level 2 - Level 3 - ...
3
votes
2answers
2k views

Looping through values stripping 1 character at a time

I want to loop through values and strip 1 character at a time from the values and display the result. So if I have a table with values: ID ___ 34679 13390 89906 I want the result to look like this ...
1
vote
0answers
19 views

How can I select rows from a hierarchical query with the lowest level? [duplicate]

Apologies for the cross-post from StackExchange DBA - I wasn't sure which site was best for this question. I have a hierarchical query in Oracle 11gR2 that returns something like this: Parent ...
2
votes
2answers
1k views

How can I select rows from a hierarchical query with the lowest level?

I have a hierarchical query in Oracle 11gR2 that returns something like this: Parent (Level 1) Child (Level 2) Grandchild (Level 3) Child (Level 2) Grandchild (Level 3) Grandchild (Level 3) ...
-1
votes
0answers
48 views

Query Deadlock on Select Query [closed]

I have 2 queries deadlocking on each other. The first query is Select Top 1 NULL From [Table1] with (HOLDLOCK, TABLOCKX) Second Query is an insert query that only reads from [Table2] to put data ...
1
vote
1answer
6k views

MySQL SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded

I have database session enable, when website got thousands of visitor. It gives me error [30-Apr-2014 04:27:12 America/Denver] PHP Fatal error: Uncaught exception 'PDOException' with message ...
0
votes
2answers
500 views

Is there a free/web-based game that requires knowledge of SQL to win? [closed]

Looking for an alternative way of teaching SQL, and wondering if there is a free/web-based game that requires knowledge of SQL to win. If possible, the game should not only be fun, but also track how ...
5
votes
1answer
204 views

SQL logs showing login that I can't find

Within my SQL server logs, I am showing a successful login to a database from an account (SERVER\loginname) that I cannot find in either Security > Logins OR Database > Security > Users. This ...
2
votes
2answers
350 views

SQL query for next occurrence of specific date

I am working on a function for our database that contains contract data. Each contract expires on a certain date, and then each contract has an expiration type that determines what happens after that ...
7
votes
2answers
219 views

Using wildcards in a like statement on an unindexed VARCHAR(MAX) column with more than 1 million records

In order to troubleshoot a problem, I have a one-time question as to whether a specific varchar(max) field contains non-printing ASCII characters (other than white-space). The following is my ...
5
votes
1answer
417 views

Optimize where clause using dates

I'm trying to optimize several queries that all use a similar pattern on one of the WHERE clauses: AND (DATEADD(DAY , ISNULL(a.[due_days], 30) + 30 , [dbo].[CalcDate]([type], ...
0
votes
1answer
113 views

SQL Server monthly Backup

Im pretty new to SQL and some employee asked me if is possible to make monthly database backups. We do daily full backups to NAS server via cobian and we use SQL Server Management Studio to make ...
3
votes
2answers
1k views

ORA-00979: not a group by expression

I'm getting the error: 'ORA-00979: not a group by expression' when I try to run this query. select empno, empname from emp.employee group by empno, empname having empmsal > avg(empmsal); I'm ...
1
vote
1answer
200 views

SQL Server agent job scripts

Being a newbie to database migration, can I script all the database jobs one by one and run them against a new server to create these jobs? If not, why do we use these SQL job scripts? Thanks in ...
2
votes
3answers
1k views

Oracle 12c in-memory option

I've been told that there's an oracle in-memory option for 12c and that it uses columnar compression to get some great query speeds. I'd like to leverage it for some business intelligence stuff. I've ...
0
votes
1answer
4k views

Declaring a scalar variable that its a table valued parameter?

I get error 137 that I must declare a scalar variable (@facilities), although I'm declaring it in the Create stored procedure as a readonly variable, so I wasn't sure what I'm missing here. any advice ...
4
votes
1answer
175 views

Which parameters was a stored procedure or command executed with?

We are using nHibernate which generates queries from .NET code. Occasionally, some queries get stuck in the sp_whoisactive list and we cannot find out why. I have a feeling that it has to do with a ...
0
votes
1answer
68 views

Restoring a Postgresql database

Last week one of my sites server crashed. I was not able to access the ssh server and could only use the basic linux console on digitalocean.com. Because I could not get into my ssh server I was not ...
0
votes
1answer
64 views

Which one is correct and optimized in sql?

Imagine that I have three entities (EntityA, EntityB, EntityC) that can have some images. So there are two ways: Make an image table for each entity. It means that EntityA has a image table named ...
1
vote
0answers
329 views

Best practice - SQL Schema to store Timerecords for a Time and Attendance module

I'm starting a time and attendance module in C# and SQL. There will be many time rules depending on every shift. For example: Shift 7:00 - 14:00 for Administratives: 15 min grace time, but if ...
1
vote
3answers
2k views

`Select` query take more time than it should

I have a MySQL database table with nearly 23 million records. This table has no primary key, because nothing is unique. It has 2 columns, both are indexed. Below is its structure Below is some of ...
0
votes
2answers
187 views

Need help phrasing regular expression to find particular T-SQL pattern

I know this is a Database Forum, but since the text I am trying to find is SQL-specific, I am hoping that somebody can point me in the right direction. I need to search code to find places where the ...
3
votes
1answer
82 views

Table A triggers an insert onto Table B, Table B triggers an insert onto Table A, what happens?

Assume I have two tables, table A and table B. Table A has an insert trigger that inserts a record into Table B. Table B has an insert trigger that inserts a record into Table A. What would happen in ...
0
votes
0answers
72 views

Enterprise Policy Management Framework Issue

I am attempting to setup and configure EPM to work in our environment. I have all the components in place and when I run the powershell it completes without reporting any errors. However, the only ...
1
vote
2answers
70 views

Numbering a rows positional index relative to its siblings within a parent context

So, I have a table that contains numerous entries of text, but each one has a parent context that identifies the entries within a group, such as: +------+-------+------+ | PKID | GrpID | Body | ...
0
votes
0answers
17 views

result time long

İ lose 3-4 minute when this query running in mysql.How to write I this query more optimal: select u.*, d.device_id, d.name from users u inner join pass_logs p inner join devices d ...
2
votes
2answers
220 views

Limiting the Number of Records Joined

How can I perform a query that contains a (one-to-many) join between two tables, which will only join up to a pre-defined number of joined records? So, lets say I have two tables, one for Matches, ...
1
vote
1answer
30 views

Locating a schema that owns a role

Let's say we've logged on under the A schema. I am able to execute the following statement grant select on wph_pden to LANDING_R; However, the LANDING_R object can not be located in the schema A. ...
0
votes
2answers
40 views

Aggregating results of two database views in one database view

I have a view with name of UserInfo like this: And another view with name of UserRoleInfo like this: I want to aggregate all the records of the two views for one user name like H.F into ...
1
vote
1answer
107 views

PostGis getting rid of the lat long from table

This question is related to this question : Order by distance Now my tables have changed a bit. Table cafes now doesn't have latitude, longitude columns instead there are table addresses which ...
2
votes
1answer
4k views

Update all columns from another table

I need to update a table from another one, and I need to update all columns. Besides listing every column in the SET clause, is there a way to update them all at once? Like this: update tableA set * ...
1
vote
2answers
202 views

Nested query efficiency in MySQL

I have a table with several attributes like this: id id2 attribute -------------------------------- 1 100 blue 2 100 red 3 100 green 4 100 white 5 102 blue 6 102 green 7 102 ...
1
vote
1answer
45 views

UK Addresses in 3NF

I am in the process of creating a UK only database which holds information for various sets of people i.e. Staff, Clients etc. The tables for each of these sets of people have an Address, City and ...
3
votes
4answers
2k views

How to check for existence of an INDEX on a column independent of used SQL database

Is there are unified way of how to check for the existance of an INDEX for a given column irregardless of the actual SQL database system used? For MySQL one could for instance check for the existance ...
1
vote
1answer
107 views

Why does this simple select statement require quotes?

Why does the following statement select * from expertrule where rule_id = '1'; Return this error ORA-00904: "RULE_ID": invalid identifier While select * from expertrule where "rule_id" = '1'; ...
0
votes
0answers
50 views

How to make a role from schema A “grantable” in schema B

There are two schemas in the same database: A and B. Schema A has a role A_ROLE. I want to be able to give grants to A_ROLE from schema B ( so that the users with A_ROLE were able to query tables from ...
0
votes
1answer
495 views

Select row with MAX(), or choose one if no MAX() exists

I have a MySQL InnoDB table with the following columns: id: UNSIGNED bigint(20) AUTO_INCREMENT (PRIMARY KEY) name_id: UNSIGNED bigint(20) time_stamp: decimal(26,9) event: enum('add', 'init', ...
0
votes
1answer
102 views

Sql statement to count sum and campare it with another table

I would like to write an sql statement in microsoft access that group items and count their sum in order to compare it to another table I have two table like below : Product: list of demanded ...
0
votes
2answers
36 views

How can I genereate a string from the returns of a SELECT query in Mysql?

I need to create a string from data that is extracted from an SQL query, and wish to accomplish it within the SQL Query. The return is something like +---------------+ | foo_ids | ...
0
votes
0answers
41 views

MySql query keep running for a long time

Following query keep running for a long time and I'm using MySql 5.5.34 on XAMPP on Windows SELECT id_package, `pck`.`fk_sales_order`, `pck`.`fk_picklist`, count(pci.id_package_item) as items, ...
1
vote
1answer
273 views

Need help with SQL Server PIVOT

I know about the PIVOT feature in SQL Server and I've read a few other questions and answers on here but I just can't seem to grasp it in order to do what I need. I'm trying to run some calculations ...
0
votes
0answers
70 views

SQL Server 2008 R2 installation device error

I am trying to install SQL Server 2008 R2 to use along with Visual Studio for a website I am creating. However when I am installing SQL Server I am constantly getting the following error: The ...
0
votes
0answers
63 views

Time series indexing

Indexing time series (like in this article) is done by reducing dimensionality and indexing it using some spatial access method (like R-tree). How does that improve performance, though? It's not like ...
2
votes
1answer
139 views

Numbering multiple dates per delivery

I am interested in producing the following view where different delivery dates are numbered. SalesID Delivery Date DateNo SO00000014 2014-02-21 1 SO00000015 2014-02-13 1 SO00000016 ...
0
votes
1answer
148 views

Query multiple rooms with different conditionals (Adults, Children)

I have a simple query where I select available x Rooms with x Adults + x Children per hotel that matches a date range, but I'm having a hard time trying to figure out how to query a list of rooms per ...