sql

SQL query to combine several tables to find price of item every day

I am trying to build a table to show me the price of an item each day over a specified time period. I begin with three tables: one containing the sale price with a start and end date, one containing the regular price of an item and when it started at that price, and one date table that just has dates for filling in blanks. Tables: S...

Performing an SQL query while waiting on an asyncronous operation generates an exception

The code I'm writing copies data from one table to another. It is possible the query may run for a long time so I'm performing an asynchronous query and while waiting I'm doing a count on the destination table to provide a status update. The query that does the count is getting the following exception message... The command execution c...

Microsoft NoSQL strategy

Does Microsoft have any NoSQL strategy at all? Any ongoing MS Research projects? ...

MySQL query problem.

When a user sends a friend request and accepts it the friends info and pic are displayed perfectly on the users side but on the friends side the friends own pic and info is displayed instead of the user who friended the friend how can I fix this problem? users friends table CREATE TABLE users_friends ( id INT UNSIGNED NOT NULL AUTO_I...

Select non duplicate values from rows that are less than a specified number of minutes apart

I have a huge table with the following format: DATETIME NUMBER -------------------------------------- 2009-03-31 16:05:52.000 2453651622 2009-03-31 16:16:12.000 30206080 2009-03-31 16:16:16.000 16890039 2009-03-31 16:16:28.000 2452039696 2009-03-31 16:16:33.000 140851934 2009-03-31 16:16:51.000 245312...

90 days range using SQL server

Hi, is there a way in SQL server that i can count the items 90 days prior to the inception date and the items 90 days after the inception date. Example: select site, count(*) from mytable where date >=10/1/2009' and date <'12/30/2009' group by site 90 days before - after inception date. prior to inception date = 7/3/2009. inceptio...

Skip rows in query based on data

I have data as follow DECLARE @tmp TABLE(cid int, colspan int, rowspan int, corder int) INSERT INTO @tmp SELECT 1,2,null,1 UNION SELECT 2,null,null,2 UNION SELECT 3,null,null,3 UNION SELECT 4,3,null,4 UNION SELECT 5,null,null,5 UNION SELECT 6,null,null,6 UNION SELECT 7,null,null,7 I want to query to return cid colspan rowspan cor...

MySQL check id whether is in another table

How to check whether the id from one table is in another table in the same database. If it is then the row should not be returned. table1: id int(11) unsigned primary key, data varchar(25) default '' table2: id int(11) unsigned primary key, tableone_id int(11) unsigned, another_data varchar(11) default'' the query checks whether id fr...

SQL date ranges

Possible Duplicate: 90 days range using SQL server I am trying to get the counts 90 days prior to the operational date and the counts 90 days after the operational date. For example, my operational date is 4/1/2004. So,90 days prior to 4/1/2004 is (1/2/2004 to 3/31/2004) and 90 days after (including 4/1/2004) is 6/29/2004. I ...

how can i write storec proc which to remove old records older than 90 days from table1 and table2

Hi, i wanna write stored proc which would delete records from dirstaging.trr.table1 and dirstaging.trr.table2 older than 90 days. the same stored proc will remove all records from dir.trr.ErrorTable where there is not a record in dir.trr.table3 and dir.trr.table4. this proc will accept variable @cleanup. NOTE : i tried something like se...

the different between join condition and where condition

Somebody tell me what's the difference between two queries: Version A select p.LastName, o.OrderNo from Persons p, Orders o where p.P_Id = o.P_Id ...and... Version B select p.LastName, o.OrderNo from Persons p join Orders o on p.P_Id = o.P_Id ...

How to use ScalaQuery to insert a BLOB field?

I used ScalaQuery and Scala. If I have an Array[Byte] object, how do I insert it into the table? object TestTable extends BasicTable[Test]("test") { def id = column[Long]("mid", O.NotNull) def extInfo = column[Blob]("mbody", O.Nullable) def * = id ~ extInfo <> (Test, Test.unapply _) } case class Test(id: Long, extInfo: Blob) ...

SQL Server 2000 Script to list all Meta Data Services DTS packages

Hi Team, I am doing an SSIS package that would go out to all our DB servers to gather information about them, and what is on them. And in this one case there is a SQL 2000 box with a bunch of DTS packages on there. Now I can easily list the Local Packages using "exec sp_enum_dtspackages", but this doesn't list the Meta Data Services P...

Need a feedback for matrix question table design

Hi In the survey, there is a type of question called Matrix which it's like this: | Is Friendly | Weather | Comments =========================================== Sydney | Y | 5 | 'bla' ------------------------------------------- Singapore | Y | 10 | 'test' ------------------------------------...

Sql Server2005 query problem

i have a table which contains the following fields Supervisorid Empid This is just like a referral program. A guy can refer 3 guys under him i.e, 3 is referring three guys namely 4 5 8 similarly 4 is referring 9 10 and 11 likewise 8 is referring 12, 13 it goes like this.. I want a query to get the total no of down line members under...

sql query to get redundant record

I want to get redundant records from the database. Is my query correct for this? select (fields) from DB group by name, city having count(*) > 1 If wrong please let me know how can I correct this. Also if I want to delete duplicate record will it work? delete from tbl_name where row_id in (select row_id from tbl_name group by...

Lock SQL table for a period of time

Hey all We are trying to test our new software here which is based on SQL 2005. We want to see how it will respond when one of the tables which the software is using during insert/update gets locked. is there a way in SQL 2005 we can simulate this? so that we can see how we can handle the error on the front end? thanks ...

SQL Query Help: Returning distinct values from Count subquery

I've been stuck for quite a while now trying to get this query to work. Here's the setup: I have a [Notes] table that contains a nonunique (Number) column and a nonunique (Result) column. I'm looking to create a SELECT statement that will display each distinct (Number) value where the count of the {(Number), (Result)} tuple where Result...

insert data read from a sybase server into an oracle server

Hi, I'm using embedded sql. When I run a query and get the results in a table from a sybase server, how do I insert the resultant table into an oracle server? ...

What is the best approach of querying based on Geo parameter

I have a table which contains Geo-Based information. (latitude and longitude) i would like users to input their Latitude and Longitude value(e.g current location), then query returns the records ordered by the distance between "user inputed spot" and "record position". any suggestions or web link would be appreciated. thank you all in...