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)

1
vote
2answers
1k views

Factoring out subselect (with clause) ends in ORA-00904

I am trying fo factor a repetitive subquery with with but getting ORA-00904 over and over again. This is my base query which works quite well: select tka.id, tka.name, txt.text as langname, ...
0
votes
0answers
3k views

0x84BB0001 Error when installing SQL Server 2012. Could not create a handshake [closed]

I have hopelessly attempted to install SQL server 2012 onto my 64 bit Windows 8 machine. The database engine always fails to install with error 0x84BB0001. Native reporting also fails, I reckon from ...
3
votes
2answers
6k views

query_cache_type = 0 vs query_cache_type = 1

Recently, I moved from standard MySQL to Percona, and used the Percona Wizard to generate my.cnf. However, I can see that, by default, the generated settings for my.cnf use query_cache_type = 0. ...
2
votes
1answer
355 views

Setting up simple question & answer database

I am having trouble thinking this (simple) table relation through. I am setting up a quick SQL DB to populate labels and textboxes dynamically on screens. This is just to prove we can do it, so it ...
4
votes
2answers
515 views

Insert with 0 Writes?

I've been looking at some SQL Profiler traces recently, and I see something I don't understand. I'm running simple INSERT commands: INSERT INTO Foo (ForeignID, FileExtension, MimeType) VALUES (1, ...
0
votes
2answers
1k views

Indexing a longtext field

I would like to run an index on a longtext field using: CREATE INDEX post_meta ON wp_postmeta (meta_value(8)); There are currently ~1 million records. Questions: Will creating this index affect ...
1
vote
1answer
847 views

MySqli - select from db based on time difference with CURTIME() or SUBTIME()

I have a db with some customers data. There I store their last login time as datetime. I want to run a cron php script every min which will query mysqli for their last login datetime and if that was ...
0
votes
1answer
207 views

MySQL: select a row if that row is equal for every user

In my database I have 5 fix users, lets say user1, ..., user5. Furthermore I have a table month(name, finished, month, year) where name is VARCHAR (the name of one of the five users) and the ...
1
vote
3answers
264 views

How can I best combine 3 queries into 1?

