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)

1
vote
1answer
92 views

Group by alternative [closed]

I have a table , that has a generic set of actions for EVERY user. However if there is a user that needs to have a unique action, that replaces an existing action, then in my query, I want to ...
1
vote
0answers
20 views

Can I include extra columns in a m->m mapping table? [duplicate]

I guess this is sort of an odd question, but consider this scenario. table classes (id_pk) table students (id_pk) table students_classes_map (students_id_fk_pk, classes_id_fk_pk, finalExamScore ...
1
vote
0answers
27 views

How to cope with SQL Server 2012 vs SQL (Azure) Database sql files

I'm trying to port my system to SQL Database (Azure instance) from SQL Server 2012. I'm using Visual Studio 2013 and I have my .sqlproj with all the definition of my database inside. Given that a ...
1
vote
0answers
170 views

sql query takes too long to execute [closed]

I am having trouble with this query. It takes 10 hours to execute. WITH CONSUM AS ( SELECT C.ID_MEASURER,C.ID_MEASURING_POINT,C.CONSUM_TYPE FROM GCGT_RE_CONSUM_H_E C WHERE C.DAY ...
1
vote
0answers
39 views

One table for article comments, video comments and photo comments or multiple tables?

First DBA question. Greetings people. I hope I'm not duplicating a question but it's very hard finding database design related questions here (for multiple comment tables), as all 'design' questions ...
1
vote
1answer
50 views

Detect data spikes (loops) in MySQL database and ignore these

i must create some statistics out of a WWW access log database, but i found out that there are some redirect loops after a login if the user has disabled cookies. So there are 10-1000 mostly identical ...
1
vote
1answer
129 views

Combining count queries into one table row

I'm banging my head against the wall because I'm sure this is super easy. I have a few queries set up that get counts for a few related tables. This is for an arcade game tracking system. The ...
1
vote
0answers
46 views

Merge/combine two queries with different dates

I have one query that runs a SUM statement based on daterange 1, and worked fine, and another query that run same SUM statement, but on a different date range. I would like to merge/combine the two ...
1
vote
0answers
118 views

MySQL fulltext selection performance

I have 1.5M rows in a table. Following is the table create code: CREATE TABLE `jobs` ( `id` INT(8) NOT NULL AUTO_INCREMENT, `job_id` VARCHAR(50) NOT NULL DEFAULT '', `title` VARCHAR(255) ...
1
vote
0answers
78 views

Errors in the metadata manager. The process type specified for the Effect dimension is not valid since it is not processed

Trying to hunt down an issue with an SSIS package we have and I don't know what to look for to help correct this issue. Error: Errors in the metadata manager. The process type specified for the ...
1
vote
1answer
17 views

Select the last logged change before a specified time from a change list

I want to get the last change for all issues issue, that was made before a specified end time. I have 3 tables. projects +---+------------+ |ID |project_key | +---+------------+ |1 |bug_tracker | ...
1
vote
1answer
141 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 ...
1
vote
0answers
52 views

Database Structure Definiton

This is a question more so on the table definition vs actual programming. I have 6 sets of potentially 255 unique fields. I have a potential of getting 40 million records per year of these. For the ...
1
vote
1answer
81 views

How to do the complex nested select SQL?

I have two tables, table1 is as following, id is primary key, table2_id is foreign key id date aid table2_id message 1 2014-03-19 16:21:02 121 1 login from xxxx 2 ...
1
vote
1answer
56 views

How to make MySQL join one-to-many with lowest value?

I have following database structure Domain has many URL which has many positions which belongs to phrase which belongs to user which belongs to subscription. In subscriptions table I have period ...
1
vote
1answer
85 views

Print the execution time on messages Pane?

How I can print the execution time of each query on messages Pane? For example the Select * from tbl1 runs for 10 mins then Select * from tbl2 runs for 15mins and so on.. Select * from tbl1 Go Select ...
1
vote
1answer
50 views

How to update a single record in a table based of foriegn key ID in another table?

I am still very new to sql. I am having troubles updating one table. I am sending information from a web application into Microsoft SQL 2008 database. I have a table called EmployeePermissions that ...
1
vote
0answers
82 views

Database Archival Process [closed]

I am designing a database archiving process - which is a automated process. Do you have any advice for how to accomplish these goals? Below are my thoughts : create another clone database ...
1
vote
2answers
83 views

Finding the highest quarter of the year

I'm sitting here and do some practise but I just can't find the Solution. Maybe someone could give me some help? I have a table and should find the highest sale amount of a quarter per year. Data ...
1
vote
2answers
55 views

Time elapsed Calculation

I need to calculated time elapsed for each user to perform his part in a transaction. The sequence is: 0 -1 - B2 or 0-B3 The table looks like the following: ...
1
vote
0answers
36 views

Modulus calculation for compound primary keys in MySQL Cluster (and other sharded databases)

In MySQL Cluster, and generally in sharded databases, how is a compound primary key's modulus calculated? Say, for example, there are two tables that have primary keys like so: CREATE TABLE Orders ...
1
vote
0answers
78 views

Database Mail not sending

I'm trying to send email using the DatabaseMail on SQL Server 2008, I can see my emails sitting in the msdb.dbo.sysmail_unsentitems But they just sit there, I get no error messages. I've checked ...
1
vote
0answers
78 views

Stored procedure taking much longer than query [closed]

I have a simple code segment that runs in about 1 second when run alone, but more than 5 minutes when deployed as a stored procedure. I'm using sql server 2008. Unfortunately, I can't post the code ...
1
vote
2answers
78 views

How to get the first or last row in ordered result set, depending by column value?

I have the follwoing result set from the table PUNCHREPORT EMPLID Name PUNCHDATE PUNCHTIME DEVICETYPE .................................................................. 70 ...
1
vote
0answers
70 views

Join and aggregate result and insert blanks for missing appendants

Consider these two simplified tables: CREATE TABLE "sources" ( "id" serial NOT NULL, "name" text NOT NULL, CONSTRAINT "sources_pkey" PRIMARY KEY ("id") ); CREATE TABLE "values" ( ...
1
vote
0answers
49 views

Testing equivalence in strings with different character sets

I have to synchronize a number of tables with string columns between two databases: the source Oracle 10.2.0.3 NLS_CHARACTERSET WE8MSWIN1252, NLS_LENGTH_SEMANTICS BYTE the destination Oracle ...
1
vote
1answer
105 views

Simple query not returning blank records

Very simple example here to a very frustrating treasure hunt for the mystery character. I have a table with a varchar(1) NOT NULL column - everything default - ANSI_PADDING & NULLS are ON for the ...
1
vote
1answer
288 views

SQL hourly data aggregation in postgresql

I am a newbie with database so I'm seeking your help with this one. I have a table containing time series data. 2012/01/01 00:10, 10 2012/01/01 00:30, 5 2012/01/01 01:00, 10 2012/01/01 01:40, 10 ...
1
vote
1answer
74 views

Log shipping - failed over to secondary, how to fail back

SQL 2012 I've been researching and testing Log Shipping as a DR solution. I got the two servers setup. Log shipping is in place and verified to be working correctly. I failed over by restoring the ...
1
vote
1answer
34 views

Limit balancing results by a column

I have a web crawler that have a table with tokens to crawl and each token have a fk_location column that is the website where that token must be processed. I also have a function that returns me the ...
1
vote
2answers
88 views

Limiting read access in postgres to few rows

We have a requirement where we want to limit the maximum no. of rows that a select query can return when its done using a particular login. So basically we would like to append a limit clause to any ...
1
vote
1answer
185 views

Database Mirroring and Replication in SQL Server 2008 R2

I have configured the mirroring and replication between 4 servers (A,B,C,D).i.e, Mirroring between A to B and C to D, Replication between A and C. The configuration was a success and I am able test ...
1
vote
1answer
183 views

SQL Server Cross Domain Transcational Replication

Has anyone got any documentation for doing/implementing Cross Domain SQL Server 2012/2008R2/2008 transactional replication document or steps (with screenshot or without screenshot) Thanks for your ...
1
vote
0answers
60 views

Failover cluster connection issue

I'm trying to run SQL Server Failover cluster in Azure. I have NODE1 and NODE2 in a cluster and another SERVER in the same network trying to connect to the database server using the instance from ...
1
vote
2answers
386 views

Building A SQL table horizontally VS vertically

What is a better design principle when designing SQL Server tables. One can either add columns (ie grow horizontally) or grow it vertically (ie rather adding rows) I have a situation when there are ...
1
vote
0answers
59 views

appending 2 tables based on common columns in Postgresql 9.3

I have 2 large tables that I need to combine into a single table--for statistical analysis. The two tables have some variations in column named, otherwise I would just use an INSERT statement. So I ...
1
vote
1answer
2k views

QUERY - pivot multiple columns, variable number of rows

I have a table that looks like this: RECIPE VERSION_ID INGREDIENT PERCENTAGE 4000 100 Ing_1 23,0 4000 100 Ing_100 0,1 4000 200 ...
1
vote
0answers
48 views

Transactions using Isolation Level on databases with FileStream

We have a highly transactional application. We have a requirment to upload huge data into our database that can happen for a duration of 5-10 minutes. During our upload time, the tables are getting ...
1
vote
0answers
27 views

What to do when the error message is longer than 4000 in T-SQL?

I have a OPENQUERY linking to an Oracle server that is failing. (I can't make any changes on the oracle server) But when it returns the error string it is cut short because it returns the query in ...
1
vote
0answers
32 views

SQL Server 2012 Page Life Expectancy resets to 0 after about 50 days [duplicate]

I've noticed an odd behavior on a 2-server HA cluster and I was hoping someone could confirm my suspicion, or maybe offer some other explanation... Here is my setup: A 2-server SQL 2012 SP1 ...
1
vote
0answers
44 views

Getting upcoming world wide releases from a database

From my database I want to get upcoming world wide release dates for an itemId along with the platformIds. If I have a table that looks like this and the current date is 2014-05-14 ...
1
vote
1answer
203 views

After Restore Log_reuse_wait_desc of Replication

I'm wondering if anybody has ran into this issue before and has any suggestions on what's causing it/how to fix it. We are restoring a database into lower Dev environments and after the restore the ...
1
vote
1answer
765 views

Impact on SSRS of migration of SQL Server from 2008 to 2012

As part of my project, we are upgrading SQL Server 2008 R2 to SQL Server 2012. We have a separate SSRS 2008 instance running on a separate machine which interact with these existing 2008 database ...
1
vote
1answer
47 views

Order of output row in random order [duplicate]

When I do select query on single table then I get output rows ordered by primary key which is perfect, following query: select * from recondata where importid=131; but when I'm joining this table ...
1
vote
1answer
535 views

Use limit with where clause in in mysql [closed]

I know where clause search and display the records as per criteria comes true, and limit is use to fetch the number of records from a table. But please help me when I am trying to use them both ...
1
vote
0answers
146 views

Storing changes to stored procedure and triggers in PostgreSQL

I want a mechanism where I can store/track changes in stored procedure and triggers. I want to track these logs in some table. What is the best possible way ?
1
vote
0answers
14 views

How to enable Parallel Data WareHouse? [duplicate]

How do I enable Parallel Data Warehouse on my Microsoft SQL Server. I am trying to run this SQL statement below and received this error. ERROR: Msg 11305, Level 15, State 10, Line 2 The Parallel ...
1
vote
0answers
19 views

How can I select rows from a hierarchical query with the lowest level? [duplicate]

Apologies for the cross-post from StackExchange DBA - I wasn't sure which site was best for this question. I have a hierarchical query in Oracle 11gR2 that returns something like this: Parent ...
1
vote
0answers
228 views

Best practice - SQL Schema to store Timerecords for a Time and Attendance module

I'm starting a time and attendance module in C# and SQL. There will be many time rules depending on every shift. For example: Shift 7:00 - 14:00 for Administratives: 15 min grace time, but if ...
1
vote
2answers
2k views

Possibly tempdb out of space or a system table is inconsistent

While running DBCC CHECKDB I got this error Msg 8921, Level 16, State 1, Line 1 Check terminated. A failure was detected while collecting facts. Possibly tempdb out of space or a system ...