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)

4
votes
2answers
1k views

What is the best way to migrate multiple databases?

I want to migrate my database server to a new server. Right now I have a database server with Windows Server 2008 and now I am migrating to a new, separate server with Windows Server 2012. There are ...
1
vote
1answer
3k views

In creating view use SQL Security definer or invoker?

CREATE VIEW syntax is CREATE [OR REPLACE] [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}] [DEFINER = { user | CURRENT_USER }] [SQL SECURITY { DEFINER | INVOKER }] VIEW view_name ...
-1
votes
0answers
57 views

Optimize SQL Select Command [closed]

Is there anyway to speed this up by optimizing/condensing the code? SELECT fullName, email_address, pos_desc, EXT FROM dbo.BTC_WEB_EMPLOYEE_VIEW WHERE grp_cde = 'STAFF' OR grp_cde = 'PROF' OR ...
3
votes
1answer
804 views

Index on foreign key makes query extremely slow

We are recently experiencing a tremendous query slowdown with spilled over temp tablespace. A specific query causes this problem. The queried table (table3) has an indexed PK, three FK with indexes ...
3
votes
3answers
2k views

MYSQL wont use index in “IN(SELECT ..)” sub clause

I have two tables in MYSQL with target fields set as index / primary index already. Then I ran the below sql query. EXPLAIN SELECT charge FROM ec_provider_account_option WHERE ...
1
vote
2answers
108 views

interpreting how much data has been lost by analyzing dbcc output

We had a SAN outage and this corrupted several databases with no backups. We ran this to do a repair: EXEC sp_resetstatus 'test' ALTER DATABASE test SET EMERGENCY DBCC CheckDB ('test') ALTER ...
2
votes
1answer
634 views

Create a sub query for sum data as a new column in SQL Server

Suppose that I have a table named tblTemp which has this data: | ID | AMOUNT | ---------------- | 1 | 10 | | 1-1 | 20 | | 1-2 | 30 | | 1-3 | 40 | | 2 | 50 | | 3 | 60 | ...
0
votes
4answers
192 views

SQL Server transaction log growing without control

We have a database growing uncontrolled and filling the hard drive every 2 days. Database maximum log size is set to 6 gb but id doesn't seem to be working because it continues growing beyond 6 gb. ...
1
vote
0answers
45 views

What is a good way to Merge 2 range sets into a single view

The real purpose of this has to do with effectivity dates and contains additional keys and fields, but I simplified it for the sake of, well, simplicity. Sample: test_Widget Table theFirst ...
0
votes
1answer
125 views

Embedded select with rank

I am having the hardest time following the tutorials on this site regarding ranking with MySQL. I have a larger problem than others seem to show. My table is constantly updating with single answers ...
0
votes
1answer
930 views

HOW to “SUM” and “JOIN” for single query of a poll results?

I have a poll database as CREATE TABLE poll_answer answer_id, answer varchar(255), poll_id int(11), FOREIGN KEY(poll_id) REFERENCES polls(poll_id) ON DELETE CASCADE, PRIMARY KEY(answer_id) ) ...
2
votes
1answer
138 views

What are the risks for logging across databases via a trigger?

I've searched for this online and had mixed or unclear responses, and after posting on superuser, was directed over here. On SQL Server 2005, we currently log certain table changes via triggers using ...
7
votes
1answer
3k views

Algorithm for finding the longest prefix

I have two tables. First one is a table with prefixes code name price 343 ek1 10 3435 nt 4 3432 ek2 2 Second is call records with phone numbers number time 834353212 10 ...
0
votes
1answer
2k views

Different dates Oracle 11g with TOAD

I have the following queries: SELECT to_date(to_char(to_date('01-FEB-1949'))) FROM DUAL; /*this returns 2/1/2049. */ SELECT to_date(to_char(to_date('01-FEB-1949'),'dd-MON-yyyy')) FROM DUAL; ...
-15
votes
1answer
1k views

Please help with these database interview questions [closed]

What is your company backup policy? If something happend to your db how to restore it? What type of clustering present used in your enviroment? Whis is the best replication? Why? If sql server want ...
2
votes
3answers
83 views

