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
1answer
232 views

sort a large table by its primary key and save it back

So I have a large table (>50 million rows) with an auto incremented primary key column, which is filled by a script running on multiple cores. Now, when I do a SELECT, entries are returned 'out of ...
0
votes
1answer
54 views

Suggest performance tradeoffs

I have a an inner query that needs outer query column values as input. It looks something like this CREATE TABLE TISSET( COL1 int ,COL2 int,COL3 int) INSERT INTO TISSET VALUES (1,1,1); INSERT ...
1
vote
0answers
116 views

How to merge rows based on how much data they have?

I am cleaning data and I formed a table something like this: file | product | color | product_id --------------------------------------------- one.csv pipe blue null ...
0
votes
1answer
182 views

SQL Server Standard High Availability (HA) with two nodes

Is it possible to accomplish High Availability (HA) with two SQL Server Standard nodes ? We can't use SQL Server 2012 AlwaysOn without Groups as it has single point of failure by using the "single" ...
0
votes
1answer
84 views

Query a name in large database, optimizations? [closed]

if you would like to query a name in a very large database, are there some ways to optimize this query? If 1 million names are in the database, and the name has to stay as it was registered (and not ...
0
votes
2answers
70 views

Amount of memory used by postgres

I am curious as to whether the performance of postgres depends on the amount of RAM available. i.e. will postgres performance(during reads) on several runs get affected by the amount of RAM that is ...
0
votes
3answers
515 views

Handling case-insensitive queries with case-sensitive data

What are some practices for designing a table, or queries, when it comes to case-sensitive data and case-insensitive queries? For example, I have a Products table that holds household goods, and ...
0
votes
2answers
2k views

Access ODBC reserved error 7711

I have user who is trying to access some tables from our Microsoft SQL Server 2008 R2 system (which very recently got moved to a brand new hardware/software stack) using Access 2007 via an ODBC ...
3
votes
0answers
19 views

Why does my procedure run slowly until I update statistics? [duplicate]

I am using a SQL 2008 database (not R2 sadly but have also tested this on an R2 database server) and have an ELT process running. Data is extracted from source and loaded to staging tables in the ...
1
vote
1answer
145 views

addition in datetime column during insertion in mysql

i have a table with below 5 columns..timestamp is data type for timedate related column : Region event_time start_time mid_time end_time India 2013-11-03 13:00:00 America ...
0
votes
1answer
5k views

How to Replace (“ ”) with no space(“”) in one column mysql?

I have table Like This ID | Propinsi | Kota | _________________________ 1 | Aceh | Denpasar 2 | Aceh | Banda Aceh 3 | Sumatera | Asahan This table have many rows The Problem is I want ...
8
votes
5answers
25k views

Error 3154 while restoring a backup using WITH REPLACE

I have SQL 2012 with SP1 installed on my computer. I made a backup of a database test.bak. I have a database with the name test2 which is the same database, but the data changed. I want to restore ...
0
votes
1answer
103 views

SQL Server 2000 Replication, Performance, and Query Priorities

I'm a developer and wanting to confirm the following: Does anyone here have experience with SQL Server Replication (transactional) on 2000? We are trying to convince the DBAs to allow this in a ...
1
vote
2answers
448 views

DB2: Cannot use RUNSTATS/REORG in trigger definitions?

CREATE TRIGGER MY_TRIG AFTER INSERT ON MY_TBL FOR EACH ROW BEGIN IF SOMECONDITION THEN DELETE FROM MY_TBL WHERE PK IN (SELECT PK FROM MY_TBL WHERE SOMEOTHERCONDITION FETCH ...
3
votes
2answers
550 views

Can't get this query to work (left outer join) Postgres

I've got this query I'd like to get working. I'm trying to count all the instances of a foreign key after a certain date that isn't null, and then left join that to the distinct of the original table, ...
1
vote
3answers
77 views

No of rows to be displayed [closed]

I have 100 records. I want to display only 10 rows of that record default or by specifying the number by using procedure
1
vote
1answer
2k views

Calling another function inside a postgres function

I have a function A and function B. Function A Name is f_a() and the code is: Select id,address from A; Function B Name is f_b() code is: Select C.address,B.name From (Select id,name from B, ...
11
votes
2answers
4k views

Does MySQL cache queries?

I'm interfacing a MySQL database with PHP Data Objects (PDO) and executing an extensive SQL query. Normally, it takes about 1500 ms; I still need to optimize it. When I run the PHP script twice ...
0
votes
0answers
35 views

How to install SQL Server 2008 R2 [closed]

My installation is completed, but no instance in not loading (I am on my service account). Show only .in for more browser. Not loading my instance in the database engine. Everything is completely ...
0
votes
2answers
1k views

Join in same table

I have a table employee +--------+----------+------------+ | emp_id | emp_name | manager_id | +--------+----------+------------+ | 1 | abc | 2 | | 2 | pqr | 3 ...
0
votes
1answer
412 views

Need C# Sql Server Project Set Up Guide [closed]

I am creating a window application on c# .net and Sql Server 2008 R2. I will give the setup of this application to my client but I am little bit confuse about SQL Server Database. How the database is ...
2
votes
1answer
118 views

DATETIME2FROMPARTS alternatives for SQL Server 2008

I am trying to part a datetime value and build it together removing minutes, seconds and so on. I want the values to be hourly. Usually this works on a SQL Server 2012 machine: DATETIME2FROMPARTS( ...
0
votes
1answer
61 views

Query Result Not Perfect on Mysql?

I have table Like This ID | City | Prize _______________________ 1 | Surabaya | Notebook 2 | Surabaya | Notebook 3 | Surabaya | 4 | Bandung | NoteBook 5 | Bandung | PC 6 | Bandung ...
3
votes
0answers
85 views

Splitting SQL Server 2008 database [closed]

I manage a 280gb SQL Server database. The structure contains a single database file and many schemas. Each customer has a schema and an associated set of tables. so : MainDatabase : Schema1: ...
0
votes
0answers
236 views

How does tablespace sizing works in Oracle

Let's say I have an input of 20 gigabytes of raw data (text file) which in turn I would into an external table and would then swap partition in order to place them on my database. The question now is ...
0
votes
1answer
2k views

Insert blank row in the postgres query result

I have below table after run a postgres query select * from tbl 1 type_1 name-1 2 type_1 name_2 3 type_2 name_3 4 type_2 name_4 5 type_3 name_5 how can I add a blank line in between each type so I ...
0
votes
1answer
787 views

Error deleting SQL Server local database

I'm doing a project in Visual Studio 2012 and it involves working with the given database. As I add the database.mdf to the project (asp.data folder) I got a connection error, but nothing out of the ...
1
vote
1answer
73 views

Display a List of used Table and Column

Goal: Display detailed information if database A use database B:s table and its column. if yes, the list will display what is the name of the database B:s table and column that is being used in ...
2
votes
4answers
2k views

How To Update Random ID to a table in mysql?

I have table like this: ID | City | Prize | ---------------------------- 1 |Surabaya | HP 2 |Surabaya | Watch 3 |Surabaya | Bag 4 |Semarang | 5 |Semarang |Watch 6 |Semarang | 7 ...
2
votes
1answer
187 views

Getting Information on active Restore in TSQL / SQL Server Management Studio

On my server a database is currently restoring according to the SQL Server Management Studio In the history SELECT * FROM MSDB..RestoreHistory WITH (nolock) WHERE destination_database_name = 'myDB' ...
0
votes
0answers
39 views

Have a lot of customers -> which design in SQL Server 2008R2 should be chosen [closed]

I have a task and I don't know how solve it :) So, we have a lot of customers who should use SQL Server for their applications. Design is standard and simply: Customer -> Remote Desktop -> ...
0
votes
1answer
692 views

Select values from 2 tables with same properties

I am using SQL server 2012, running on windows data-center 2012, under windows azure cloud platform virtual machine. I have the following situation : I have a base settings table lets say as ...
1
vote
4answers
9k views

how to write conditional where clause query

Hi I want write the mysql query conditionally. I am basically using the Wordpress, please have a look at my same tables. tbl1 id name 1 A 2 B 3 C 4 D 5 E tbl2 id post_id key ...
4
votes
1answer
158 views

SQL Server's BACKUP DATABASE - how to access the original exception?

DECLARE @DbName SYSNAME; SET @DbName = 'MyDatabase'; BACKUP DATABASE @DbName TO DISK = 'C:\MyDatabase.bak' WITH INIT, NAME = 'MyDatabase-FullBackup', STATS = 5; This, sure enough, ...
0
votes
1answer
200 views

Complex Oracle SQL to sum data

I am building a SQL query in Oracle 10g that needs to sum overtime hours for the base table, but needs fields from the parent tables as well. I am looking for the fastest way to build the query. The ...
0
votes
1answer
2k views

Why are timestamps not always increasing with concurrent inserts?

I'm seeing some unexpected behavior with timestamp (rowversion) columns . I created a test table: create table Test ( Test_Key int identity(1,1) primary key clustered, Test_Value int, ...
1
vote
1answer
4k views

Select next and previous rows

I have the following table: CREATE TABLE post ( id bigint primary key, thread_id bigint, is_notice boolean, title text, content text ) I display the list ...
0
votes
0answers
49 views

Should triggers be used as an extra precaution to enforce business rules? [closed]

I'm new to SQL Server, and I was wondering: how often do DBA's use triggers to enforce business logic? As long as your security is tight and no user has db_datawriter (or some other all-writing ...
3
votes
3answers
832 views

ts_rank massively slows my query, how can I improve performance?

Here's the table definition Table "public.kb_article_contents" Column | Type | Modifiers ------------+----------+----------- article_id | smallint | not null contents | text | not ...
1
vote
3answers
594 views

Proper use of database functions for business logic

I have a database in postgres with 147 tables; these tables contain data generated by functions that have most of the logic of the system, for example how to build an accounting entry. These ...
0
votes
1answer
34 views

Conditional when creating a domain

How can I define or change a domain based on another attribute value? F.e. domain for salary is a numeric value > 500. But if a date the person was hired > January 1st, 2013, then the salary must be ...
1
vote
1answer
266 views

Okcupid.com (can find matches without accessing a database!?) [closed]

I'm doing a research project on a popular dating site called: OkCupid I would like to talk about how the database is used. After reading this explanation from the Co-Founder of the site, I became very ...
-1
votes
0answers
9k views

Errors trying to install SQL Server 2012 on Windows 7 [closed]

I am getting the above error message when i try to run the setup file. Microsoft SQL Server 2012 Service Pack 1 Setup The operating system on this computer does not meet the minimum ...
0
votes
1answer
3k views

SQL Query with multiple conditions on date

I want to write a query with condition on dates for below table and sometimes it requires great thinking. StartDtm StopDtm 2013-11-03 00:00:00.000 NULL ...
2
votes
1answer
381 views

SQL Server Replication - setting up scheduler issue

We have tasked to set up a scheduler to synchronize data between a publisher and subscriber on daily basis. The subscription was set using windows sync manager and it runs just fine when run manually. ...
0
votes
1answer
64 views

SSMS gives error if column name is “MERGE” where as other keywords works

IN SSMS create table if we include sql keywords in column name then it will be wrapped around square brackets "[]" automatically and the table gets created without any error generally. But if we ...
0
votes
1answer
839 views

What is blocking 'SELECT… WITH(NOLOCK)'?

While following BrentOzar's "How Much is Offline During an Index Rebuild?" I was curious to run: SELECT Quantity FROM [Production].[TransactionHistory] WITH(NOLOCK) while executing a rebuild ...
0
votes
1answer
38 views

Oracle sql plan for a select with procedure in terms section

Is there any difference in optimizing a plan to execute any sql request in case of using a procedure from a package which checks to display row or not and in case of constructing a plain sql query ...
0
votes
1answer
142 views

Merge two tables on partly matching column

I have below 2 tables. old_name old_value Tom1 100 Kate1 80 Jim1 70 new_name new_value Tom2 70 Kate2 100 Jim2 80 I want to make a new table look like ...
2
votes
1answer
79 views

What is the appropriate SQL method for “Safe to SUM”?

In SQL Server 2008 R2+ we, unfortunately, have some nvarchar columns storing numeric data. In some cases we want to SUM the data when it can be summed. The problem is that ISNUMERIC() returns 1 for a ...