An acronym for "Structured Query Language" (it's not the name of a specific DBMS product), SQL can be used in relational database management systems (RDBMS) to query, update, delete, and insert data as well as modify the structure of the database. It can also be used to manage schemas and data ...

learn more… | top users | synonyms (1)

0
votes
0answers
7 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
0answers
11 views

Drop database while query is active

I have a big innodb table on which a huge delete statement is running. I want to stop this statement since it is running too long (> 14 days now). Problem is that killing the statement will result in ...
0
votes
1answer
16 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
0answers
11 views

Choosing a better configuration for Windows Server 2008 R2 Standard

Currently we have a dedicated server running the following configuration Intel Xeon E3-1230, 4C/8T, 3.20GHz, 8M Cache 16GB Memory, DDR3, 1333MHz 2 x 146GB, SAS, 3.5-in, 15K RPM Hard Drive (RAID 1) ...
0
votes
1answer
27 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
29 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
17 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, ...
-3
votes
0answers
13 views

how can insert multipal data from table1 one column data can copy from another table2 from sql server [on hold]

how can insert multipal data from table1 one column data can copy from another table2 from sql server eg insert into Voterinfore(CustID) select CustID from CustomerVoterInfo --SET IDENTITY_INSERT ...
1
vote
1answer
55 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
11 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
19 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
122 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 ...
-4
votes
0answers
12 views

I can't connect with the DB through the php file. [on hold]

i can't transmin from php file,to the localhost db created with phpMyAdmin. I doesn't giv mi any errors,but still,doesn't transmit the informations. The code is simple. from e form with post method, ...
0
votes
1answer
56 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 ...
0
votes
1answer
46 views

sql statement in access that group items and count their sum

I would like to write an sql statement in microsoft access that group items and count their sum My table is like below : id : Auto-Increment Items : String Quantity : Number Eg : id | Items | ...
0
votes
1answer
73 views

How to get back sql table data? [duplicate]

IDE: Microsoft SQL Server Management Studio Mistakenly I have cleaned a table data using delete from table tblBookData and now it has cleaned that table, please tell me is there any way to get ...
1
vote
1answer
93 views

Difference between now() and current_timestamp

In PostgreSQL, I use the now() and current_timestamp function and I see no difference: # SELECT now(), current_timestamp; now | now ...
2
votes
1answer
48 views

Optimizing indexes

I just began optimizing my schemas with indexes (pretty late I guess). I never dealt with huge dataset but I'll be soon coping with about 1 to 5 millions rows. Here is the schema I'm using right now ...
1
vote
1answer
69 views

Possibly tempdb out of space or a system table is inconsistent

While running DBCC CHECKDB I got this error Msg 8921, Level 16, State 1, Line 1 Check terminated. A failure was detected while collecting facts. Possibly tempdb out of space or a system ...
0
votes
2answers
54 views

Merge two SELECT queries with different WHERE clauses

I have one table of services And I need to merge two SELECT queries, both have different where clauses For example SELECT U_REGN as 'Region', COUNT(callID) as 'OpenServices', SUM(CASE WHEN ...
-9
votes
0answers
32 views

Mirroring error #1418 [on hold]

I have configured mirroring in server without witness but I am getting a error no 1418 please suggest how to solve it. Even if I tried to create a endpoint but I couldn't create it.
0
votes
1answer
22 views

Can I estimate the row count of a large mysql table using the disk space?

Sysadmin here (not a developer by trade), so go easy please ;) I have a mysql table, on a linux server that uses innodb_file_per_table. When I try to do select count(foo) from table; It doesn't ...
0
votes
2answers
31 views

Dynamically REVOKE CONNECT FROM guest in SQL Server 2005

I wrote this simplistic script (I'm not very familiar with TSQL and dynamic SQL) to revoke all connections from guest accounts: DECLARE @database_id int, @database_name nvarchar(100); DECLARE ...
1
vote
2answers
46 views

Returning empty string when string_agg has no records

I am trying to return a text field in a PostgreSQL query that is of the form 'stringOne' || string_agg(field, ',') || 'stringTwo' where for certain elements in the group clause, field is always ...
2
votes
1answer
27 views

How to create function(table_name) that returns a set of the table

I have a set of tables that share the same fields (some timestamps and users names used for version control). I need to create a function with dynamic sql that uses a table_name and a timestamp as ...
0
votes
1answer
22 views

Merge left outer join column

I have a query that use left outer join. something like that : select issues.id, journal.notes from issues left outer join on (issues.id = journal.issue_id and journal.notes != '') So far it ...
0
votes
1answer
37 views

What data will be lost with DBCC CHECKDB (REPAIR_ALLOW_DATA_LOSS)?

I have a corrupt database. The last known good backup was over 2 weeks ago. I've run a CHECKDB and have the page numbers where SQL Server located the corruption. I've looked at the data on the ...
1
vote
1answer
33 views

Avoiding entitized characters when using FOR XML PATH for string concatenation

I have this query: SELECT DISTINCT f1.CourseEventKey, STUFF ( ( SELECT '; ' + Title FROM ( SELECT DISTINCT ...
1
vote
1answer
45 views

Profiling parameters

I was trying to fine the parameters of a query I suspect to be causing unnecessary logical read and eventually captured it in profiler, however parameters @p3 and @p4 are not listed. Is anyone able ...
1
vote
3answers
37 views

New SQL Server 2008 instance, load old instance DB's

BACK STORY: I'm a developer with a local instance of SQL Server 2008 on my workstation. I just recently upgraded my motherboard and found out (much to my dismay) the old motherboard's RAID drivers ...
4
votes
1answer
65 views

sql indexing and performance

I am using mysql5.1, i have table which has about 15 lakh (1.5 million) records.This table has records for different entities i.e child records for all master entities. There are 8 columns in this ...
-3
votes
0answers
32 views

Is it possible to get the queries executed in the past? [closed]

Is it possible to get the queries executed in the past? the server is restarted.
1
vote
1answer
47 views

Any idea why this seemingly-simple query is really slow?

Here's the query SELECT count(*) FROM registration r LEFT JOIN registration r2 ON r.baggage_group_id = r2.baggage_group_id AND r2.team_id IS NULL WHERE r.event_id = "102577"; It seems pretty ...
0
votes
1answer
25 views

How do I use a temporary table to generate a template of results and then fill it?

So let's say I have a table, call it 'orders' that looks like this: fields: customer|order_type|price data: "Bob" |"Delivery"|100 "Nancy" |"Delivery"|200 Where customer can be any name, ...
0
votes
1answer
17 views

How can I apply heuristics to optimise an expression tree?

I've converted the following SQL query: SELECT name FROM dog d, works_at w WHERE (d.owner_name = w.person_name) AND (w.kennal_name = "Breeders"); into the following expression tree: My main ...
1
vote
1answer
51 views

Optimistic Paging and separate query for COUNT?

I am using SQL SERVER 2012 FETCH/OFFSET after searching a lot that this will give me the best performance. But for paging to work, I need a Total count. There are 2 ways to achieve this. 1) Paging ...
0
votes
4answers
31 views

SQL Server 2005 database log size increasing drastically? [duplicate]

My friend works in a company (pretty small in size) that is running SagePro ERP which has a SQL server 2005 database. Now the problem is, the database size (over the period of 7 years) has increased ...
2
votes
1answer
75 views

Can comments in stored procedures cause problems

We're running a webserver that calls stored procedures to compute complex queries. Using sp_who2, we've discovered a peculiar issue where an abnormal number of processes would be stuck on SELECT state ...
0
votes
0answers
22 views

Adding a new partition to the partitioned table is skipping the last filegroup

I have created one partitioned table and trying to add a new partition to that. I ran the following scripts to create a new filegroup and add a new partition to the table. But when I run the alter ...
1
vote
1answer
46 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
21 views

how to use joins in hierarchical queries

how to use joins in hierarchical queries my try SELECT cust_id AS child_id FROM customer c,cust_assoc_dnorm d on d.dsend_id=c.cust_id WHERE connect_by_isleaf=1 and ...
1
vote
2answers
42 views

Loop through all databases and remove all users

We are doing a conversion from one system to another which is requiring backup/restores. I am trying to create a process that will remove all users after the restore on the new servers as no user ...
1
vote
1answer
27 views

Translating a query from MS Access to SQL Server

I have a legacy query from years ago that was written for an MS Access backend: DELETE category.* FROM category LEFT JOIN product_category ON category.id = product_category.categoryid ...
0
votes
0answers
22 views

Multiple login mappings for linked server

Can we assign two logins for two different databases on target server. For example, I would like to create a Linked Server between ServerA and ServerB. ServerB has two databases on it and both using ...
0
votes
0answers
27 views

MySQL Query for combobox

I have two tables in my database.namely books and bookidofid. where bookidofid from books table is referenced to bookidofid from bookidofid table Table books ...
0
votes
1answer
25 views

How can I rewrite the following removing the date_format function?

I have a table with a column when that is of type datetime. I am doing the following filter which can not use and index: AND DATE_FORMAT(t1.when, '%Y-%m-%d') <= LAST_DAY(now() - interval 1 month ) ...
0
votes
0answers
25 views

How to use Select query just right after Insert on master in a query.?

I have a question on mysql replication. As usual, I deployed my db structure like the Update on master db, the select on slave. My questions. If I use SELECT query just right after INSERT in a query, ...
0
votes
1answer
31 views

Postgresql condition on subquery results

This is a new question based on the solution to my previous question I have the following tables: users int (pk) user_id date last_visit int (fk) local_site sites int (pk) site_id site_stats ...
2
votes
1answer
37 views

Tuning Postgres for Single connection use? Or is postgres wrong tool?

Any rules of thumb for work_mem, maintenance_work_mem, shared_buffer, etc. for a database that DOESN'T anticipate concurrent connections and that is doing lots of aggregate functions? I'm a social ...
0
votes
1answer
58 views

Select one single row from table b for each row from table a

I have two tables: A(name VARCHAR2(20), type VARCHAR2(20)) and B (type VARCHAR2(20), ... (20 fields more)) I need to select a single row from B for each distinct name,type from A taking into ...