sql

Problem with using IN in sql

Hi!Can you please help me to understand where is the problem? SELECT mz_t_NaznExec.p_Services FROM mz_t_NaznExec Above script returns recordset where record with p_Services = 200000000000115 not exists SELECT mz_t_Services.p_ID from mz_t_Services Above script returns recordset where record with id = 200000000000115 exists But this ...

Advanced grouping without using a sub query

Hi guys This is a sample of the data that I have. -ID- -Rank- -Type- -Status- -Amount- 1142474 2 Under Offer Approved 23 1148492 1 Present Current 56 1148492 2 Under Offer Approved 3 2273605 1 Present Current 24 Where the ID is the same I only want the record with the highest rank. So the end result of the query....

Create a Java Stored Procedure in MS SQL Server 2005

Can I create a java stored procedure in MS SQL Server 2005 like in Oracle or DB2? ...

Getting current connection properties in SQL Server

In MS SQL Server, the Database Properties dialog has the "View Connection Properties" link over on the left. Clicking that brings the "Connection Properties" dialog with properties of the current connection, such as Authentication Method, Network Protocol, Computer Name, etc... Is there a way to get that information programmatically by ...

Access VBA save Report as PDF/Binary

I am using Access 2007 (VBA - adp) front end with a SQL Server 2005 Backend. I have a report that i want to save a copy as a PDF as a binary file in the SQL Server. 1, Report Opened . 2, Report Closed - Closed Event Triggered. 3, Report Saved as PDF and uploaded into SQL Server table as Binary File. Is this possible and how would i ac...

dba_jobs_running: table or view does not exist when trying to access from procedure

Hi Folks, Simply querying running jobs using something like select * from dba_jobs_running; works fine when executed in my sqldevelopers SQL console. However, it does not work, when having exactly the same statement within a procedure. Compilation fails with PL/SQL: ORA-00942: table or view does not exist Any ideas? Is there so...

Inserting multiple rows in SQL

How do I restore my data from a backup table table1_bu into a new table new_table1, which has the same structure? I need to insert all the rows from table1_bu into new_table1. ...

Altering SQL column type and adding PK constraint

How to change the type of a column in a SQL table? I've got: CREATE TABLE table( id INTEGER, salt TEXT NOT NULL UNIQUE, step INT, insert_date TIMESTAMP ); I'd like to change salt's type to just TEXT and id's type to INTEGER PRIMARY KEY. UPD: I'm using SQLite. ...

mysql UNION vs IN clause

I have been trying to optimize one of my queries which looks like: select toc.* from (select sender, max(convid) as maxconvid from MetaTable where sender in ('arjunchow','aamir_alam') group by sender) as tmp1 inner join MetaTable as toc on toc.sender = tmp1.sender and toc.convid = tmp1.maxconvid...

SQL statement to switch values

Hi, I have several tables where a field is for priority (1 to 5). Problem here is that different projects have been using 5 as highest and some 1 for highest and I going to harmonize this. My easy option is to create a temp table and copy the data over and switch as this table: 1 -> 5 2 -> 4 3 -> 3 4 -> 2 5 -> 1 I'm not that good wit...

Why are my SQL indexes being ignored?

We're having a problem where indexes on our tables are being ignored and SQL Server 2000 is performing table scans instead. We can force the use of indexes by using the WITH (INDEX=<index_name>) clause but would prefer not to have to do this. As a developer I'm very familiar with SQL Server when writing T-SQL, but profiling and perform...

Can sqlite be an inmemory database also?

Hi, A bit confused, I was watching some video where some guy was using sqllite as an in-memory database. From the sqllite.org site it seems as though it is a real db? Can it be both or is the in-memory db that I saw something else? (used with NUnit). ...

Does ActiveRecord support dynamic conditions in sql statements?

I want to make a SQL query in a Rails app that adds a condition when a drop-down menu is added. Obviously I don't want to search with a blank condition if the drop down is not selected. How can I develop a dynamic condition in an SQL statement? untested example: When dropdown is not selected: Object.find("billy," :conditions => {}) Wh...

Problem with a MS Access query after a "Compact and repair" operation.

I have an Access application that use the classical front-end/back-end approach. Yesterday, the backend got corrupted for a reason I don't know. So I opened the backend with Access 2003 and access asked me if I wanted to repair the file, I said yes and it seemed to work. I can open the database see the tables contents and run most of th...

format interval with to_char

Following SQL command select TO_CHAR(NVL(arg1 - arg2, TO_DSINTERVAL('0 00:00:00'))) from table1 produces a result of the format: +000000000 00:03:01.954000. Is it possible to enter a special format in the to_char function in order to get a result of format: +00 00:00:00.000? ...

Handle error in SQL Trigger without failing transaction?

I've a feeling this might not be possible, but here goes... I've got a table that has an insert trigger on it. When data is inserted into this table the trigger fires and parses a long varbinary column. This trigger performs some operations on the binary data and writes several entries into a second table. What I have recently discover...

Sql query Monthly result but how?

This query returns me first below table. forexample; 2009-06-01 00:00:00 people enter my system '41' times. i need second table declare @date1 smalldatetime, @date2 smalldatetime , @countgap int, @page nvarchar(100) select @date1='2009-01-01', @date2='2009-12-30 23:59:59' ,@countgap=1, @page='Tüm Sayfalar' declare @@date1 smalldate...

How can I change an URL inside a field in MySQL?

I have a table called "wp-posts" with a field "post-content". This field contains the text for a blog posts. I'd like to change all records to replace an URL for another one. Imagine that I can have things like: This is a test and somewhere there's something like <img src="http://oldurl.com/wp-content/somimg.jpg"&gt; and something l...

Batch SQL inserts in .NET

Is using the .NET DataAdapter's batch insert features any more efficient, as far as DB round-trips, compared to using DbCommand.ExecuteNonQuery() in a loop? Coming from the Java world, I was hoping to find something similar to it's batch abilities where multiple SQL commands are sent to the database and executed in one operation. When ...

Concat all column values in sql

How to concat all column values from differenct rows returned from a sql query into one value? This is an example: a query returns: FOO ------ RES1 RES2 RES3 now I want to have a result like the following one: FOOCONCAT ----- RES1RES2RES3 Are there any ways to do this in sql? ...