I need the following queries combined into one query that returns the following from all results from the first query you see below (Right now I load the first query into an array in php then run two ...
5
votes
2answers
116 views

Algorithmic order of table indexes for table operations

I have not been able to find a clear indication of the impact table indexes have on the algorithmic order of table operations. I am not interested in the nuts & bolts of specific implementations; ...
0
votes
0answers
26 views

SQL services wont start due to incorrect drive letter [duplicate]

Possible Duplicate: SQL services wont start due to incorrect drive letter after windows restore SQL services wont start due to incorrect drive letter after windows restore Had a server ...
1
vote
1answer
425 views

How to delete and create user remotely on SQL Server 2000

My boss wants to make sure that no one runs a job accidentally so we are setting up lots of safeguards to ensure that no one sleepwalks, log into the system and run a job. We are updating the ...
1
vote
3answers
3k views

SQL services wont start due to incorrect drive letter after windows restore

SQL services wont start due to incorrect drive letter after windows restore Had a server crash, was successfully able to reinstall windows and restore the server SQL and all the necessary services ...
1
vote
1answer
322 views

Storing Different Products and Joining on table Names

I am setting up a database using mysql to store different products with different product types. For example I could have Books, Software and clothes etc. What I am think of is creating a parent ...
0
votes
1answer
5k views

Save output from multiple SQL SELECT commands to a file

Within a Postgres function I would like to run a number of SQL SELECT commands and append the output to the same variable. After all the SELECT commands have run this output should be written to a ...
0
votes
1answer
85 views

Is there any way to get recently inserted value in a table without using aggregate functions?

I tried to get the users list who are all accessed our application in past 6 months . In our table , we are storing login_time , user_id ..etc . It's a huge table approximately it will contain over 3 ...
4
votes
2answers
834 views

Backup Only Database Schema Everynight

I have an instance with 15 databases on SQL Server 2012. I will set up to backup system which will work every night. I want to backup only the schema because several databases are very big. I haven't ...
2
votes
3answers
2k views

SQL Subquery , One to Multiple rows

Following query I have written returns the result as expected, example 121350 rows. SELECT dbo.Articles_in_Consignment.Consignment_id, dbo.ORDER_D.Orders_boxsize, ...
0
votes
2answers
2k views

How to select row and column name where field is null?

I wanted to show row and column where field is null. i already see this example here but i don't understand xml code. my code is like this if exists (select * from Header where [name] is Null ...
1
vote
1answer
276 views

Delete word, its meanings, its meaning's example sentences from DB

I have three tables as below (simplified for demonstration): words ===== integer id text word meanings ======== integer id integer word_id text meaning examples ======== integer id integer ...
1
vote
2answers
1k views

ERROR: could not find array type for datatype information_schema.sql_identifier

I am trying to run the below sql command: SELECT ARRAY( SELECT column_name FROM information_schema.columns WHERE table_name ='gis_field_configuration_stage' ); and I get the below ...
1
vote
1answer
170 views

cloud computer to speed up sql big data queries?

i have been doing a lot of data mining at my new job. we collect TONS of data, and it's my job to visualize that sea of information in real time with statistic/heuristic analysis. we're currently ...
2
votes
1answer
144 views

Finding similar values in columns

For example I have a column id and column email. I would like to find all values from id and column that share similar pattern. let's say: in id 'column' I have Alexander and in 'email' column - ...
0
votes
1answer
379 views

MAX function and group by usage - postgresql

I am building a ranking algorithm using IMDB's formula: http://stackoverflow.com/questions/1411199/what-is-a-better-way-to-sort-by-a-5-star-rating/1411268#1411268 The formula for calculating the Top ...
4
votes
2answers
219 views

Performance on SQL Join

I have a query which takes ages to run mainly due to a join between 2 tables on a PK and FK. The Key is prefixed with 2 letters (which is always the same, RN) followed by 7 digits So RN1234567 for ...
1
vote
1answer
4k views

Retrieving data from inner join using LIMIT and OFFSET

These are my two tables: table1 qid[PK] |gid[PK] |abcd | xyz | date ---------------+---------+---------+------+------------ 00001 | qwe | 54 | a | 1994-11-29 00002 ...
5
votes
1answer
948 views

sql_slovak_cp1250_ci_as vs Slovak_CI_AS

Can someone explain to me what is the difference between collation sql_slovak_cp1250_ci_as vs Slovak_CI_AS? I have a db set to sql_slovak_cp1250_ci_as and shared hosting supports only Slovak_CI_AS. ...
1
vote
1answer
161 views

Setting up simple relational database structure

I'd like to set up simple MySQL database but I'm a bit confused about everything, so let me try to explain... I have 4 relevant tables, let's call them POS, POS_STRUCT, POS_STRUCT_DIV and MEMBERS. ...
2
votes
1answer
316 views

sorting groups of related rows by average values while keeping the groups together

I'm using PostgreSQL 8.4, but would like a standard SQL solution if possible. Consider the following table. corrmodel=# SELECT * from data limit 1; id | datasubgroup_id | datafile_id | ...
4
votes
2answers
2k views

SQL Server 2012 database backup successfully report but no backup file

I have created maintenance plan in SQL Server 2012. And every day, the maintenance plan should backup the database. There is no database backup file when I look in the folder where the backups must ...
-4
votes
2answers
18k views

Display month in columns and the sum of sales below the columns in sql [closed]

My table is like this: Sitecode Month Amount -------- ----- ------ XX Jan 1000 XX Jan 3000 XX Apr 3000 XX Apr 1000 What I want is, to ...
3
votes
1answer
1k views

Error while restoring database in SQL Server 2008 R2

This error occurs while I restore database from .bak file A system assertion check has failed. Check the SQL Server error log for details. Typically, an assertion failure is caused by a software ...
0
votes
1answer
167 views

How to create an index view?

I have a view which is doing summation of several columns: Select cola, colb, cola + colb + colc from table tbl_a Can I know what are the indexes I should create for the view to improve its ...
1
vote
3answers
178 views

Efficient SQL database design for recording examples of a word

I am designing a dictionary-like program which stores (and displays) a few example sentences of the given word. One way to design a SQL database for such problem is to create a table with two columns ...
0
votes
2answers
636 views

Remote Desktop Session's Machine ID for SQL Server Query

How to get machine name of a user, who is connected on an instance through Remote Desktop and used windows authentication login. I need it for each query she has executed. sys.dm_exec_connections just ...
1
vote
1answer
4k views

Possible Causes of a Slow Sql View When Filtered

I have a view in Sql Server 2008 that when performing just a: SELECT * FROM [Table] Will return roughly 40000 rows by 130 columns. Here are 6 runs with client statistics on (roughly 7 seconds ...
2
votes
1answer
652 views

Parsing and binding variables for SELECT .. WHERE column IN ( .. ) queries

I'm looking to make sure that all queries in a php web application have proper use of bind variables to minimize parsing of the queries. I'm wondering how Oracle parses queries that compares a ...
1
vote
1answer
850 views

Sql Server rollback to some point in time

This seems like a fairly common scenario, yet I'm not sure how to do this. I have a very large database (think a lot of terabytes), which makes it impossible to create a full backup. At some point, I ...
1
vote
3answers
4k views

How do I use SSMS to compare Database 1 Table 1 against Database 2 Table 1?

I have two database - Database1 and Database2. Both database contain a table that have similar structure as follows: ...
5
votes
2answers
912 views

T-SQL Purpose of MAX in this Group By Query

I have run into some pre-existing SQL that I'm having a hard time uderstanding. SELECT MAX(I.Symbol) Symbol , MAX(I.Ticker) CUSIP , MAX(I.Name) Name , SUM(H.Quantity) TotalQuantity , ...
1
vote
1answer
330 views

Group activities in activity feed by users and products

On my website I'm building an activity feed where I got the basics done and are now making some improvements here and there. One of them is the grouping. I've built it so that if multiple users buys ...
0
votes
2answers
576 views

How can I simplify this query?

I have written the following SQLite query: SELECT sum(amount) / (julianday('now', '+1 day') - julianday('2012-08-11')) * 14 AS 'Cost Per Fortnight' FROM ( SELECT "transaction".transamount AS ...
1
vote
1answer
7k views

How to check for null in column? and use other column instead?

How would I write a query that involves the following check: if colA is null then colB = colB1 + colB2 if colA is not null then colB = colA
4
votes
2answers
934 views

Right Trimming Binary Data in SQL Server

Scenario: I am inserting a string into a binary field (CONTEXT_INFO) and then later attempting to pull it out and convert it back to a string. When I do, the resulting string has a length of 128 ...
1
vote
2answers
525 views

Database Design - One table from many source(One to One)

I have a 'Text' table, the text table may came from different source, like Tweet, SMS, Email, etc. and each source have their own log, and Text is came from the source. so i came with some solution, ...
1
vote
2answers
5k views

Multiple triggers vs a single trigger [closed]

Scenario: Each time data is inserted/updated/deleted into/in/from a table, multiple unrelated items of business logic need to be executed. Question Given that the solution is to use database ...
5
votes
1answer
4k views

What is the difference between NORECOVERY and RECOVERY when restoring database?

Can anyone explain the main differences? Any help appreciated.
1
vote
1answer
214 views

is it reasonable to use NoSQL for my project

Imagine you want to write a webapp for selling your car online. A car has a lot of attributes. Like how many doors, color, aircondition, etc. Some of them are simple boolean values, others might need ...
2
votes
2answers
511 views

Advantages of Database Snapshot

Can someone please highlight the advantages of Database Snapshot in SQL2008. I read some where that "When a Database Snapshot is created, SQL Server doesn’t allocate space on disk equivalent to the ...
1
vote
1answer
101 views

T-SQL Case functionality

Is it possible to structure a CASE statement as follows? For each Path column I want to update the Value column, but the values aren't being set and I'm not sure how to proceed. The columns are all ...