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)

6
votes
2answers
153 views

FOR XML could not serialize the data because it contains character (0x0000)

I have a big query (if necessary I will post it here) and I'm getting this error: Msg 6841, Level 16, State 1, Line 1 FOR XML could not serialize the data for node 'NoName' because it contains ...
4
votes
2answers
74 views

Grouping by sequential relationships with Postgres

This is quite similar to this question about continuous ranges, and this question about grouping by sequential numbers, but differs in that the sequences are not numeric. Given the following ...
3
votes
2answers
134 views

Filter and append data to row

My query and my data set (copied from sqlfiddle): CREATE TABLE one ( id int4 primary key, p_id int4, k_id int4 ); CREATE TABLE two( id int4 primary key, p_id int4, k_id int4, ...
1
vote
2answers
77 views

How can I run a SQL job every 1 second? [duplicate]

I have an SQL Job which processes minimum amount of rows at a given time. Currently its running every 10 seconds which is the minimum available in Job Scheduler. But because of that the table used ...
1
vote
0answers
7 views

JDBC - maximum allowable cursors - how do I see my open statements?

I've got some resource leaking and I'm trying to find what's causing them. I think I have some statements or resultsets that aren't being closed properly. Is there any way to see all of the cursors ...
2
votes
1answer
30 views

How to Choose Between VALUES and SELECT for INSERT?

This answer raised the question for me how to choose between VALUES and SELECT in such a function . Using PostgreSQL 9.4.3 on x86_64-unknown-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit: ...
0
votes
1answer
17 views

Slow fill database

The source sends in my program a large number of rows. When the number of rows such as two thousand per minute for one table, all is saved in the database properly. But if you send two thousand per ...
1
vote
1answer
35 views

Rename PK column names when they are FK in another tables

I need to change the names on PK columns and that has relations with another tables meaning they are FK also so this is what I am doing: SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET ...
3
votes
3answers
206 views

Do I want an index if all I care to query is field not null

In SQL, do all the common considerations about indexes apply if everything I'll ever want to query (in the where condition) is when a field is not null? Is there a special configuration of the index ...
0
votes
2answers
48 views

Display Total under name column and sum of amount under sal column [closed]

in a table empno,ename,sal,hiredate is there. but i want output is empno ename sal hiredate 122 ganga 2000 1989-02-06 123 reddy 3000 1986-06-02 Total 5000 here empno, hiredate column ...
1
vote
0answers
22 views

Creating a dynamic database

I'm using mysql server connected to Access, and I want to do a form, to fill the table. My question is how to do it. I need to select the data from a listbox, that's okay this is already done. And I ...
0
votes
1answer
47 views

PostgreSQL window functions very slow on big table

I have a PostgreSQL table constructed as device_id | point | dt_edit ----------+-----------+---------- 100 | geometry | timestamp 101 | geometry | timestamp 100 | geometry | ...
0
votes
0answers
19 views

SQL Server 2012 Extended Event-Set Session Event Filter

I am doing an exercise to create a new session using SQL server 2012 extended event feature. --I am not able to see the drop down menu for 'set session event' filter when using 'new session wizard. ...
1
vote
1answer
53 views

Replace Yes with 1 and No with 0

I get a data set and an example of the field is below. The values if these fields is "Yes" or "No". I would like to replace the value of "Yes" with 1 and the value of "No" with 0. This file will be ...
2
votes
0answers
31 views

SQL Server database suspect

All the databases went to suspect mode on a server. Tried bringing on-line by taking emergency but did not workout . Have restarted the server as there is disk I/o error still in suspect mode. Can ...
-1
votes
1answer
43 views

Insert id into another table and give the item another id that is autocrementing?

Need this answered if anyone can help. I need to create a query that will automatically insert ordID, but give it a new auto incremented OrderNumber in Orders.dbo. Fiddle is below: ...
0
votes
1answer
62 views

SQL Spool FILE SQLPLUS BATCH FILE

*/ SET colsep ';' SET TERMOUT OFF SET NEWPAGE 0 SET SPACE 0 SET LINESIZE 800 SET PAGESIZE 0 SET ECHO OFF SET FEEDBACK OFF SET HEADING OFF SET NUMW 20 column timecol new_value timestamp column ...
2
votes
1answer
33 views

Detect circular relations in a distribution table

I have the following two tables, that will define distribution rates from items on table A to other items on table A (I think I can say B defines a many-to-many relationship for A with itself). ...
0
votes
0answers
19 views

MySQL Cluster query all nodes at once

Is there a way to query all the available nodes of the cluster in one command ? (Make the same query go individually for each host and show the results.) mysql -uuser -p -hmyhost.com -e "select * ...
1
vote
1answer
24 views

Attach Database is disabled in Microsoft SQL Server 2012 Management Studio

I have buy from Godadday hosting and domain, after that I have create database in godaddy and the connect to this db using my authentication. I have .mdf, .ldf that need to attach to the connected ...
4
votes
1answer
37 views

Limiting Domain Admins permissions on a SQL Server

I have a SQL Server 2012 machine and I want to limit the Domain Admins permissions. What can I do to make sure that the Domain Admins have read only permissions for the databases and nothing else for ...
1
vote
0answers
54 views

Get all data from two tables and group it into different category in mysql

These are my tables to build an FAQ: CREATE TABLE `tbl_section` ( `section_id` int(11) NOT NULL AUTO_INCREMENT, `section_title` varchar(100) NOT NULL, PRIMARY KEY (`section_id`), ...
1
vote
0answers
17 views

Metaphone / Soundex Dictionary [closed]

I have a sql table with phrases which I convert using metaphone to allow users to search on strings which aren't spelled 100% correct. Evaluating the benefits of replacing the phonetic strings with a ...
3
votes
1answer
39 views

Update columns values using select from external database and table in MariaDB trigger

I have two databases pdone and veevan. pdone is a kind of master and veevan keep on continue sync against an external sources. I need to perform a internal sync between veevan and pdone so I am using ...
2
votes
2answers
47 views

SOS_Scheduler_Yield wait type

I am having a process that has a last_wait_type as SOS_Scheduler_Yield and is inserting 100 records to a table. This process has been with this wait type forever with low CPU utilization %. There are ...
1
vote
3answers
172 views

Remove duplicate values from query result

I am using Postgres 9.3.9. I have 2 tables : f_agent : CREATE TABLE f_agent ( f_agent__id bigserial NOT NULL, f_agent__total_users integer NOT NULL, f_agent__dim_time_id integer NOT NULL, ...
3
votes
2answers
62 views

Applying GROUP BY when using multiple CASE WHEN

select e_id ,CASE WHEN w_id in ('1','2') THEN w_id ELSE 0 END as new_w_id ,CASE WHEN w_id = 1 THEN fee END as value1 ,CASE WHEN w_id = 2 THEN fee END as value2 ,CASE WHEN w_id not in ('1','2') THEN ...
1
vote
0answers
36 views

How to use variables in a PL/pgSQL function with dynamic queries?

...and when must I use EXECUTE ... quote_ident(variable)? Taking an input to the function as text and storing part as a variable: wtype := split_part(message, ' ', 4); realval := ...
1
vote
1answer
44 views

How to update row values with values from SELECT into another DB in a trigger

I have been working in a trigger for INSERT|UPDATE values for a given record based on same PK. What trigger basically should do it is, foreach row when some INSERT happens on veeva_new.account: ...
1
vote
1answer
80 views

select query on Temp table is not returning data in correct order even after specifying index hint [duplicate]

In my code, I am creating a temp table using select * into #tempTable. Temp table contains the huge number of records and I need to retrieve data from it many times in my code so I created a ...
1
vote
1answer
37 views

Can I remove “/*!50100 PARTITION BY HASH…” to success with import?

I'm trying to import a database and get this message (Swedish lang phpMyadmin): As you see, I get the message: #1064 - You have an error in your SQL syntax; check the manual that corresponds ...
1
vote
2answers
116 views

How can I select data from two differents servers?

I have two databases: data1 and data2 in two different servers (server1 and server2). I am trying to join two tables of my two databases in MySQL like this: SELECT left(a.code,9) as fourn, ...
1
vote
0answers
24 views

How to prevent multiple queries in this case? [duplicate]

I am using Postgres. I have 2 tables. PS : week starts from monday. Time (id (bigInt), startOfWeek (Date), startOfMonth (Date), startOfQuarter(Date), day (Date) ...) and User (id (bigInt), timeId ...
2
votes
1answer
49 views

Powershell - SQL Server - connectionstring in loop for multiple Instances

Thisis part of a bigger script which finds DatabaseFiles on a SQL Server machine (multiple instances). Following should just return all files for 3 instances. The server is called V3000801 and ...
0
votes
1answer
49 views

One time data conversion in Oracle tables with excel data

First of all I have very basic knowledge in back end I need to do an one time data conversion in an Oracle table with a excel sheet data. Excel sheet have data in below format OldData NewData ...
0
votes
1answer
15 views

Is capitalization of SQL commands/keywords required, expected or completely optional? [closed]

Also, is it done automatically in some environments?
2
votes
1answer
69 views

What are the best practices for restricting write-access on a specific table?

I have a table, which I'd like to be read-only, except for a few specific stored procedures which need permissions to UPDATE rows in the table. After that, I want only a select group of additional ...
2
votes
1answer
32 views

How to calculate shift hours in postgres?

I have table like below where (I=In) and (O=Out): id | date | time | status | employee_id ----+------------+----------+--------+------------- 1 | 2015-07-01 | 11:00:00 | O | ...
3
votes
2answers
77 views

Do I need a composite primary key in a junction table?

I have a junction table like this: CREATE TABLE `entitytagjunction` ( `EntityId` bigint(20) NOT NULL, `TagId` bigint(20) NOT NULL, PRIMARY KEY (`EntityId`,`TagId`), KEY ...
5
votes
1answer
75 views

No service broker active on database

I am trying to set up query notification however when I try to create a queue and service I get the error 'There is no Service Broker active in the database. Change to a database context that contains ...
2
votes
1answer
32 views

I want to select all records for those persons who have one or more entries that equals zero dues

DUES_TABLE ID LNAME FNAME DUES DATE 3456 Smith Bob 12.50 2014-10-01 3456 Smith Bob 0.00 2014-11-01 3456 Smith Bob 12.50 2014-12-01 9450 Jones ...
0
votes
0answers
23 views

SYNTAX ERROR: delete from multiple tables with inner join

Sorry, but I need syntax help :( This needs to run on SQL Server 2005 + DELETE SO, ASO, ASOV, AOV FROM SYS_OPTION SO INNER JOIN ADM_SYS_OPTION ASO on SO.OPTION_ID = ASO.OPTION_ID INNER JOIN ...
-1
votes
1answer
64 views

A complex query to Joining 2 tables and getting result [closed]

I have a database in MySQL. I have 2 tables, Structures as follows : t1 t2 I want to join both the tables and result should be like this : Employee_id | count(DNIS) | total_calls | count(DNIS) ...
3
votes
1answer
499 views

Benefits of SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

I use SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED in the majority of my general SQL queries, mainly because this was drilled in to me when originally learning the language. From my ...
2
votes
1answer
68 views

Multiple indices on a table

I have run SQL Profiler and I can see that I'm "missing" some indexes (non-clustered) on a table. How is it best to handle indexes that can be a "subset" of another index? Index 1 UserId, ...
14
votes
4answers
2k views

Why should a key be made explicit?

I am very new to the subject of databases so this may sound ignorant, but I am curious why a key should be made explicit within a table. Is this primarily to tell the user that the given column value ...
1
vote
2answers
75 views

How to break down RELATIONAL data into HIERARCHY data structure?

I have a query that returns the following dataset: RELATIONid MAPid D1id D2id D3id 4999 4999 626 1250 7 5000 5000 626 1250 8 For the next step, I need to bind those ...
0
votes
1answer
72 views

Select all from table using procedure oracle

I am trying to execute the select command in a procedure.Initially i retrived all of the columns of the table in the procedure using cursor. The real problem comes when I am trying to access the ...
5
votes
2answers
33 views

Combine two event tables for multiple timelines into a single result set

This question is an extension to a question I've previously asked that was overly simplified. The more accurate example is demonstrated in this SQLFiddle, where I demonstrate a working (but slow) ...
3
votes
1answer
71 views

Slow window function query with big table

I'm doing some performance testing on a new DB design on PostgreSQL 9.4rc1 and I'm seeing some pretty slow queries using window functions. Here is my table setup: CREATE TABLE player_stat ( ...