How to take SQL Server database under this scenario?

I have a database of size 290 GB running on SQL Server 2005 (compression is not available) and disk space is z: drive 250 GB and Y: drive is 80 GB. How can I take a full backup in this scenario? How ...
3
votes
3answers
2k views

query processor ran out of internal resources and could not produce a query plan

This is showing up in the logs several times a night. How do I find the query causing the issue? SQL Server 2008 R2 Sp1. Thank you
0
votes
1answer
3k views

pgAdmin3 can't connect properly to Postgres 9.2

I have installed pgadmin3 version 1.10.2, however when it connects to PostgreSQL server version 9.2, it says: Warning: This version of pgAdmin has only been tested with PostgreSQL version ...
0
votes
1answer
1k views

Restoring database backup file gives access error

I am running SQL server 2008 and trying to restore from a backup file. Note: the backup file and folder and read/write access to "everyone". Running the command as "master" Running RESTORE ...
4
votes
1answer
40 views

Verify Query Request Received

I have a software system which queries data via OLEDB from an external SQL Server 2005. The query request is sent every 15 minutes. I want to verify that the SQL Server is receiving the query ...
0
votes
1answer
1k views

Changing the SGA and/or PGA in Oracle 11g affects the performance of the queries?

I am making a practice for school where one of the questions is if changing the SGA/PGA size would affect the queries performance and in what sense. I have been looking around for how to do that and ...
1
vote
1answer
1k views

Upgrade SQL Server 2005 Enterprise to SQL Server 2008 R2 Standard

I understand that this is not a supported path, but does anyone have any insight about how to accomplish this? I can't seem to find any documents on the subject. I need my QA (2005) to match my ...
0
votes
0answers
1k views

Using something better than UNION for combining multiple queries

