sql

SQL: Dynamic Where Clause using IN statement dying on records with NULL values

I am trying to implement search funtionality for our database through a website. The database has one master table and five tables that are foreign keyed to the master (detail tables). Detail tables hold nullable integer values that are hooked to lookup tables in the application. I want to allow a user to select any/all values from a loo...

how to use reportservice2005.asmx

Hi there, is there an article that explain how to implement reportservice2005.asmx? thanks ...

Determine position of first occurence of string in MySQL?

For a table like this: username | time --------------------------------------- animuson | 0.678 aP*animuson | 0.967 animuson | 0.567 qykumsoy | 0.876 I'm trying to find a way in MySQL to order these by times and then find the position where username occurs and username is only counted once. So, if I'm s...

SQL - How do you select the first row (or any unique row) of multiple rows with the same ID?

Let's say I have a query result that looks as follows: ID NAME Phone ---- ---- ----- 1 Bob 111-111-1111 1 Bob 222-222-2222 1 Bob 333-333-3333 2 Stan 555-555-5555 3 Mike 888-888-8888 3 Mike 777-777-7777 I want to return just a single row instance of each ID value. It doesn't matte...

MySQL triggers alteration

Is there any way how to update automatically mysql trigger(s) structure, every time when I alter a table? ...

SQL query to find where no primary key exists

Hi I have re-added a foreign key relationship to a table in order to do so I had to abandon checking data on creation. I presume some parent(Company) objects have been deleted and I want to find the orphaned(Division) records. How would I find an row where the foreign key does not exist in the primary table? This is what I was thinking ...

A simple MySQL query taking forever (more than 20 minutes!)

Hello, Maybe you can help me. I need to query 3 tables in order to get data for a financial stock. The idea is to go to the instruments table, find the index for each instrument and then bring all the prices for that particular instrument together with the indicators that are on a separate table. Tables stockdata and indicators are bot...

Which RDBMS and development tool should I choose to re-write my character-based app?

I have a pawnshop CRUD app written 20 years ago with INFORMIX-SQL/SE (DOS) which is currently running on DOS 6.22 within Microsoft Virtual PC 2007 on Windows Vista. I would like to modernize this app with a GUI, SQL-based engine and retain its existing functionality. It doesn't require any networking or multi-user capability. I would pre...

SQL Server 2005 One query to calculation two table

Hello everyone, I'm beginner in SQL Server I have three tables in Database hospital PatientFiles OtherServices PatientDeposit Two queries to display my result Query Number One. Display PatientFilesID, TotalOtherServices SELECT pf.ID AS PatientFileID, SUM(os.Quantum * os.Price) AS TotalOtherServices FROM PatientsFiles pf INNER ...

How do you read a full table from a SQL database in VB.NET?

I hate to ask this question on this forum, but I'm having a lot of trouble finding it on these online tutorials. Basically, I'm learning about SQL, VB.NET, and how to glue the two together, and I've learned about using SqlCommand.executeScalar() to get the first entry in a table. But that's all it's really good for, right? Or is there...

Update database n:n

I have two classes: public class RichMan { public string ID {get;set;} List<Car> _cars=new List<Car>(); { public List<Car> Cars { get { return this._cars; } set { this._cars = value; NotifyChanged("Ema...

Count(*) with 0 for boolean field

Let's say I have a boolean field in a database table and I want to get a tally of how many are 1 and how many are 0. Currently I am doing: SELECT 'yes' AS result, COUNT( * ) AS num FROM `table` WHERE field = 1 UNION SELECT 'no' AS result, COUNT( * ) AS num FROM `table` WHERE field = 0; Is there an easier way to get the resu...

SQL Server Developer

I have got one offer from MNC company for the post of SQL Server Developer. As such i am a programmer (in .net and SQL Server as back end).To crack the interview what topics i need to be aware of? (as there would be a difference in MS SQL used by programmer and a MS SQL Developer) Thanks! ...

How to create an MySQL query alias?

For example I use this select * from tab1; every 5 minutes. Is there a way to set up an alias p so that I can just do p instead and that query is executed? ...

cache lite / memcache

i have a function that build query depending on which page user is at, by parameter array value, once it build the query, then it returns, so we can execute it and get the desire result we want. well we need to put cache on it, so we can speed up things and im really confuse on how to make cache id, sence the query is kind of dynamic ...

Populate Typed Dataset wit UNION ALL SQL query

I have a strange situation here and I hope someone can help me. I don't have the same problem when using an untyped dataset. OK. I have a typed dataset MyDS with a typed datatable MyTable (TableID, Title, Message). The table gets filled with results from two tables, using a UNION ALL Select TableAID, TableATitle, Message FROM T...

How do i create index column in sql?

I'm using SQL-Server 2005. I have table with many columns, rows i select have where clause which makes impossible to use identity as indexer. I want select all these row + indexer row (acting like identity). example 2 jack 4 thomas 8 james to 1 2 jack 2 4 thomas 3 8 james thanks ...

improve a mysql query.

I have a query. DELETE FROM A WHERE i NOT IN ( SELECT i FROM B WHERE j = 1 UNION select i from C UNION select i from D ); basically delete all rows in A where field i does not occur in tables B, C or D. If it was just DELETE FROM A WHERE i NOT IN ( SELECT i FROM B ); then that could be done easility with a left join ...

Check constraint for a flag column

Database is MS SQLServer Data example: | Name | defaultValue | value | | one | true | valone | | one | false | valtwo | | one | false | valthree | I'm after a way of constraining the table such that each 'Name' can only have one row with 'defaultValue' set to true ...

Selecting columns as rows

Query: SELECT 'SUMS' AS [Desc], SUM(PriceN) AS Nett, SUM(PriceG) AS Gross FROM Resources gives me a resultset: Desc Nett Gross -------- ---- ------ SUMS 515.00 621.55 I need a resultset which looks like this: Desc Value ---- ----- Nett 515.00 Gross 621.55 I was struggling with pivot sta...