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)

6
votes
3answers
229 views

Find material for improvement in Microsoft BI

Which websites, books etc. can you recommend me to improve my basic knowledge in Microsoft Business Intelligence 2008, SSAS, SSIS and SSRS? Please remember that I'm a newbie in technical BI tool. If ...
6
votes
2answers
5k views

How to use variables inside a select (SQL Server)?

If I want to compute a column and use the result in more than 1 column, how do I do this without making the computing twice? Example: SELECT LOWER(SUBSTRING([NAME], 4, 100)) + '@somedomain.com' as ...
6
votes
2answers
2k views

'Conversion failed' error with ORDER BY CASE expression

I have the following Stored Procedure that works great EXCEPT when I set the 'OrderBy' to 'OrderNumber'. I get the following error: Conversion failed when converting the nvarchar value 'SK11270' to ...
61
votes
4answers
8k views

Why use both TRUNCATE and DROP?

In the system I work on there are a lot of stored procedures and SQL scripts that make use of temporary tables. After using these tables it's good practice to drop them. Many of my colleagues (almost ...
0
votes
1answer
2k views

How to get query execution time and query result at the same time? [closed]

Is there any SQL query syntax that returns query execution time and query result at the same time?
2
votes
1answer
853 views

Can't retrieve data of countries and regions

Goal: Improve my sql ability by doing some coding and reviewing existing code. Problem: I have spent lots of hour to find a solution based of this question "3c. Some countries have populations more ...
3
votes
3answers
590 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 ...
10
votes
4answers
33k views

Can I see Historical Queries run on a SQL Server database?

Someone was running a query on our SQL Server database remotely and their system crashed. They have no backup of that query and want to see what was run on the server. Is it possible to find this ...
4
votes
2answers
4k views

Prevent copying to temp table (sql)

I have two tables - comments and votes : comments(id, text, user_id, page_id) votes(id, value) There are 2,000,000 rows in the votes table. I created the following query: SELECT ...
8
votes
3answers
2k views

What are the alternatives for an ORDER BY clause in a View?

This question just had to be in this site :) ORDER BY is forbidden to use in a view, as I understood because of the possibility for multiple order by's when using this view. I know that there are ...
1
vote
2answers
83 views

Model of database management systems

Having just installed MYSQL server and client on my laptop with Ubuntu, I was wondering, (1) do all database management systems use the server-client model, regardless of whether they are actually ...
3
votes
2answers
6k views

SQL query that concatenate values from duplicate rows in a single table

Lets say I have a table of employees, like this: Name Sex Role Bob M Developer Joe M QA Now, I have a problem with this table of duplicated rows. I will fix it ...
5
votes
1answer
2k views

Send email when certain Data is being inserted in MS SQL Server

I realize that there is an integrated email notification system in SQLServer, where I can configure it to send an email using my organization's Exchange server. I want to use that to send email on ...
2
votes
2answers
124 views

Database Agnostic Conditional

I'm writing a Drupal module and I want it to be agnostic between PostgreSQL and MySQL. I have a field that gets its value from a conditional, and I originally wrote it as an IF(). Then I found out ...
1
vote
0answers
150 views

SQL Server and Perfmon [duplicate]

Possible Duplicate: SQL 2008 Server agent cant see perfmon counters I'm trying to setup SQL Server Perfmon counters on a Windows Server 2003 with SQL Server 2005 SP3. I'd like to run ...
2
votes
2answers
383 views

Check Index Fragementation Query

I'm completely stumped. I'm a relatively new SQL Server DBA so I'm at a loss with the following situation; hoping maybe someone had an idea. I have a new production SQL Server (Windows Server ...
1
vote
4answers
12k views

Retrieving row count without using Count function

I wrote a query below which shoots me a syntax error why would it do so, SELECT MAX('Row') FROM (SELECT ROW_NUMBER() OVER(ORDER BY ID DESC) 'Row' FROM USERS) Error Desc: Incorrect syntax near ...
2
votes
2answers
4k views

SQL Xml returning empty root tag on empty record set

