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

TRIM function in used for a loop

SUBSTR(TRIM(location),1,INSTR(TRIM(location),' ',1,1)-1) != 'ABC'; can you please explain what exactly the above statement is doing ??
0
votes
1answer
31 views

Query for orders that contain a product without using sub-query

Order ----- OrderId OrderDetail ----------- OrderDetailId OrderId ProductId How do I write a query that returns all orders that contain a specific product without using a sub-query? I don't want ...
0
votes
2answers
28 views

How to list LOGIN + ROLE in SQL Server 2008?

I'm looking for an answer but i can't found. Just a lot of long scripts. I need to list Login | Role ( sysadmin, dbcreator, etc ) but i can't find a table to join. I have this for now: SELECT name ...
0
votes
0answers
6 views

Data base design for handling website subscriptions

I have a website where at least 20 posts are posted in a day and each post contains more than 5 categories and each category has further tags. I wanted to build a subscription module that users can ...
0
votes
1answer
45 views

Order of Columns in Index

I have following query which has ON clause on different column, Where clause on different column and Selection on different columns so my question is what should be Order of Columns in Index as ...
-1
votes
0answers
10 views

DB2 - Sql to get only the multiple records starting from 1 in row number function

Please help me in writing a sql script to get only the multiple records in row number function inclusive of rownumber 1 record. Example: ***Column 1 Column2 Row_number*** Apple orange 1 ...
0
votes
1answer
27 views

MySQL: Get comma separated values from a table, should not exist in another table

I have two tables, table structures as below. Table: items Id item_name item_ids 1 pens 10,11,12,13 2 books 20, 30 3 computer 50, 60, 80 Another table : ...
0
votes
2answers
23 views

SELECT that is null if there is one more register in this date that is not null

I'm trying to make a query that I can't produce... This is my table capturainfo captureid int(11) userid int(11) date date dateinit datetime datefin datetime I need to select ...
1
vote
2answers
90 views

run a script for all databases

I need help what statement or function i can use to run a query in all database using one script , i want to run the below script at the same time to retrieve output in all databases select ...
0
votes
1answer
66 views

ON DELETE CASCADE not deleting entry for foreign key

I am running the below query in ideone CREATE TABLE AUTHOR ( AUTHOR_ID NUMBER(5) PRIMARY KEY, AUTHOR_NAME VARCHAR2(18) ); INSERT INTO AUTHOR (AUTHOR_ID, AUTHOR_NAME) VALUES (1234, 'MC GRAW HILL'); ...
0
votes
1answer
23 views

Oracle SQL Summing Values From Two Different Tables

Hey all so I am trying to add to (or subtract from) a column of different values based on a separate column in another table. Here is a example of what I am tying to do: Table 1: (Current Inventory) ...
-2
votes
1answer
29 views

How to define one to many relationship in a SQL Server database [on hold]

How do I create the relationship that is defined in above image? I have created two tables both have a column ID (auto-increment) as their primary key.
0
votes
0answers
18 views

Windows Administrator doesn't have permission on SQL Server [duplicate]

My previous system administrator created a SQL Server 2008 instance on my local machine with his domain User. Now, I cannot create, delete, or view any databases or tables on that instance. Even with ...
0
votes
0answers
12 views

Connect java application with cloud storage using sql [on hold]

I want to create an application in java and I want to use online storage but how I can connect that application with cloud storage
0
votes
1answer
30 views

Combining multiple rows into single column

The return from my MySQL statement displays an example below: id 1 | status | id 2 | name | category 001 | open | 011 | john | person 001 | open | 011 | john | male How would I combine the ...
0
votes
1answer
33 views

Join to a Culture Table vs Select Culture ID

I have a query that is executed several hundred thousand times a day. Due to legacy support, the incoming variables on this SP cannot change. Currently it looks like this: Select id, name, ...
-1
votes
0answers
12 views

SSIS Export Ragged Right Fixed Width format File [on hold]

I created an SSIS project to export a fixed width file to an external system. This file has 12 fields and they all position correctly per the external system requirements. I use Ragged Right format ...
0
votes
1answer
34 views

Display a one-to-many relationship in one row

