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
2answers
682 views

LIMIT to one row per ID

This query gives me multiple hits because of each assetid may contain many vb.title. How can I limit the result to only 1 hit for each assetid? 'select DISTINCT v.id, v.purchasedate, ...
-2
votes
1answer
46 views

What are the ways to handle temp table with more than 9000 rows? [closed]

I am creating a temp table in my stored procedure which has more than 9000 rows and I read some articles saying that its bad practice to use temp table with more than 9000 rows as it uses temb db for ...
0
votes
2answers
39 views

Searching a database safely using SELECT

I have a site that allows users to search the database for several items. However I am not that good with SQL and I have read that allowing user to type in boxes that then use "SELECT-statements" is ...
2
votes
1answer
671 views

Split comma separated entries to rows

I have a Table like this: | ID | OtherID | Data +--------+-----------+--------------------------- | 5059 | 73831 | 5103,5107 | 5059 | 73941 | 5103,5104,5107 | 5059 | 73974 | ...
0
votes
0answers
22 views

How to fix slow performed query with joins while pagination?

I've following tables with respective records. 1) wi_individual_g with 85K records 2) wi_organization with 550 records 3) wi_program with 2 records I've used following query for creating ...
1
vote
0answers
19 views

usertype column is giving error [closed]

Whenver I am running this query it is running fine. Because in the end I have only one usertype=2 SELECT dbo.tbl_post.title, dbo.tbl_post.description, dbo.tbl_post.active, ...
-1
votes
2answers
712 views

Remove a character from a records enclosed between double quotes

I have a table in which every row have data like: 0150566115,"HEALTH 401K","IC,ON","ICON HEALTH 401K",,,1,08/21/2014 What I want is to remove every comma (,) that is enclosed between double quotes ...
0
votes
1answer
129 views

How can I reseed all identity columns?

I deleted all rows from 20 tables after disabling the constraints, triggers using the stored proc SP_MsForEachTable. Now before the import happens, I need to reseed all the identity columns back to ...
0
votes
1answer
67 views

What is the correct SQL for using where ID in List and the items are with AND operator

I need a SQL Statement to use IN operator within the items with "And" connected. SELECT * from tbl_Users WHERE id in [1,2,3] is equivalent to: SELECT * from tbl_Users WHERE (id=1) or (id = 2) or ...
2
votes
1answer
154 views

Search within same ID across several rows

My table has the following structure: +----+---------+------------+-------------+ | id | word_id | meaning_id | sentence_id | +----+---------+------------+-------------+ | 1 | 1 | 15333 | ...
1
vote
1answer
27 views

SSIS Transaction Problem

I am trying to use SQL transaction with my SSIS package so if any error comes changes are rollback. I am using an "Sequence Container" in Control Flow for this and setting its "Transaction Option" to ...
1
vote
1answer
27 views

System.Data.Entity.Infrastructure.CommitFailedException: C# Multithreading & SQL Server 2012

We have a C# multi threaded (100 threads) program which reads the records from the DB and each thread picks up one record (one Entity Framework connection per thread) and update the a single DB table. ...
0
votes
0answers
27 views

How to Make a Condition Before insert a Row According to XML value

I'm facing a logically issue in SQL SERVER 2014 that how can i make a condition to insert a rows , these rows must be a valid values and these values are included in Xml Column I've Two (2) Tables ...
0
votes
1answer
15 views

How do I write this MySQL query?

I have a table with a column of numbers that are consecutive but not concurrent. So 91 may be followed by 92 or it may be followed by 96, for example) with intervening numbers not in the column. I ...
0
votes
2answers
33 views

WHERE clause converting INT to DATETIME

Looking for advice on how to match two differing column types: I have two tables: RT-A and DA-B. Under both tables there is a column named DeliveryDate, but the individual tables use differing ...
0
votes
0answers
36 views

Database Hangs while trying to run sql

I have a challenge with SQL Server. We are running SQL with an inhouse developed application. Lately we have been having a challenge where the DB hangs and users are unable to access the application. ...
1
vote
1answer
180 views

Sql Server sys.Traces log

