An acronym for "Structured Query Language" (it's not the name of a specific DBMS product), SQL can be used in relational database management systems (RDBMS) to query, update, delete, and insert data as well as modify the structure of the database. It can also be used to manage schemas and data ...

learn more… | top users | synonyms (1)

0
votes
0answers
19 views

How could index be used so that only records that satisfy certain criteria are accessed?

I will start this question by saying YES, this is a part of my assessment, but i am trying to learn. I have the following question. Assume that a student table in a university database had an ...
1
vote
2answers
34 views

can i use php functions strtotime() in sql queries

i have this table i need to use a php function in the query id time lastTime 1 08:02 2 08:04 3 08:30 iam using this query with the strtotime() and its not working UPDATE ...
1
vote
3answers
31 views

Removing chat history for a particular user from database

I'm currently developing a web chat application using SignleR and SQL server this is my database schema so far I've added an option where the user can Clear Chat history for a particular ...
-2
votes
0answers
18 views

Database Timeout expiring when tables fill up

Once my database starts to fill up with the tables being used, my stored procedures are taking longer to execute. If I truncate the data and execute again, execution time usually takes 3 minutes. Once ...
1
vote
1answer
28 views

PostGIS vs. SQL Server for GIS data

So I'm recently starting at a new company and have a lot of ArcGIS users who seem really keen on going forwards with a PostGIS instance to serve some data to our customers. While I don't have an issue ...
0
votes
0answers
26 views

How I can monitor SQL Server 2012 databases to determine the security privileges that are called by different processes

Is there any tool that can identify the SQL privileges or roles that are being called on query by query basis. We need to know which ones are being used at each time on a Microsoft SQL Server 2012.
0
votes
0answers
25 views

What is the difference between Row and Table Expressions in MySQL

Can anybody explain with example what is a Row and Table expression and what is the difference between them. Any example for clarification will be appreciated.
1
vote
1answer
27 views

Upsert statement never completes, infinite loop?

Edit: The function works, tested it by creating a small table. So the problem must be with my input, but I still can't see what the issue is - unless the function is just incredibly slow. It's not a ...
0
votes
1answer
33 views

JOIN on 3 tables being slow

everyone. Can't figure out what indices are missing or how to rephrase my query. I created about a milllion of test entries in each table to see performance. Query takes about 1.5 seconds which is ...
0
votes
1answer
18 views

Bulk insert in multiple tables

I have two tables on which I perform some bulk inserts: key: key_id(pk), key_name related_key: key_id(fk), related_key_id First Insert: values_data = "($$key_1$$), ($$key_2$$)" INSERT INTO key ...
0
votes
0answers
36 views

table check constraint, greater than > not accepting

CONSTRAINT CK_BABY_YOUTH_CHILD CHECK (case when Passenger_Type='Baby' then Reference_ID >=0) This is my table check constraint, i have no idea why sql server is not accepting ">". Please ...
0
votes
1answer
38 views

What's faster: two UPDATEs with WHERE (in / not in) or one UPDATE with CASE?

What's best performance wise, two separate UPDATEs: UPDATE table1 SET enabled = 0 WHERE code NOT IN ( SELECT id FROM table2 ); UPDATE table1 SET enabled = 1 WHERE ...
0
votes
2answers
53 views

Dynamic Table partitioning on a daily basis

I have a SQL Server database which contains two tables -- Acks and Logs. These two tables are related in logic but not in a relational database way. Basically, every message that comes in gets saved ...
0
votes
0answers
28 views

sql server 2012 execute as query [on hold]

Please look at this question and i have two options You administer a Microsoft SQL Server 2012 database named ContosoDb. The database contains a table named Suppliers and a column named IsActive in ...
0
votes
0answers
24 views

Should I drop this column or is there a query that can achieve a results table without duplicate columns?

I use a column named active in several of my database tables to adjust whether a particular entry/row/user/etc should be included in future query result tables instead of deleting the information. ...
0
votes
3answers
37 views

PostgreSQL equivalent of MySQL query variables?

Is there a straightforward way to adapt these types of MySQL queries to PostgreSQL: setting variables in MySQL like set @aintconst = -333 set @arealconst = -9.999 It seems not. Assigning ...
0
votes
1answer
43 views

deleting a table referenced by many foreign keys

I have a table that I want to drop and create again, because I want to add the IDENTITY property to a column, wich is not possible directly. The problem is that I can't drop it, because my column is ...
0
votes
2answers
50 views

Check Constraint with Case Statement

I want to add a check constraint on a column if entered value for column is greater than 3 than it should be saved as 1 else entered value. For that scenario I am using below query but on insertion of ...
6
votes
2answers
172 views

Why are simple SELECTs on InnoDB 100x slower than on MyISAM?

I have quite an annoying problem. I want to use INNODB as my main database engine and give up on MyISAM as I need the former for using galera-cluster for redundancy. I copied (description follows) ...
0
votes
0answers
53 views

Technical documentation for Replication [on hold]

My boss wants me to write a technical paper on replication, I don't know where to start or what to write about. We held a discussion and he talked about: Managed Code (we use VB.NET) Triggers ...
1
vote
0answers
54 views

Outer Apply vs Left Join Performance

I am Using SQL SERVER 2008 R2 I just came across APPLY in SQL and loved how it solves query problems for so many cases, Many of the tables I was using 2 left join to get the result, I was able to ...
0
votes
2answers
24 views

Users Characteristics

I'm really battling an issue where I have a Users table that has a growing number of user characteristics (regligion, smoking preferences, etc). The strategy I've used thus far has been to add a ...
0
votes
0answers
42 views

Double subquery is very slow, but independently they are fine

I have this query: SELECT mac, pid, node_category.name, status, computername, user_agent, detect_date, regdate, unregdate, last_dhcp, node.notes, (SELECT ip FROM iplog WHERE iplog.mac = node.mac ...
1
vote
3answers
31 views

Query to return output column names and data types of a query, table or view

Is there a PostgreSQL query or command that returns the field names and field types of a query, table or view? E.g., a solution if applied to simple SELECT query like SELECT * from person should ...
1
vote
1answer
31 views

Break AG Cluster

I have a 2 node cluster setup and we use AlwaysOn HA with it. Currently we have two AG's and each one has three separate databases in each AG. We want to break the cluster and have three databases ...
1
vote
0answers
43 views

Relational or non-relational database for a system to pass objects on?

hopefully this is the right place to ask this kind of question. I am working on a system that focuses on helping people give away things that they don't use anymore. So, an object typically has the ...
0
votes
2answers
27 views

How to implement a dynamic string into a (prepared) sql statement?

I have some spatial datasets which are available in a open source metadata catalog software GeoNetwork and in a PostGIS database. The problem is that the student who created the database used ...
0
votes
1answer
34 views

The materialized view is already optimal and cannot be tuned any further

I have tried DBMS_ADVISOR.TUNE_MVIEW to verify some materialized views created locally. One of the result returns an error: Error report: ORA-13600: error encountered in Advisor QSM-03116: The ...
-3
votes
0answers
14 views

what is inventory cleansing and data cleaning? [on hold]

Can anyone tell me the complete process of inventory cleansing and data cleansing in a data base?
2
votes
1answer
43 views

Fastest way to change column type from varchar2 to number on large table in Oracle

I have a table which contains a VARCHAR2 column that must me changed into NUMBER. The table contains more than 30 millions rows. The table definition : CREATE TABLE EFF ( MOD ...
0
votes
1answer
34 views

Frustrating SQL Server and VS Express 2013 Issue

I recently reinstalled Windows and am trying to set up SQL Server again with an existing database. I've tried installing SQL Server 2012 and 2014, and continuously get the same error. The error says ...
0
votes
2answers
26 views

Adding DATETIME() and Status column with xp_FileExist result

I'm trying to add a two columns in addition to the results of xp_FileExist. Here's my T-SQL: DECLARE @path varchar (100) DECLARE @file varchar (100) SET @file = '<location>\*.txt' SET @path = ...
0
votes
1answer
52 views

CROSS APPLY versus INNER JOIN

I was reading a lot about cross apply versus inner join recently. I tried writing some query and they both work kinda same, execution seem to be same aswell. Maybe someone with a deeper knowledge ...
1
vote
1answer
22 views

mysqldump - select table in database only if it contains a specific string

(I'm new to Database Administrators, and am not a Database Administrator. However I originally asked this question on Stack Overflow (here) but didn't get any answers. Sorry if this is not the right ...
1
vote
0answers
56 views

SQL select top X rows having sum limit

I am using SQL Server 2012, I have a table with a format such as : MyOrders : ID -> PK int Cost -> float Category -> int I want to get the following : Input : category (lets say 2). ...
0
votes
0answers
58 views

Stored Procedure's Commented line causing issues [on hold]

We have a stored procedure which works as the sample mentioned below: CREATE PROCEDURE [dbo].[sdp_Test_Update] ( @ID int OUTPUT, @File_ID int, ...
1
vote
3answers
40 views

Can set unique constraint in table have data not unique SQL Server? [duplicate]

I have a table with has many rows, I want to set unique constraint for this table, but the column that must be unique, has data is not unique. Is any way to set unique constraint for this table for ...
2
votes
2answers
76 views

GROUP BY one column, while sorting by another in PostgreSQL

How can I GROUP BY one column, while sorting only by another. I'm trying to do the following: SELECT dbId,retreivalTime FROM FileItems WHERE sourceSite='something' GROUP BY seriesName ...
0
votes
0answers
5 views

Using range types (with GiST index)

Say I have 2 tables with a PostgreSQL range column: CREATE TABLE events ( id serial, during tsrange ); and CREATE TABLE storms ( id serial, during ...
0
votes
1answer
20 views

Row-level subquery caching?

I have a query that uses a CTE which contains millions of rows. I plan to call this query many times, and the CTE returned each time will have most of the same rows. Is it possible for me to cache the ...
1
vote
3answers
101 views

Why MAX() of SUM() giving wrong output?

I have a table employee id name salary city 1 ram 50000 c1 2 sham 20000 c2 3 jadu 80000 c1 4 madhu 90000 c4 5 hari 10000 c2 6 gopal 34000 c3 7 ...
1
vote
1answer
18 views

Index on integer column not helping. Help? (EXPLAIN ANALYZE output inside)

The table market_trades has an integer column market_id which takes values from 1 to 5. This seems like a pretty straightforward query to get the number of trades on each market: WITH markets AS ( ...
1
vote
1answer
36 views

Optimizing a query on a large table (EXPLAIN ANALYZE result inside)

I have a table market_trades with a timestamp column: api_production=# \d market_trades; Table "public.market_trades" Column | Type ...
1
vote
2answers
27 views

sp_publication_validation procedure doesn't seem to work properly

I am trying to use sp_publication_validation stored procedure to validate that my replication setup is working correctly. This procedure is pretty straightforward and is described here. I am running ...
0
votes
0answers
21 views

Combining 2queries: One filtered Users on Role, One Select users with only one specific role

First query: Selects All users with specific rid ( 3 or 4 or 19 or ...). SELECT u.uid AS uid, u.name AS name, fn.field_full_name_value AS field_full_name_value FROM users u LEFT OUTER ...
1
vote
0answers
28 views

How to add SQL Server in networks list?

After changing my PC name and workgroup, I am no longer able to connect to SQL Server. Currently in my servers list I have only Home & localhost. Anybody know how to add server to networks list? ...
-7
votes
0answers
53 views

What's new in SQL Server 2014 T-SQL since SQL Server 2008 R2? [closed]

I want to upgrade my sql server from 2008 to 2014 and I wanna know what's new in programmability T-SQL enhancements.Now I'm installing 2014 to make few T-SQL tests. Thanks
2
votes
5answers
75 views

Make IN clause behave like AND clause

I've asked the same question on stackoverlow, but got no answer, so that's why I'm asking it here (I've read that simple sql questions should be asked at SO, but I have no choice). Suppose I have 3 ...
-3
votes
0answers
71 views

SQL Query Consuming lot of CPU Usage:

Following SQL Query is Consuming lot of CPU Usage: SELECT * FROM (SELECT REQ.* FROM provisioningrequest REQ, unique_id_mapping UN WHERE ( instance_name IS NULL ...
1
vote
0answers
47 views

How to handle many columns / variable schema?

I apologize in advance in case this question has been asked already. I'm working on revamping a reporting application used within my company. The requirements are: Support addition of new fields ...