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)

0
votes
0answers
6 views

Optimizing queries for 25+ million rows

I am using MS SQL, and I have to run several queries on the same table on different criteria. At first I ran each query on the original table although they all share some filtering (i.e Date, status). ...
0
votes
0answers
10 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
17 views

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

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, ...
2
votes
2answers
41 views

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

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
0answers
7 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)

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
22 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
32 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
14 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
24 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
34 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
3 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; ...
1
vote
1answer
28 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
36 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
31 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
0answers
49 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
6 views

Styled Data-Driven Reports for Print

I work at a school district and am helping to put together a project that will keep kids on track for graduation. We are able to flag a certain number of kids in our database who we can see are having ...
0
votes
0answers
13 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
12 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
26 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
19 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
110 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 [on hold]

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
55 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
28 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
38 views

SQL CLR in MySQL?

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
18 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
86 views

How to calculate database query accurate responses? [on hold]

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
16 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
38 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 ...
0
votes
0answers
16 views

FACT table loading

I have the below table structure : Ticket# Tckt_type Amount Acct Num 1 abc 10 1001 1 def 20 1002 So, for the same ticket number, there ...
1
vote
2answers
85 views

Query to return zero if nothing exist

I have a table With currency, paymenttype and invoiceamount. I have to write a query to get currency, paymenttype and total invoiceamount made. This is pretty simple with group by. But actually I ...
1
vote
2answers
38 views

Return counts for multiple ranges in a single SELECT statement

I have a Postgres database table foo that, among other things, has a column for score that ranges from 0 - 10. I want a query to return the total number of scores, the number of scores between 0 and ...
1
vote
1answer
47 views

Using LIKE or Full-text when searching database

I am fairly new to SQL and I am currently trying to create a search function for my website, much like the one on imdb.com. I have 3 tables and I need to search two rows (nvarchar) in each table when ...
0
votes
0answers
66 views

Reviewing ways to generate monthly tables using PL/SQL automatically

I am attempting to automate a set of tables that my colleagues produce monthly, using PL/SQL. The set of tables contain data about different metrics (e.g. Customer revenue, customer demographic ...
1
vote
1answer
35 views

Is there a way to get disc space remaining using an SQL query on an Oracle database?

We experienced a problem recently where the disc space ran low and some queries started giving unpredictable results. The root cause was that we'd take too many restore points and filled up the disc. ...
1
vote
1answer
57 views

SQL Server 2012 - Dropping Snapshots takes hours

We recently did a SQL Server upgrade from 2005 to 2012. We have a nightly job that drops a snapshot of an active database. The snapshots gets created again later in the day. Before upgrading, in SQL ...
-1
votes
2answers
28 views

Best approach to find out a string [closed]

I have a very huge database table named Customer and it has FirstName and LastName columns in it and I am looking for a string with name "Jack". My question is should I assume that the string is ...
0
votes
1answer
27 views

Function to handles firstname and lastname to a specific format

I'm trying to figuring out a way to show a name properly. Let's say I have 2 variable : @Firstname = 'Marc-Oliver' @Lastname = 'Saint-Onge' I would like to have name shown as; M.-O. St.Onge Or ...
0
votes
2answers
42 views

SQL Server choose at random from giving data

My problem is that I don't know how to choose the random data from a giving set. For example: I have a Node column which need to produce different inserts but only from these numbers: 16, 17, 18, 22, ...
0
votes
1answer
40 views

Different runtimes using parameter vs. constant

A strange thing is happening to me during execution a specific query. I have this query: DECLARE @P0 as varchar(4000) DECLARE @P1 as varchar(4000) SET @P0 ='P0' SET @P1 ='2015-02-21 00:00:00' ...
2
votes
2answers
54 views

Cannot generate SSPI context ( SQL Server 2008 ) ( RESOLVED )

When someone tries to connect to a SQL Server instance, the error shows up: It's not possible do generate SSPI context. Yesterday we had a blackout (don't know how to say this expression in ...
0
votes
2answers
41 views

how to identify table name using a column name if we are not aware about the table name

how to identify table name using a column name if we are not aware about the table name Imagine if you have 10000 tables in Database I am aware about the column name , but i dont know the exact ...
0
votes
0answers
32 views

How to fetch data on a single column from a table having composite key

I am working on a messaging application, where the users can have a group conversation with multiple recipients. So in my database, I have a table called user_message where user_id and message_id is ...
-3
votes
1answer
53 views

How match a numeric column with a varchar parameter? [closed]

external_id in my source table is of varchar(255) data type I need to convert it to a numeric(20) to do a lookup on target table where card_id (contains external_id's) is of numeric(20) data type. I ...