Working with traces on production server I found some mysterious entries to me in sys.Traces, When I run below query it shows me status of all traces as ‘Paused’ along with entries in ...
2
votes
1answer
769 views

Designing database with Category and Tags for Posts - Seeking for guidance/advice

I'm not really a database novice but I'm not an expert either. Problem: I'm having this difficulty on designing my Post, Category and Tags relationship. I've read Normalization many times but could ...
1
vote
1answer
50 views

PostgreSQL isn't using indices in FULL OUTER JOIN

I have these tables I'd like to do a FULL OUTER JOIN between. They both have an index on (ts_minute, user_id, campaign_id, host_id) (which matches the join condition). In the following query, if I ...
2
votes
3answers
159 views

find all numbers that appear at least three times consecutively

This is a question from leetcode online judge I tried this SELECT Num FROM Logs GROUP BY Num HAVING COUNT (Num) >1 but got runtime error!! Anyhelp would be appreciated
0
votes
0answers
10 views

Postgresql : Table historisation

I would like to do a script that gather data from an API everyday. (8000 lines/days) So for each object would like a object1 table for the data of the day. And a object1_hist for archived data. ...
0
votes
0answers
33 views

how to optimize a query with a lot of join

I have the following query: SELECT DISTINCT s0_.id AS id0, s0_.created AS created1, s0_.style AS style2, s0_.styleTitle AS styleTitle3, s0_.styleTitleDescription AS ...
0
votes
0answers
12 views

call a file contains a list of table

I'm using Ingres Database and I've this procedure that create a text file with a list of tables. How i can call the file into the where condition? select request_num,table_name,temp_table from tables ...
3
votes
6answers
664 views

Steps after restoring to a different server

We have a 30 GB Database on SQL Server 2008 R2 Standard Edition. Yesterday we backed up the database and restored it to a different Virtual Machine which has exactly the same specs as the previous ...
0
votes
1answer
40 views

Optimizing a MySql query

Here's the query: set @_YEAR = 2014; set @_MONTH = 1; set @_PRODUCTS = '53'; set @_START = date(@_YEAR * 10000 + 1 * 100 + 1); set @_END = date_add(date(@_YEAR * 10000 + 1 * 100 + 1), interval 1 ...
0
votes
1answer
78 views

Restore InnoDB from .frm files

My database crashed and my PC and I now only have the .frm and .ibd files left. Is there any way to restore my database?
2
votes
1answer
109 views

Select a range of values

I have the following data in rows: 1 2 3 6 7 15 16 I want to write a SELECT statement to return contiguous ranges. Given the sample data above, the output would be: 1,2,3 6,7 15,16
2
votes
3answers
73 views

Find duplicate records across one-to-many relationship tables

Let's say I have two tables that have a one-to-many relationship: People and Attributes. I'm trying to find duplicates based on the first_name, last_name, and all attributes must match exactly. ...
1
vote
1answer
39 views

Join and count boolean columns by logical OR

There are two tables: user_table and user_schedule. Each user has four schedule rows (one for each 6 hour period per day) with one column for every workday. The desired result is to count the number ...
0
votes
1answer
26 views

set unique key checks 0 in mydql

In a table i have unique value check for the combination of box_number,price,start_val,end_val so there can not be a two box number with same number which have same price , start_val and end_val.. ...
-1
votes
1answer
27 views

Query optimization and takes less execution time

CASE-1: SELECT * FROM A JOIN B ON B.CustomerID=A.CustomerID CASE-2: SELECT * FROM A JOIN (SELECT * FROM B) C ON C.CustomerID =A.CustomerID Which CASE is efficient ?
0
votes
1answer
37 views

How to remove the duplicate records from primary filegroup after partitioning?

Basically, our database is created based on primary filegroup alone. Now, I have done partitioning for a large table which was approx 25 GB. The partitioning was done on secondary filegroups which ...
-1
votes
1answer
33 views

System.Data.SqlClient.SqlException when try to run simply queries

