sql

Problems with SqlRestore when using different DataBases

Hello, i have some project, which can be running on databases with different names. I have some functionality in my program to do database backups and to restoring from them. The problem is when i try to restore database from backup to other database with a different name and so on. My code looks like this: public void Restore(s...

Java and prepareStatement with MySQL

Hello. I use Java to do some SQL queries. in general the queries that i want to perform are: set @uid=?; set @friendsList=?; IF EXISTS(select 1 from fb_user_friends join fb_user on " + " fb_user.id = fb_user_friends.fb_user_id where uid=@uid) then " + "update fb_user_friends set friends = @friendsList; ELS...

Designing SQL database to represent OO class hierarchy

I'm in the process of converting a class hierarchy to be stored in an SQL database. Original pseudo code: abstract class Note { int id; string message; }; class TimeNote : public Note { time_t time; }; class TimeRangeNote : public Note { time_t begin; time_t end; }; class EventNote : public Note { int event_id; }; ...

Update status (publish) of 60000 nodes

hi I have approximately 60.000 nodes in my Drupal installation. They are all unpublished, and I need to publish all of them. I'm trying to publish them from "Content menu" but I can only select all nodes in a single page. How can I select all nodes in my website ? thanks ...

Subsonic 3 query with aggregate error

Hello, I'm creating a simple query with aggregates. The example is: string query = new SubSonic.Query.Select( SubSonic.Query.Aggregate.GroupBy("ProductID", "ID"), SubSonic.Query.Aggregate.Max("Price", "MaxPrice") ).From("Orders").ToString(); The Sql Result is: SELECT ProductID AS ID, MAX(Price) AS MaxPrice FROM [Orders...

iterate over database query results in vba in excel

Hi. I would like to open a connection to SQL database, and then have access to individual cells. I have an example that uses PivotTableWizard (presented below). I would like to know of a way that does not have anything to do Pivot Tables - I would like to iterate cell-by-cell. Or is this PivotTableWizard suitable for that purpose also? ...

how to form a tree structure from DB2 Table(s)?

Please refer to this question database-structure-for-tree-data-structure Is this possible in DB2 Database? I know it is possible in Oracle using START WITH and CONNECT BY, i don't have any idea in DB2, Is it possible to achieve this in DB2? Thanks! ...

Get values from all sub-divided child tables.

Hi All, I have three tables as below. TransactionTable ---------------- TransactionID Status Value FileNo (int) FileType - 'E' indicates Email, 'D' Indicates Document EmailTable ---------- EmailFileNo (Identity) ReceivedDate .... .... .... DocumentsTable --------------- DocFileNo (Identity) ReceivedDate ..... ..... ...

sql query for nullable number greater than parameter

Simple table: create table Items ( Price money null ) Now I need to create a stored procedure that accepts one paramter of type bit @ItemsWithPriceTenDollarsOrMore which: returns all items if parameter is null returns all items with Price >=10 if parameter = 1 returns all items with Price < 10 if parameter = 0 I have difficulty ...

simple Group By

Sorry for this simple question, but i'm missing the forest through the trees. These are my tables (i left the sparepart-table because i'm only looking for two special fk's): I need the distinct rows from tabData which are referenced in the child-table tabDataDetail with fiSparePart=8837 and 8969. The following gives me only that rows ...

Call a stored procedure with another in Oracle

Hi, does anyone know of a way, or even if its possible to call a stored procedure from within another? And if so how would you do it? Here is my test code: SET SERVEROUTPUT ON; DROP PROCEDURE test_sp_1; DROP PROCEDURE test_sp; CREATE PROCEDURE test_sp AS BEGIN DBMS_OUTPUT.PUT_LINE('Test works'); END; / CREATE PROCEDURE test_sp_1 ...

Linq to SQL Chunked Delete or Update Operation?

I have a lot of rows to delete in a table, and using ADO.NET I might send a SqlCommand with this text: WHILE(1=1) BEGIN DELETE TOP(5000) FROM myTable WHERE myval=123 IF @@ROWCOUNT < 5000 BREAK END I would wrap that in a transaction or 2 and could then delete in chunks so the DB could come up for air. I would like to do th...

database design normalization help needed (5nf)

Can you guys show me how to get this ERD in 5th normal form? We did a class assignment yesterday where we had a real client come in and explain to us his need my group came up with this model I am trying to take it a step further and see if I can get it to 5th normal form so that I can understand it better as next week we will be doing a...

How does SQL READUNCOMMITTED behave on VIEWS ?

I have a view which contains a join of multiple tables. If I use 'WITH (READUNCOMMITTED)' on the SELECT FROM View, will this propagate and apply to tables that are joined by the view or not ? ...

SQL between dates but cut off at certain time and continue and certain time.

I have an MSSQL query that runs order productivity for a time period. Basically it calculates how long an order takes from start date to completion date in minutes. What I am doing is getting the date and timestamp where the order is created(a) and getting the date and time stamp where the order is completed(b) and subtracting them the...

SQL eleminate mulitple value(s) if same identifier has a associated NULL value

Ok here goes: I have a table with id ( can be duplicate but not NULL ) and value ( can be duplicate and NULL ) id value ----- ----- 1 red 1 red 1 (null) 2 blue 2 blue 3 (null) So how do I return the id's and value's of all the records that have a value, but if a null value is also found don'...

Is it possible to use characters instead of a position in a substring function?

Hello all, is it possible to use characters instead of a position in a substring function? SELECT SUBSTRING(title,2) FROM table puts out every title starting with the second position. Now I want to cut the output after a space. The space positions varies. Is it realiseable? I tried sth. like SUBSTRING(title,2,LOCATE('',title)),but fo...

This SELECT query takes 180 seconds to finish

UPDATE: Just to mention it on a more visible place. When I changed IN for =, the query execution time went from 180 down to 0.00008 seconds. Ridiculous speed difference. This SQL query takes 180 seconds to finish! How is that possible? is there a way to optimize it to be faster? SELECT IdLawVersionValidFrom FROM question_law_versio...

double sorted selection from a single table

I have a table with an id as the primary key, and a description as another field. I want to first select the records that have the id<=4, sorted by description, then I want all the other records (id>4), sorted by description. Can't get there! ...

How to run sys.sp_addlogin in ant sql task ?

Hi Ant guru, I got error BUILD FAILED C:\Projects...\build.xml:987: com.microsoft.sqlserver.jdbc.SQLServerException: The procedure 'sys.sp_addlogin' cannot be executed within a transaction. How can i make an ant sql task run this? thanks ...