sql

what are the uses of the different join operations in sql

what are the uses of the different join operations in sql? Like i want to know why do we need the different inner and outer joins? ...

Web form is not updating tables, why?

I have a web application and on page is an update page to update some profile information. Below is the code I am using to update the table. But I think it is wrong. Does anything stick out? The connection string works cause it is used to read the database to get the profile information, I just removed it due to it containing passwor...

Oracle Database Enforce CHECK on multiple tables

I am trying to enforce a CHECK Constraint in a ORACLE Database on multiple tables CREATE TABLE RollingStocks ( Id NUMBER, Name Varchar2(80) NOT NULL, RollingStockCategoryId NUMBER NOT NULL, CONSTRAINT Pk_RollingStocks Primary Key (Id), CONSTRAINT Check_RollingStocks_CategoryId CHECK ((RollingStockCa...

Convert SQL Server 2000 to 2005

I have a SQL Server 2000 database and I want to convert it to SQL Server 2005 ...

SQL Server - sum comma separated value from a column

There is a column in database which contains comma separated values like: 0.00,12.45,14.33 and so on. I need to sum this inside a stored procedure. One way which I can think of is to split and convert it into a table using a function and then sum it. Any other ideas? ...

What's the execute order of the different parts of a SQL select statement?

Hi guys, What's the execute order of the different parts of a SQL select statement? Such as distinct from order by group by having multiline function(count, avg, max, min...) top(sql server) or limit(mysql) other parts Does the different databases have the same execution order? Great thanks. ...

should this database table be normalized?

i have taken over a database that stores fitness information and we were having a debate about a certain table and whether it should stay as one table or get broken up into three tables. Today, there is one table called: workouts that has the following fields id, exercise_id, reps, weight, date, person_id So if i did 2 sets of 3 diffe...

Using SQL for localization instead of RESX files in ASP.NET

Hi, I'm thinking of developing the following but wondering if it already exists out there: I need a SQL based solution for assigning and managing localization text values for an asp.net site instead of using RESX files. This helps maintain text on the site without having to take it down for deployment whenever an update is required. T...

What is the difference between check and foreign key?

i am quite confused about the difference between a FOREIGN KEY and CHECK constraint - they appear to me to achieve the same result. I mean I could create a table and enforce a Foreign key on another table, but i could create a CHECK to ensure the value in in another table. What is the difference and when to use the one or the other? ...

SQL: Recursively get parent records using Common Table Expressions

Hi there, Suposse you have to following tables where a sale consists of products and a product can be placed in multiple categories. Whereby categories have a hierachly structure like: Man Shoes Sport Casual Watches Women Shoes Sport Casual Watches Tables: Sale: id name 1 Sale1 Product: id saleidfk name ...

Is there something like "if not exist create sequence ..." in Oracle SQL?

Very probably a noob question: For my application that uses an Oracle 8 DB, I am providing an SQL script to setup stuff like triggers, sequences etc., which can be copied and pasted into SQL*Plus. I would like the script to not stop with an error if a sequence that I am trying to create already exists. For a Trigger this can easily be do...

WSSQL query for multiple computers at once

I can run normal searches just fine. Windows 7 won't let me add a network share to my local index, but I can query the remote index just fine. The problem is that I can't find a way to query two indexes at once. I was hoping that something like this would work: SELECT System.ItemName FROM compA.SystemIndex, compB.SystemIndex WHERE ...

Does introducing foreign keys to MySQL reduce performance

I'm building Ruby on Rails 2.3.5 app. By default, Ruby on Rails doesn't provide foreign key contraints so I have to do it manually. I was wondering if introducing foreign keys reduces query performance on the database side enough to make it not worth doing. Performance in this case is my first priority as I can check for data consistency...

SQL to retrieve aggregated data with computed columns

I have a table that looks like this for about ~30 students: StudentID Course* CourseStatus 1 Math Pass 1 English Fail 1 Science Pass 2 Math Fail 2 English Pass 2 Science Fail etc. *In my actual database the 'Course' column is ...

SQL Server SELECT stored procedure according to combobox.selectedvalue

In order to fill a datagridview according to the selectedvalue of a combobox I've tried creating a stored procedure. However, as I'm not 100% sure what I'm doing, depending on the WHERE statement at the end of my stored procedure, it either returns everything within the table or nothing at all. This is what's in my class: Public Functi...

algorithm optimization: returning object and sub-objects from single SQL statement in PHP

I have an object oriented PHP application. I have a simple hierarchy stored in an SQL table (Chapters and Authors that can be assigned to a chapter). I wrote the following method to fetch the chapters and the authors in a single query and then loop through the result, figuring out which rows belong to the same chapter and creating bot...

Facing problem in configuring Reporting Server

Hi all, I am using Sql server 2005 express edition and i want to Install and configure Reporting server on my local machine.Now i have installed the reporting server but the issue is that i am unable to configure it properly.when ever i go to start the reporting services it gives me the following message: THE SQL SERVER REPORTING SERV...

How do I do a WHERE on the COUNT(name) produced by a GROUP BY clause?

WHERE gets processed before GROUP BY in the SELECT statement. How can I use WHERE on the result of a COUNT(name)? What I want is this: SELECT topic, COUNT(name) AS counter FROM blah GROUP BY name WHERE counter <> 1 ...

MySQL ORDER BY date and team

I would like to order by date and then team in a MySQL query. It should be something similar to this: SELECT * FROM games ORDER BY gamedate ASC, team_id AND it should output something like this: 2010-04-12 10:20 Game 1 Team 1 2010-04-12 11:00 Game 3 Team 1 2010-04-12 10:30 Game 2 Team 2 2010-04-14 10:00 Game 4 Team 1 So that Team 1...

MS SQL datetime precision problem

I have a situation where two persons might work on the same order (stored in an MS SQL database) from two different computers. To prevent data loss in the case where one would save his copy of the order first, and then a little later the second would save his copy and overwrite the first, I've added a check against the lastSaved field (d...