I've installed SQL Server 2012 Express. I'm doing some test with this and Server 2008 Express. With 2008, all is ok. But with the 2012, I get some troubles. I'm using it from my c# app, with code ...
-4
votes
1answer
38 views

Who is depends on specific column? [closed]

I want to alter column table from varchar X to Y. And for that I need to know who is depend on this column . Any suggestion?
1
vote
0answers
82 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 ...
3
votes
1answer
112 views

How can I prevent having inconsistent data under isolation level serializable in Oracle SQL?

I have the following table: InStores +--------+---------+-----+ | ProdID | StoreID | qty | +--------+---------+-----+ | p1 | s1 | 25 | | p1 | s2 | 70 | +--------+---------+-----+ ...
0
votes
0answers
39 views

SQL Server 2012 Downgraded from Enterprise to Standard. Permission errors

We downgraded our SQL Server from Enterprise to Standard. Now on 3 of my 5 non system databases a lot of users no longer have effective permissions. My admin account is in the same boat. I have ...
0
votes
2answers
50 views

How to select the largest value of the same column in multiple tables?

I have multiple tables which have some columns with the same meaning, eg., event_timestamp. The schemas are like following: Table A: ...
1
vote
1answer
95 views

Check entry based on entry in another column

Still fairly new to databases and SQL, so bear with me. I'm trying to check whether or not data can be inserted depending on data in another column, create table Table1 (PaymentType varchar(5) ...
0
votes
1answer
600 views

Grouping and counting rows by existence of matching criteria in any of several columns

Disclaimer: I've inherited a database which is probably not quite as "normal" as I would like, and I'm limited to Jet/MS Access 2010 for my db backend and interface, as well my choice of reporting ...
0
votes
2answers
15 views

Added a unique index, but cannot find it in TABLE_CONSTRAINTS

I'm running the following command in my DB: CREATE UNIQUE INDEX [UK_NAME1] ON [TABLE1] ([COLUMN1] ASC); Now, I'm running the following query: SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS ...
0
votes
1answer
204 views

Data Analysis with MongoDB or MySQL

I have a need for processing some data in order to come up with some statistic. This is the scenario: Each user can answer several questions from the question list. They pick their answers from a ...
3
votes
1answer
89 views

Update old database with SQL dump

I had to recover a database with a some months old full backup. I have however in my possession a most recent but unfortunately incomplete SQL dump for this same database done with mysqldump. Is ...
0
votes
1answer
48 views

SQL Server counting rows

I have an imported database and I'm running a query. I want to count the rows found and output it. Here is my query: select mualbum.album, mutitle.title, mutitle.comp from MUALBUM inner ...
0
votes
1answer
172 views

Generate All days in moth report using PIVOT of SQL server

My table, tblEmployeeScan(EMPLOYEE_ID varchar(7), ScannedTime) Everyday each employee scans 2 times, 1 time or 0 time Now I want to create store procedure Create proc spMonthScanReport @MONTH ...
2
votes
1answer
283 views

Slow Performance of Parametrized Query in Excel due to Parameter Datatype

I'm pulling Data from a SQL Server 2008 into Excel using a Parametrized ODBC Query created by the Excel Wizard. (Data-->getExternalData/FromOtherSources-->FromDataConnectionWizard-->ODBC DSN) My ...
1
vote
2answers
6k views

exporting oracle tables on command line as sql files

I use exp and expdp to export database tables on command line but it generates binary .dmp files. I want to export/import tables as .sql* files on command line like pl/sql developer app can do. Is ...
2
votes
1answer
30 views

INSERT multiple values via join

I have three tables, representing two entities and a connection relationship. Each of the entity relations has an artificial surrogate key used for foreign key constraints in place of natural keys. ...
1
vote
1answer
61 views

Multi table GROUP BY query optimisation

Currently I have a multi table/column GROUP BY query which is pretty slow. Below is the tables schema used by the query: report Table ...
10
votes
2answers
3k views

Best way to populate a new column in a large table?

We have a 2.2 GB table in Postgres with 7,801,611 rows in it. We are adding a uuid/guid column to it and I am wondering what the best way to populate that column is (as we want to add a NOT NULL ...