I am working on xml explicit to generate user defined nodes in xml output using Sql Server 2005 Express edition. The below code works fine, just that i couldn't manage to generate a empty node when ...
2
votes
1answer
2k views

Sql Server 2008 R2 DBCC SHRINKFILE Severe Error

I am trying to run the following command in Sql Server 2008 R2: DBCC SHRINKFILE('filename') When I try to run this command, I get the following error: Msg 0, Level 11, State 0, Line 0 A severe ...
2
votes
2answers
1k views

SQL statement to combine main table and child table as columns?

Having a main table and a child table in a Microsoft SQL Server database (2005+), I want to show the user a single table in a grid view which includes rows from the main table and rows from the child ...
1
vote
2answers
4k views

Send Email when sql server agent job fails

How can I send an e-mail when the sql server job fails. I added my e-mail as operator and then in the job properties -> notification -> enabled the email. But it is not working. Any ideas?
13
votes
3answers
8k views

How does shrinking a SQL Server log file affect performance?

I have a SQL Server 2008 database that has a data file of some 2GB in size, but the log file is over 8GB. With pre-2008 databases I could use the 'Backup log' and the TRUNCATE_ONLY option but this is ...
4
votes
3answers
649 views

MySQL very slow query when changing one WHERE field despite no index/key

This is quite a confusing issue for me. I have a database full of baseball statistics. Running this query: SELECT * FROM hits JOIN stadiums ON stadiums.gameName = hits.gameName JOIN players ON ...
3
votes
2answers
424 views

How much RAM I should assign to SQL Server 2008 running on W2K3

I'm planning an installation for SQL 2008 over Windows 2003. The server has 16g RAM. How much RAM I should assign to SQL server?
3
votes
2answers
540 views

Testing Query Speed

When I'm running a query for the first time, it takes x miliseconds to be executed. When I run it the second time it takes a lot less time. I assume that it is some caching involved in this mechanism, ...
7
votes
3answers
606 views

More Databases Per Sql Server 2005 Instance

Our company currently hosts about 400 databases per SQL Server 2005 instance. 500-600 databases and we see performance start to deteriorate. Database size ranges from 50mb to 40-60gb in the extreme, ...
1
vote
3answers
187 views

Query optimization

In another question they told me that the speed of a DBMS largely depends on the optimizations of your queries. Does anybody know good documents about this? At school I only learned the basics. For ...
3
votes
4answers
1k views

tempdb in sql server

Using SQL Server 2000, I am getting the following error. The log file for database 'tempdb' is full. Back up the transaction log for the database to free up some log space." How to solve it? I ...
3
votes
2answers
350 views

How do I calculate working business minutes?

I'm working on business inteligence reports and one of my task is to create reports for time tracking. I have to report on business minutes (10 hours per day) within business week (monday to ...
2
votes
4answers
114 views

Backup Scenarios

In My Computer, on C drive I have a Database of 50GB and I want to take backup of that 50 GB data to other drives D,E,F but D,E,F Drives contain only 20 GB for each. In this scenario how can i take ...
4
votes
2answers
2k views

Query problem: there can be only one auto column

Can someone please tell me what's wrong with this table definition. mysql version is 5.1.52-log root@localhost spoolrdb> create table spoolqueue ( queue int, ...
4
votes
1answer
338 views

How can a raised alert fail to notify an operator via e-mail?

SQL Server 2008: A message with @msgnum = 75000 and @severity = 16 was added to the SQL instance. An alert was added that is raised when error number 75000 is raised. The alert is enabled and an ...
3
votes
2answers
101 views

Rankings based on “versus” style matchups? [closed]

Let's say I have an application that, from a pool of items, presents a random two to the user. The user selects one as the "winner" and the result would be recorded like this: INSERT INTO results ...
6
votes
5answers
4k views

SQL Select taking too much time to execute

It's a simple select from a temporary table, left joining an existing table on its primary key, with two sub selects using top 1 referring the joined table. In code: SELECT TempTable.Col1, ...
4
votes
2answers
2k views

