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
8 views

Count of delimited items in bytea encoded string

How would you get a count for each of $ delimited Individuals in each of the group_names? (Example: SomeGroup has 1, This Is Another Group has 8) thedb=# select group_name,encode(group_data,'escape') ...
1
vote
1answer
34 views

Rebuild vs Reorganize [duplicate]

I currently have a maintenance plan that is reorganizing indexes everyday and I would like to know if you reorganize an index everyday would you ever need to rebuild the index? If so, why?
0
votes
2answers
84 views

SQL Query - Possibly the most poorly written query in the history of mankind

Having a major headache trying to tune this query and looking for help, a programmer who had no idea what they were doing messed with this query and it is currently being used in production and it ...
0
votes
1answer
22 views

MySQL - How to replace a given value from multiple columns when using SELECT?

I need to SELECT a set of rows of a given table whose structure looks like - 1º line is the name of columns A01 A02 A03 A04 A05 ... A200 99999 99999 10 753 99999 ...
0
votes
0answers
26 views

Cannot insert into table

I have created a table called users in my computer by the following method. <table name="users"> </table> Now I am trying to insert a record in it by the following method. ...
0
votes
0answers
19 views

Procedure or function 'sp_InsertImages' expects parameter '@Img_path', which was not supplied [migrated]

i have passed img_path in my code nd procedure but it show me error please anyone help me. my procedure is : create proc sp_InsertImages ( @Img_path nvarchar(max), @product_id numeric(18,0), ...
0
votes
0answers
11 views

SSRS Report queries begin running slowly, have to stop and start report server to restore performance

We have had a production issue crop up twice now where reports begin running slowly seemingly at random. When this happens we can see from running SQL Profiler that the report queries are taking an ...
1
vote
0answers
27 views

Rolling back a SQL Server 2008R2 Database stored in SQL Server Express [on hold]

We had an accident where a bunch of data was deleted from one of our products. The product removed a bunch of lines from various tables about 12 hours ago. There is no good backup and I try to ...
0
votes
0answers
40 views

SQL Server Timesheet Query Performance

I am working on a webapp for timesheet administration. I write a query to group all the time entry of an employee by week. And I also have to use paging. The query is already slow with something like ...
2
votes
1answer
33 views

Log shipping and new NDF file

I have a log shipped database, and I want to create a new NDF file in another disk for moving historic tables to that NDF file. My goal is to free some space in the MDF file because the disk that the ...
0
votes
1answer
47 views

MYSQL any way to improve this query's performance?

MYSQL version 5.6.23 CENTOS 7 Hi, I have the following query that is coming from an application that I am hoping to make more efficient from the mysql side of things. I have an index built on ...
0
votes
0answers
23 views

Database Role Membership: db_executor vs db_datareader and db_datawriter in SQL Server 2008R2?

I have a couple of users who have only public and db_executor memberships in their Server Login object, User Mapping properties in the one database (let's call it A), now that our front end ...
0
votes
1answer
42 views

Any tips to watch out for when setting one of my databases to Read Only?

Our front end application uses\ pointed to a different database now in SQL Server 2008R2 in the same instance, so to prevent users from accidentally updating data in the old production database, is it ...
0
votes
1answer
16 views

GRANT permissions to all tables, views, procedures in SQL Server 2000

I was wondering if there was a fairly efficient way to use T-SQL with SQL Server 2000 syntax to GRANT SELECT, INSERT, UPDATE, DELETE, on all TABLES and VIEWS for a particular database while excluding ...
-5
votes
1answer
32 views

Increment the value of an entire column [on hold]

I have a table and one of the columns, is of the data type int. I want to increase every tuple's value of that specific column by 100. I have not found a proper answer for this yet. Anybody?
0
votes
0answers
19 views

Best way to run a formula (segment) a large number of users with custom attributes

Here is my question. I have a table that stores a large number of people (80 mil). Each person has a GUID id. Then I have another table (or set of tables) that stores information about people. e.g. ...
2
votes
2answers
177 views

MySQL - How to check whether all values of a given SELECTed row are equals? [on hold]

Using MySQL, how can i SELECT all rows whose values are equals ? For instance, suppose a SELECT of a given table as follows COLUMN_A COLUMN_B COLUMN_C ... COLUMN_N 1 2 4 ...
0
votes
1answer
13 views

sub and sub-sub item organization system [duplicate]

So I am looking to find the best database design for the following situation. I will refer to my entities as 'articles' as that would best/most-easily describe them. So the articles have already ...
0
votes
2answers
83 views

Storing IP addresses - varchar(45) vs varbinary(16)

I am going to create a table with two fields - ID as BIGINT and IPAddress as either varchar(45) or varbinary(16). The idea is to store all unique IP addresses and use a reference ID instead the actual ...
3
votes
3answers
83 views

How to interpret correlated subqueries?

EDIT: Both answers are great but I think I must clarify my question. NOTE: I must indicate that in the following, by executed, I mean logically. I understand that the actual execution made by the ...
2
votes
2answers
43 views

Sampling in PostgreSQL

I am looking for possible ways of random sampling in PostgreSQL. I found a couple of methods to do that with different advantages and disadvantages. The naive way to do that is: select * from ...
1
vote
1answer
39 views

updating same column as in the select query

When I try to do this, I get an error saying I cannot use the same table in where select as the column that I am updating. UPDATE table_name SET quantity = 19 WHERE productID = 148357 ...
-1
votes
1answer
15 views

Query issue for login page in asp.net? [on hold]

I would like to create a simple login page in asp.net. here is my code: protected void Button1_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection(); ...
0
votes
1answer
43 views

SQL update multiple columns matching a pattern

I have a table in a postgresql database in which I have multiple columns matching a pattern /\w*(?:_open|_close)/g. Those are timefields. I would like to substract 1 hour from all the rows on those ...
1
vote
1answer
29 views

Reference column alias in same SELECT list

I'm converting an old MS-Access-based system to PostgreSQL. In Access, fields that were made up in SELECTs could be used as parts of equations for later fields, like this: SELECT samples.id, ...
6
votes
1answer
674 views

SQL Query challenge

I have what seemed like an easy query to write, that really has me stumped - can anyone help me please? So this is really easy on paper, but I can't translate it into SQL. Lets say you have some ...
-1
votes
1answer
25 views

Prioritised table query

I'm looking for a way to query two tables at once but ... I want the query to first run against Table A and then if Table A returns no matching records to query Table B. There many well be instances ...
4
votes
1answer
98 views

SQL “Standard” guide?

I am currently learning TSQL and am learning that were possible, I should use "standard" SQL dialect. Where can I find out which commands are "standard" and which are TSQL?
-2
votes
0answers
28 views

How to restore database? [on hold]

When you save metadata (added new column selection) from the translation of reference issued SQL error message: The log file for database '' is full. Back up the transaction for the database to ...
0
votes
2answers
32 views

Executing stored procedures asynchronously using tasks in SSIS

I have a stored procedure which is calling 20-30 stored procedures. I need these stored procedures to run asynchronously. From what I have read, it seems like executing those stored procedures using ...
-3
votes
2answers
47 views

optimisation for 4million + records [on hold]

I have a table full of addresses in one state. ID, address, state_id,region_id, suburb_friendly_url,street_name_friendly_url I have indexes on all of these fields. A cluster index on address. Doing ...
3
votes
2answers
173 views

sql querying for a pattern

I was hoping someone could steer me in the right direction with this one. I have a table that has student grades. Create Table StudentGrades ( StudentID references Student(StudentID) int not null, ...
0
votes
1answer
43 views

How to merge two databases, both with primary keys

I have two databases, both with the same tables, but the data is out of sync. I need to add data from database A to database B, but not overwrite any data in B that exists in A, instead add it with a ...
0
votes
0answers
28 views

delete query performance issue on mysql

I have two tables table1, table2 where table2 is a subset of table1 (basically created with the query create table table2 as select * from table1 where .....) Now, I am trying to run the below query. ...
-1
votes
1answer
24 views

Retrieve user Permissions on a database [closed]

Please could you provide me query that shows user(John Felix) permissions on a server\database.
0
votes
1answer
20 views

Optimize Query in MySQL

I've following tables with respective fields 1) wi_individual_g(ind_id,ind_is_recepient,ind_deleted,ind_district_id,...) - Around 200K data 2) wi_individual_p(ind_id,prg_id,...) Around 250K data 3) ...
-1
votes
0answers
9 views

Can anyone convert this SQL into Rational Algebra Format [closed]

select RATE.rname, RATE.boundary from RATE, ROUND, CANDIDATE where RATE.rname=ROUND.rname and ROUND.cname=CANDIDATE.cname and CANDIDATE.person_name=’Jacky’;
0
votes
0answers
5 views

Access 2010 delete and append queries run partially then give “Read Only” error

I have a number of append and delete queries written in Access 2010 that link to and modify tables on our SharePoint 2010 site. These queries have run without problem for months, but suddenly they've ...
2
votes
1answer
20 views

Linking SQL Server tables to a PostgreSQL Server

I have a SQL Server 2005 instance and also a PostgreSQL 9.3 running on the same network, I would like to know if its possible to somehow create or have 'views' on a database within the PostgreSQL ...
1
vote
2answers
20 views

How can I map a login to a database using T-SQL (not SSMS)

I'm writing a program that requires me to assign all permissions and everything in code. I have gotten stuck in this part: I just want to do the equivalent of clicking the little box under "Map" ...
1
vote
3answers
43 views

Script to drop all databases except one not working

I'm trying to drop all databases but one on my test server. For this, I'm using the below script but it gives error: EXEC sp_MSforeachdb ' USE [?] IF (DB_ID(''?'') > 4 AND DB_NAME()!=''ABC'') ...
1
vote
0answers
43 views

Is there a way to improve this query further?

I've got a query that over time I've been improving. Originally it simply selected * from the records table, and the data was formatted on the webapp side. But that was slow and I wanted to make ...
0
votes
1answer
38 views

SQL select with unique_list - losing an item

I have an oracle database and I have the following problem: If I make an select like this: SELECT fk_proddes_id,fk_id_cod_deseu, LISTAGG (TO_CHAR (cod_eliminare), ',') WITHIN ...
0
votes
0answers
41 views

Why is MySQL not saving inserted data?

So I have the following insert statement that I run through MySQL Workbench: INSERT INTO PeakOnlineCount (time_stamp, LocationId, Count) values ('2015-03-26', 0, 1) If I run the following query: ...
0
votes
1answer
22 views

oracle database - sql for counting the columns with the same id with the one in current row

I have an oracle database and a few tables and with this query: select rap.DENUMIRE,a3.ID,op.FK_ID, (SELECT COUNT(*) FROM ANEXA3_TABEL1_ROWS) AS count from ANEXA3_TABEL1_ROWS a3 inner join ...
0
votes
0answers
18 views

DB space vs query complexity tradeoff

I have a dilemma - Right now I have a query that I do constantly - joining 5 tables on different columns, calculate stuff per row, distinct on that, and do that with offset and limit (pagination). I ...
-2
votes
0answers
13 views

Can anyone tell me which programming language is from www.freelancer.com, www.clickbank, www.craigslist.org and www.pof.com? [closed]

I want to build a site like www.pof.com and advance search area is my favor (key word post and match and searching). Any one can tell me better, simple and easy to apply and manage in the future for ...
2
votes
1answer
33 views

How to keep updates (diffs) of some entity in the database

What is the best way to keep updates (diffs) of the some entity in the database? At StackOverflow we can edit questions and answers. And then we can look at any revision of the question or answer we ...
3
votes
2answers
34 views

Getting Machine name from where stored procedure was last executed

Is there any way to find out machine IP or machine name from where a particular stored procedure is executed in SQL Server 2005? We have a client server architecture with .NET as a front end and SQL ...
0
votes
0answers
11 views

Populating a table with data from a table that has the historical data on columns (SQL/plSQL 10g) [closed]

I have to populate a table with information from a table that has the historical data on columns. The source table name is source table xxtbl_source(client_id number, dec_14 number, nov_14 number, ...