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)

1
vote
0answers
29 views

How to resolve Error 7311 returned by a job running against a linked server?

I have a job and a linked server. The job was working fine for a while, but recently I started getting this error message and I couldn't find a soloution for this. Executed as user: ... Cannot ...
0
votes
0answers
25 views

SQLite table design for PK and/or UNIQUE

I'm trying to design a table in SQLite3, where I can perform these 2 actions. INSERT new row where a unique primary key is created. And INSERT new row with an given primary key Think of a ...
1
vote
0answers
19 views

Check for a value from table 1 in table 2 [migrated]

I am struggling with how to do this and the examples I have found seem overly complicated for what I need to accomplish. I have two tables in separate databases. I need to see if Db1, table1, column2 ...
2
votes
2answers
67 views

Why would you put Identity Increment other than 1 in SQL? [closed]

In SQL Server, you can set the increment of an identity column other than 1. In what situation would you do that?
2
votes
1answer
65 views

Avoid joining to the same table multiple times

I have two tables: CREATE TABLE one ( id int4 primary key, p_id int4, k_id int4, c_id int4 ); CREATE TABLE two( id int4 primary key, p_id int4, k_id int4, t_id int4, pos int4 ); Table ...
-1
votes
1answer
67 views

Group by creating problem in Ranking of player [closed]

CREATE Table dbo.[#TMP] (UId uniqueidentifier, Points int, DC datetime, CId int, Username nvarchar(50)) ...
0
votes
1answer
33 views

Count in an other table and show only theese records in query which has more than they used in other table

I have for example 2 tables: used(us_id, code_id); codes(code_id, amount) I want something like this: If for example I have 5 eggs, and egg code is 1, then if the used table have reached 5 of ID ...
0
votes
0answers
16 views

how to get tag record with its descriptor from pi database?

I want to get the data with tag, time ,value, descriptor from pi database, but it seems tag record and its descriptor are stored in different database. tag, time ,value is stored in database ...
1
vote
2answers
154 views

Group or Order SQL output into a single row

I want to display each persons contact info and their commissions in a single row as oppose to multiple rows. Commission Table ID COMMISSION DATE ...
3
votes
1answer
88 views

DECODE or CASE STATEMENT for PARAMETER in WHERE CLAUSE [closed]

I am having an issue where I need to make 1 parameter have multiple options, almost like a case statement or decode function. Here is a snippit of the query below, We were using 2 parameters so he can ...
2
votes
2answers
93 views

Query: How to get both Question and multi Answers in one query

For this question, Question and Answer are just my example tables for one-many relationship. For example: Question(QuestionID, QuestionTitle, QuestionContent) and Answer(AnswerID, AnswerContent, ...
3
votes
2answers
71 views

For XML PATH error (SQL Server 2008 R2) [closed]

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
68 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
120 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
61 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
5 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
22 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
23 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
197 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
41 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
21 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
38 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
16 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
49 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
30 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
32 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
36 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
29 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
10 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
22 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
35 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
50 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
14 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 ...
4
votes
1answer
27 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
39 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
148 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
61 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
28 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
37 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
65 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
30 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
90 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
36 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
39 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
59 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
28 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
60 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 ...