sql

checking for smalldatetime column equal to GetDate() - ignoring time

I have a column of smalldatetime type, date I'd like to run a query that only retrieves rows: where date = convert(smalldatetime,GetDate()) However, this is never finding matches as it is also comparing the times. Ie: 01-01-2010 12:23:00 != 01-01-2010 12:25:00 How can I find matches on only the date portion? ...

when is an EJB CMP entity bean actually created

Hello, I have a session bean that provides a business method, in which it creates several CMP entity beans, something like this public void businessMethod(int number) { try { MyBeanHome home = lookupMyBean(); DataSource dataSource = getMyDataSource(); Statement statement = dataSource.getConnection().createSta...

Connecting to a File share with a flat file source in SSIS2005

I have created a SSIS package in BIDS005 that uses a flat file source as the input. The file I am wanting to use doesnt exist on my local machine, or on the server where the package will be executed. The file exists on a file share on another server, however when I try to use the server path for example: \\servername\fileshare$\filename...

SQL for MS Access: Another question about COUNT, JOIN, 0s and Dates

Hi folks, I asked a question regarding joins yesterday. However although that answer my initial question, i'm having more problems. I have a telephony table ID | Date | Grade 1 07/19/2010 Grade 1 2 07/19/2010 Grade 1 3 07/20/2010 Grade 1 4 07/20/2010 Grade 2 5 07/21/2010 Grade 3 I also have a Grade table ID | Name 1 Grade 1 2 Grad...

Dynamic Function Issue

Hi All, I am trying to create some dynamic DDL to build a function and when I run it, it keeps giving me an error. I am not sure what I am doing wrong with the format....I have tried a lot of different things and now it is just out of curiousity that I want to understand how to get it to work. Any input is greatly appreciated. CODE: ...

Unknown column error in MySQL (#1054)

This sql fails: select * from RRICallouts as r JOIN LevelToCalloutsJT as lc on ( `r.__kp_RecID` = `lc._kf_RecID~Callout` ) JOIN Levels as l ON ( `lc._kf_RecID~Level` = `l.__kp_RecID` ) where `l.__kp_RecID` = 201006221644060009 #1054 - Unknown column 'l.__kp_RecID' in 'where clause This works: select `__kp_RecID` from Le...

PostgreSQL query for current minute

My web application needs to get the results of all the items which have their time value for this minute. My table has a time attributes id, message, time, ..., where time is of type timestamp with timezone. I need to get a list of all entries where the time is the current minute. Comparing the entire value does not match because the ...

Why would an IN condition be slower than "=" in sql?

Check the question This SELECT query takes 180 seconds to finish (check the comments on the question itself). The IN get to be compared against only one value, but still the time difference is enormous. Why is it like that? ...

sql query converting rows to columns

I have 2 tables Order Table - OrderId- Primary key Order Details Table - OrderID foreign key from order table. Orderdetail table has the information for all the products which were ordered in the specific order For example Order Order Detail Table ID CustomerID OrderDate ID ...

Help Me with my SQL Query (Need it to always return at least one row.)

First off, here's my SQL query: SELECT research_cost, tech_name, (SELECT research_cost FROM technologies WHERE research_cost <= USERS_RESEARCH_POINTS_VALUE ORDER BY research_cost DESC LIMIT 1) as research_prev, (SELECT cost FROM technology_costs WHERE id = 18 LIMIT 1) as te...

Set minimum value of MySQL field - possible?

Quick newbie MySQL question. What would be the simplest way to ensure that the minimum value of a given field is 0? Basically, we have a script that runs automatically and subtracts an integer value from the value of a field every 15 minutes--but we want any entry that gets to 0 to stay at 0 and not go negative. This could be simply d...

postgres query for sales projections

================= This is my query: SELECT SUM(sub_total) AS sales, CASE WHEN (sub_total<100) THEN '0-99' WHEN (sub_total>=100 AND sub_total<200) THEN '100-199' WHEN (sub_total>=200 AND sub_total<300) THEN '200-299' WHEN (sub_total>=300 AND sub_total<400) THEN '300-399' WHEN (sub_total>=400 AND sub_total<5...

need to find the type of the column of DB.

Hi, This is my piece of code.Im getting all the tables names and col names present in the database .Now i need to know the type of column .like its int or varchar or something else .Can any one help me in this ?? and btw this is C# . OleDbConnection con = new OleDbConnection(connectionString); DataTable schemaCols; DataT...

SQL query with complex subquery

I have two tables, Foo and Bar. Foo contains a foreign key to Bar's primary key (bar_id). Bar is structured to allow a parent/child relationship to itself through a foreign key (bar_parent_id) to another record in Bar. This relationship is limited such that any Bar record that has a parent cannot itself be a parent. However, any given pa...

What is the use of reorg command in IBM DB2 ?

What is the use of reorg command in ibm db2 db ? What does Reorg do internally ? Is it necessary to run reorg if new indexes are created on the table ? ...

Microsoft-provided data provider classes, the good and the bad?

What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET? are they fast? ...

SQL Query to get the rows not part of join

Hi, I am having below tables. create table test(int id,int data1); create table test1(int id,int data2); insert into test values(1,1,); insert into test1 values(2,2); insert into test1 values(3,3); insert into test1 values(1,1); Now I want the rows of test, that don't participate in join. i.e I want rows (2,2) and (3,3). I want to ...

creating timestamp from columns in postgres

i have 2 rows in a column, one feeding me the julian date (number of days since Jan 1, 1970, with that day being 1), and the second column is the number of minutes past midnight of the current day (why it was done this way, i have no idea). i would like to get my sql query to create a timestamp out of these two columns. if i had access...

Finding unique matches in 2 separate databases

I have 2 databases that have the same structure, but different data. Both are SQL 2005. I am trying to find which of the Persons in Database A, exist in Database B. My best opportunity for match is to match on FirstName and LastName. I only want to bring back a list of: DatabaseA.Person DatabaseB.Person Where: 1. I want all records f...

SQL Select From Master - Detail Tables

I have two tables, named t_master and t_detail. The data in the t_detail table corresponds to a record on the master table. Data of t_master ID Brand 1 Toyota 2 Honda Data for the t_detail DetID ParentID Model 1 1 Corolla 2009 2 1 Corolla 2010 3 1 Corolla 2011 4 2 Civic 2004 5 2 ...