I have a "one to many" relationship in two tables: Table "products" contains: product_id, product_descr Table "packing" contains: product_id, package_id, package_desc One product has often more ...
0
votes
0answers
29 views

Adding a constraint to check another table whether if the data exists [migrated]

currently I'm learning SQL but i got stucked at one point, I've searched a number of threads but it seems that i can't find the exact one that I'm trying to achieve. Currently after creating table, ...
3
votes
2answers
134 views

Is EAV an appropriate design for a collection of coexisting metadata-rich “fact estimates” on objects? [on hold]

I'm attempting to architect a system that will collect estimates on various quantities (10+) on each of many (300K+) objects, and make decisions from the historical record of these estimates. For ...
0
votes
3answers
45 views

How do I do an outer join between all nested subqueries? (getting an error of 'OUTER' is not a valid input for this position) [on hold]

I have this query: SELECT AVG(a.score) AS Average1, AVG(b.score) AS Average2, AVG(c.score) AS Average3 FROM (SELECT subfactor.score, dateID, EmployeeID FROM employeescore LEFT JOIN ...
-3
votes
0answers
24 views

Hi this is my requirement can you help me?

Student sid name address phno 1001 abc nellore 1342425 1002 xyz allur 98876545 mark sid m p c 1001 45 34 34 1002 62 13 78 fee sid fee 1001 ...
-2
votes
3answers
36 views

Cannot identify syntax errors [on hold]

Newbie here. I'm trying to execute this line in sql server: CREATE TABLE dummy_driver but I'm receiving the error message Incorrect syntax near 'dummy_driver'. I can't seem to locate the error. ...
0
votes
0answers
15 views

SQL social connections query

Given the following 2 tables: Profiles --------- id, name Connections ----------- id1, id2, status where status is (for the sake of the example) either 'pending', or 'active'. What I'm trying to ...
0
votes
1answer
33 views

Query results that not are in previous query result

I want to retrieve from my table the id_product of the products which haven't got some attribute and it's value is not the ones i want For example i want the id_product of the products in which ...
1
vote
1answer
37 views

Return list of columns in user-provided subquery

I am trying to fill a ComboBox of all columns from results of a query. That query is submitted by the user on the form, so the program needs to run the query then have a procedure run that extracts ...
0
votes
0answers
5 views

How to execute cursor in PostgreSQL?

This is my program for cursor, but I am not getting how to execute the cursor on a database. emp=# CREATE or replace function cursor_demo() returns integer as $$ declare emp_rec employee%rowtype; ...
2
votes
1answer
34 views

BLObs – Should I Store In Database Or in Directory Structure?

BLObs – Should I Store In Database Or in Directory Structure I have been developing a database to replace an ageing data structure that contains 1000's of files within a directory structure. The ...
1
vote
0answers
41 views

Simple avg query on large table much slower in PostgreSQL than SQL Server

I have a database with three tables items, parameters and measurements in both servers and want to query the measuerment table. But the query is much slower in PostgeSQL (9.4) vs SQL Server (2012). ...
0
votes
1answer
36 views

How to keep archive table accessible for some users which is not frequently accessible?

I have partitioned my table based on some boundary ranges. My Database is built at MSSQL server 2008 R2. I have done partitioning for a table which has 40 million records in it. Now it's time to ...
0
votes
2answers
11 views

Compare values in SQL having dots

I'm comparing values from two different database. In one table the name is stored with dots(i.e A.B C) and in another table the same value is stored as AB C(i.e in second table none of the names ...
2
votes
1answer
71 views

Reporting on a normalized Key-Value pivot

ERD & SQL Fiddle provided. We're trying to design a reporting tool for our stakeholders around a normalized Key-Value Pair model. We've tried to find a solution using Pivot Tables but can't seem ...
0
votes
0answers
16 views

How to Load Special characters in Database 11.2 & Client Character Set is US7ASCII through SQL * Loader [duplicate]

My client using Oracle database version 11.2.0.1.0 and NLS parameters are NLS_NCHAR_CHARACTERSET AL16UTF16 NLS_LANGUAGE AMERICAN NLS_TERRITORY AMERICA NLS_CURRENCY ...
0
votes
1answer
17 views

Postgres Nested WHEN Aggregate Function

In PostgreSQL (version 9.4) I am trying to construct a query to determine in various tranches how many times various numbers appear in the data set between ranges. When I query group-ing by ...
0
votes
2answers
27 views

Oracle SQL Creating Copy of Table Using DBMS_metadata

so I am trying to create a copy of a table using dbms_metadata. I know you can get the DDL of a table by executing DBMS_METADATA.get_DDL('Table','TABLENAME') so my question now is how can I use this ...
0
votes
0answers
12 views

How to use DMBS_LDAP to select 3 attributes for selected entries

I'm attempting to use DBMS_LDAP to create a procedure in Oracle 11.2.0.2.0 that ultimately updates an employee table from active directory. The attributes I want are sAMAccountName, GivenName, and ...
0
votes
2answers
22 views

can i secure sql server agent job with password

i want to secure SQL server agent jobs with password or any other method is it possible?
1
vote
3answers
111 views

Distinct Random select

Hi can anyone help with this little MS SQL Puzzle. I basically need to get a 1 random answer from each of the submitters. id, submitter, answer 1, James, Blue 2, James, Red ...
0
votes
1answer
17 views

error - order by must appear inthe list of statements contains a union,intersect or except operator

In sql i want to add 'All' in the list for that I used the following code : select 'all' as stateid,'all' as statename union select stateid,statename from state order by stateshortname
0
votes
1answer
18 views

Reusing views to do aggregate queries [closed]

I have created some views which give me some values. So some thing like the following select from a table of all ids gives me some thing like id1 id2 id3 id4 view1 gives me id1 2 id1 1 id1 3 ...
2
votes
1answer
56 views

How can we select data from another table during an insert?

I'm trying to insert data into a table using a few columns that are hard-coded or are static values and then the rest of the datat selected from another table. I've tried the following query: insert ...
0
votes
1answer
33 views

Suitable schema to record email sent and response received and invoicing in DB

When a form submission is made on a website: An email with form's details is sent to a set of recipients email addresses stored in a DB. The email contains a link for the recipient to show interest. ...
0
votes
1answer
38 views

sql display error

When I run store procedure in SQL Server with parameter 4 param 1 = 'all' param 2 =' all' param 3 = 'all' Result :displays 21 rows When I run store procedure in SQL Server with parameter 4 param ...
0
votes
1answer
41 views

SQL CLR in MySQL? [on hold]

Can we call SQL CLR in MySQL Server using User Define Function? I want to create trigger in mysql. It will call user define function and this UDF will update the table in SQL Server.
0
votes
0answers
16 views

SQL Server 2008 R2 - Capture or be notified when an sql handle is ran

I'd like to monitor a particular SQL handle and find out who (process id) is running the SQL. Is there a way to retrieve either a list of proc ids who executed the SQL handle in last N minutes or be ...
0
votes
0answers
19 views

Sampling and matching samples with spatial conditions

The Problem I have two tables with start points of a route and possible end points of a route which need to be matched against each other. I also have a given distribution for the distance between ...
0
votes
0answers
87 views

How to calculate database query accurate responses? [closed]

I was given a set of data, 100000 rows of data queried using statistical interface for average value of an attribute. The response is determined using the random-sample query method, with subset of ...
0
votes
1answer
22 views

Only LIMIT rows with specific number

Sorry for the title, As I'm not that experienced I had a real hard time trying to come up with a proper title. So I have this query to fetch all the comments of a specific topic. Now for my paging I ...
0
votes
0answers
18 views

MYSQL — Inventory View with calculated fields

Trying To create an inventory view. I have created this query using MS Access query builder since I am no pro at SQL and this is pretty convoluted. When translating this into MYSQL syntax I get an ...
1
vote
1answer
39 views

MySQL Deadlock - accessing different primary key values also creating deadlock

I went through MySQL logs and found the reason for deadlock 1st thread is trying to execute below query. Which is waiting for thread 2. UPDATE M_SAMP SET MM_Q_IND=0 WHERE M_ID IN (SELECT M_ID FROM ...