I have one big query which is based on 12 smaller queries that I have put together using UNION. A relative simple example of my query: (SELECT 'type1' AS 'type', fieldOne AS someField, ...
5
votes
1answer
521 views

Execute output from query

I've got this query that builds my drop login statements. As part two I want to execute this output. Ideally I want to do this in a sql job with two steps (generate and execute). Can this be done? ...
0
votes
1answer
49 views

Bit column vs multiple join tables

I asked a question earlier about how I could define a many to many relationship between users and FOSes (fields of study). My original question was how could we know whether the user was the ...
-2
votes
3answers
172 views

Load Balancing in SQL

We are implementing new database applications with large users and the developer thinks we need to look into doing some kind of load balanced SQL database.our server is slow due to vast amount of ...
6
votes
2answers
2k views

Turning OFF CHECK_POLICY by default

We moved from SQL Server 2000 to SQL Server 2005. The client software, which I can not change, creates a user without option CHECK_POLICY = OFF; After creating a user, I have to run the command ...
1
vote
1answer
609 views

how to transfer data from table to table

I have two tables Table1, Table2. From Table1 want to transfer data to Table2. Suppose I have the following query: Select * from Table1 where UserID between 5 and 10 I want to store above ...
-2
votes
1answer
99 views

Handle vast amount of data in DB [closed]

Now my current database is working in SQL Server 2008 R2 and we are uploaded its only in 1 server. How can I migrate my existing database in to Hyper Table ? (My current database has huge amounts of ...
-1
votes
1answer
71 views

validate where each parent intermediary is also a parent to itself [duplicate]

I want to validate where each parent intermediary is also a parent to itself. So this query should return invalid parents in SELECT If table has any. I need to do is first of all get all parents ...
2
votes
1answer
106 views

How to select nodes where all children is satisfied?

I have a tree structure of light bulbs. I want to turn on all the light bulbs starting from the leafs of the tree. A light bulb cannot be turned on unless all its immediate children are turned on. ...
4
votes
4answers
2k views

Examples of SQL transaction procedures for sales tracking or a financial database

I am making a database for an accounting/sales type system similar to a car sales database and would like to make some transactions for the following real world actions: salesman creates new product ...
4
votes
2answers
631 views

how to get unique records

Table structure CREATE TABLE [dbo].[Order Details2]( [OrderID] [int] NOT NULL, [ProductID] [int] NOT NULL, [UnitPrice] [money] NOT NULL DEFAULT (0), [Quantity] [smallint] NOT NULL ...
0
votes
1answer
478 views

How to load more than one MS-Access-db tables with data in SQL-Server-DB

I'm just getting into SQL-server 2008 R2 ssis, so forgive me if this is a basic question. I'm building an application using integration service. One of my computer folders contains more than one ...
7
votes
4answers
6k views

Select statement takes long remotely due to long “client processing time”, but short locally

While connected to our production server (SQL2008. very powerful machine), this select statement takes 2 seconds, spitting back all fields (4 MB of data in total). select top 30000 * from person ...
5
votes
3answers
180 views

Check server activity with code

I would like to see the activity on of the SQL server. So I can run a query when the server load is low. I know there is an activity monitor in SQL server but my company doesn't want me to give the ...
0
votes
2answers
146 views

How do you store tabular data in an RDBMS?

First: I really haven't got any idea how to google for this. If you got one, leave a comment. If I want to store arbitrarily large tables in a database, how should I set up my database tables? ...
1
vote
1answer
2k views

Mysql query grouping by two columns for max date takes too long

I have table that looks like this: l_p l_a l_timestamp l_n l_act l_name 123 321 2011-1-1T01:00:00Z B q das 21 23 2012-1-1T01:00:00Z C q sd 123 ...
1
vote
1answer
7k views

Connect Error (2054) - mysql_old_password issue still not solved

i use php 5.4.3 and i want to connect to a MySQL DB remotely (php script resides on a different server than the db) with normal oop way: $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); ...
0
votes
1answer
281 views

Multiple junction tables?

I am working on a system where you have users, and you have Fields of Study or 'fos' for short. Each user can have many fos and each fos can have many users. So we are dealing with a many to many ...
1
vote
0answers
57 views

Which database could handle storage of billions/trillions of records in sql? [duplicate]

We are looking at developing a tool to capture and analyze netflow data, of which we gather tremendous amounts of. Each day we capture about ~1.4 billion flow records which would look like this in ...
9
votes
3answers
8k views

Are individual queries faster than joins?

Conceptual question: Are individual queries faster than joins, or: Should I try to squeeze every info I want on the client side into one SELECT statement or just use as many as seems convenient? ...
1
vote
2answers
612 views

Join on different types

In a database I have two tables: The first has a field named taxonomy_id that is an integer The latter has a field named ID that is a character varying The two tables are related: if it exists a ...
2
votes
2answers
131 views

Query to find Maximum friends not giving correct resuts [closed]

Table Schema for the Likes table: id id1 1 2 1 3 2 1 I count the total number of Likes for each student with this: select id,count(*) from friends group by id I have to find the students with ...
2
votes
2answers
2k views

Postgres 9.2 select multiple specific rows in one query

I have a table with three columns, Id Serial. Value real. timein Timestamp. I want to select the values based on a range of days ie. from two days ago until now. The table may contain one or two ...
1
vote
1answer
2k views

Remove specific duplicates (all but latest)

When removing duplicate rows, using the below query from this tutorial, how would I go about forcing which of the found duplicates to remove? DELETE FROM dbo.ATTENDANCE WHERE AUTOID NOT IN ...
0
votes
1answer
525 views

MySQL stored routine performance while using PREPARE

Instead of maintaining stored routines for each database in my current environment I have decided to create separate database just for stored routines storage. Mainly I am using them for reporting. ...
11
votes
3answers
2k views

Updating a table with millions of records, its been 4 days

I am currently updating a table with millions of records, its been 4 days and query is still executing. I checked the activity monitor its shows that query is running. In event log there is no ...
1
vote
2answers
784 views

Remove scientific notation from an XML column

I have a XML column as shown below: <Root> <Row> <Rowid>1</Rowid> <date>2013-05-06</date> <Balance>1.0002E7</Balance> </Row> ...
2
votes
4answers
162 views

When should I use the shrink option

I have seen a lot of blogs stating that shrinking is not a good habit as it will reduce the performance of the system. I agree with all those things it will lead to side effects like fragmentation, ...