What are some common and useful fields for a users table in a database?

I want to begin implementing user functionality on my website, but I'm not sure exactly what kind of information I should be storing. Obviously the basic things like username, password, password hash, ...
3
votes
2answers
417 views

Unique time range or database schema for a scheduling system

I'm having to design a table which contains scheduled times for media to be displayed. These scheduled times should not overlap. In my SheduledSlot table I have: id integer PRIMARY KEY begin ...
7
votes
3answers
2k views

Is there a standard implementation of a Users Database?

I need to implement basic personalized user functionality for my website. Is there a standard structure for databases of this type? Like is it common practice to have all user info and data in a ...
2
votes
2answers
4k views

Why can't we specify group functions in Oracle in the where clause?

SQL> desc tab1 Name Null? Type ----------------------------------------- -------- ---------------------------- ID ...
4
votes
4answers
3k views

Storing arrays of integers in database (for efficient select)

I am creating a database that will store 100.000 (and probably more in the future) users. While this obviously happens in a table with 1 row per user, every user can (and will) store hundreds of ...
1
vote
1answer
156 views

Duplicate record problem

create table #Personel ( Ad varchar(100) ) create table #Masa ( MasaAdi varchar(100) ) insert into #Personel values('deneme1') insert into #Personel values('deneme2') insert into #Personel ...
3
votes
2answers
671 views

A query submitted from different applications has differing DOP

I have a query which selects from multiple views and is fairly I/O heavy. If I execute this query using Management Studio it uses parallelism across most of the 16 CPUs and completes in under 10 ...
1
vote
1answer
704 views

Cartesian Product SQL / Inserts with multiple Values Clauses

I want to create cartesian product sql query.But,I'm getting the error.Where I wrong? alter table #Personel ( Ad varchar(100) ) alter table #Masa ( MasaAdi varchar(100) ) insert into #Personel ...
0
votes
1answer
325 views

Date Format in Sql Server

I am importing data from another sources, which has multiple columns but I am facing problem in date column like I have multiple format in this column like: dd/mm/yyyy mm/dd/yyyy mmm-yyyy Can you ...
1
vote
1answer
137 views

Is it require to fill all tables inside of the database?

Now,I created upper that table and in order to test I will give 3 textboxes values as below. SqlCommand cmd = new SqlCommand ("Insert Into dbo.PrnInf(PrnName, PrnSurName, PrnEgn ) Values ...
1
vote
2answers
782 views

null check and string concatenation

Can I do better than this query? select func_returns_str('key1') || nvl2( func_returns_str('key2'), ',' || func_returns_str('key2'), null) from dual; I ...
1
vote
1answer
603 views

Is it possible to write an SQL query that automatically reconciles/“transactionalizes” payments and charges

I'm still working on the project mentioned here (http://dba.stackexchange.com/questions/2428/how-do-i-properly-design-a-many-to-many-charges-payments-accounting-system). The system is to give the ...
4
votes
1answer
622 views

Speeding SQL queries for a large(?) WordPress database?

I am using a WordPress plugin called feedwordpress in order to run a planet like website (it takes content from other websites, with their permission) on WordPress (See it here). The plugin is great ...
9
votes
2answers
4k views

Reasons for occasionally slow queries?

We are running MySQL 5.1 on Windows Server 2008 R2. We have been doing some diagnostics on our database of late and have found some disturbing artifacts which we can't explain. We added some code to ...
5
votes
2answers
512 views

SQL Server configuration / specification recommendations and advice!

I am about to deploy a new server at work as follows: Dell T610 2 x Xeon 2.53 Quad core 24 GB RAM 1 x Perc H700 RAID controller with 1GB Non Volatile memory 8 x 300GB 15k SAS Hard drives I am looking ...
18
votes
2answers
27k views

How do I use currval() in PostgreSQL to get the last inserted id?

I have a table: CREATE TABLE names (id serial, name varchar(20)) I want the "last inserted id" from that table, without using RETURNING id on insert. There seem to be a function CURRVAL(), but I ...