sql

IS a MIN(coalesce) across multiple tables possible / the best solution for this query in sql 2005?

Hi, I am looking to pull out the minimum value across three tables and then compare this to the lowest value in a fourth table, where the tables are structure like this: Table 1 (event_id (PK uniqueidentifier),date_created,contact_id) Table 2 (event_id (PK uniqueidentifier),date_created,contact_id) Table 3 (event_id (PK uniqueidentifi...

java.sql.SQLException: Exhausted Resultset

I get the error java.sql.SQLException: Exhausted ResultSet to run a query against an Oracle database. The connection is via a connection pool defined in Websphere. The code executed is as follows: if (rs! = null) ( while (rs.next ()) ( count = rs.getInt (1); ) )...

How to insert table values from one database to another database?

I want a query to insert records from one table to another table in different database if the destination table already exists, it should append the records at the end of the table. Please help me. Thanks in advance. ...

Calling a WCF Service from SQL CLR Stored Procedure

I have created a SQL CLR Stored Procedure which will call a WCF Service. I have managed to get all the correct DLL's loaded into SQL Server to get this to work however I now have following error message: System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for system.serviceMode...

Dynamic SQL on DataSet

I have to get a dynamically created SQL-Query to work with a DataSet. I'm using a DataSet where I store some information from the database file (MS-Access). Now I want the user to be able to select special filters - and depending on them I create a SQL-Query, e.g.: SELECT * FROM table WHERE x <> 0 AND y >= 10 The problem is, that the...

Top User SQL Query With Categories?

I'm trying to figure out how to get the top users in each category with a mysql query: My Users Table looks like this: user_id,category_id ... and some other stuff My Votes Table looks like this (each row is one positive vote): reciever_id ... and some other stuff I was thinking that I need to first determine the unique votes by user_...

SQL Server 2005 - Getting error for unknown reason

What I'm trying to do is create a table that has 2 fields, one being the status and one being a type of equipment. I then need a list of how long these particular types of equipment have been being repaired. There can be multiples of each equipment, so I would like something like this: Equipment Type | Status | 0-7 days | 8-15 days ...

Is SQL Injection possible when parameter's type isn't set?

Does passing SQL Parameters to a stored procedure alone ensure that SQL injection won't happen or the type checks also need to be performed? As an example - ADO.NET Code: Database DBObject = DataAccess.DAL.GetDataBase(); DbCommand command = DBObject.GetStoredProcCommand("usp_UpdateDatabase"); List<DbParameter> parameters...

what is good, explicite cursor in backend or loop in front end?

what is good,using explicite cursor,while loop on database side OR using loop on front end (application side programm)??? Edited:- Hi,if I want to iterate and i am using ado.net asynchronous(disconnected) connection (ie.I have a datatable and i am applying for loop on datatable in front end) -- In this case,If i want to iterate which is...

Table is not getting updated , when used executeNonquery

Hi, I am trying to change the user password. I am not able to update the password :(. The message i am getting is password changed where as its not getting changed. . My code is as follow.. Please if anyone can suggest where i am going wrong . I am just a beginner ... protected void Button1_Click(object sender, EventArgs e) { Datab...

Is OData intended for use within Government and Financial envrionments? What security precautions do I need?

At first brush, OData seems like it will only appeal to "open" databases, and would never be used in envrionments where security is needed, especially with financial or government clients. Is this the correct perspective to have with the current version of OData/WCF? If not, can you share whatever I would need to change that perspectiv...

How to test performance for your database Best practice

Hi, I need to test indexes performances for some table in my database. After I run my query with indexes or without them I always use this code; SELECT * FROM sys.dm_exec_query_optimizer_info; And I receive details about my query. My problem is: using sys.dm_exec_query_optimizer The details for my query are always changing making...

Derby INSERT SELECT null pointer exception

I'm writing a Java application that's working with Apache Derby via JDBC. I'm having problems with the code in the following snippet: byte md5[] = md5sum(file); PreparedStatement s = con.prepareStatement("INSERT INTO input_files (job_ID, hash) SELECT job_id, ? FROM job WHERE job_name = ?"); s.setBytes(1, md5); s.setString(2, jobName); ...

I have one big query for performance related in SQL Server 2005

I have one big query for performance related in SQL Server 2005. I have data like this id parentId 1 null 2 1 3 1 4 2 5 4 6 3 I want the order for the records by downline with parentId and id wise like id Order 1 1 2 2 4 3 5 4 3 5 4 6 I don't want to use loop, because loop is creating the problem if high ...

How to get date representing the first day of a month?

I need functionality in a script that will enable me to insert dates into a table. What SQL do I need to insert a date of the format 01/08/2010 00:00:00 where the date is the first day of the current month. What do I need to change order that I can specify the month value? Thanks ...

SQL: How to find duplicates based on two fields?

I have rows in an Oracle database table which should be unique for a combination of two fields but the unique constrain is not set up on the table so I need to find all rows which violate the constraint myself using SQL. Unfortunately my meager SQL skills aren't up to the task. My table has three columns which are relevant: entity_id, ...

Zend_Dojo_Data from SQL View (primary key not available, can it be done?)

Well, i'm trying to achieve something but i think it is not possible. Here's where i am. SQL Table T with columns colID , colA, colB. colID is the primary key I needed to retrieve all the values specified in colA "unioned" with colB, so I created a view CREATE OR REPLACE VIEW vw_MyView (col_Common) AS (SELECT col_A AS col_Common FROM ...

SIMPLE MySQL Join question...

Hello again! I'm a complete newbie to SQL, and I am having problems with what I assume is an easy easy SQL join statement. I have an "inventory" and an "items" table. The "inventory" table contains a user_id, an item_id, and a qty. The "items" table contains an item_id and and item_name. I want a user to get a list of all inventory ...

ways to escape single quotes in sql LIKE command

hi, i want to know what are the various ways to ESCAPE single quotes(') in SQL LIKE command . one way is to put two single quotes whenever you have to escape a single quote. Can you people suggest something?? Thanks. Database -- SQL2005, oracle 10g ...

Want to sum some fields and leave others alone SQL

I have a query that results in a field of varying lengths (6, 8, 10, ...) and respective counts as seen below: "region","repeatLength","count" "promoter","6","272387" "promoter","8","86929" "promoter","10","28337" "promoter","12","8873" "promoter","14","3080" "promoter","16","1098" "promoter","18","475" "promoter","20","206" "promoter"...