sql

What tool for managing Oracle DB do you suggest?

What tool for managing Oracle DB do you suggest? I need to execute scripts and manage data in tables and develop some scripts and packages. I'v tried SQL developer and actually don't like it. Want some more features for developing (debug, code assist, integrated help and so on.) ...

Silverlight deepearth sql server 2008

Is it possible to use deepEarth with sql server 2008 spatial, or is there aney other open-source mapping solutions for Silverlight and sql server 2008. Tanks for any thought on this. ...

mysql: Average over multiple columns in one row, ignoring nulls

I have a large table (of sites) with several numeric columns - say a through f. (These are site rankings from different organizations, like alexa, google, quantcast, etc. Each has a different range and format; they're straight dumps from the outside DBs.) For many of the records, one or more of these columns is null, because the outside...

Drop group of stored procedures by name

I have group of stored procedures with names like 'somename_%'. Are there any way to delete that SP with one query, forexample DROP PROCEDURE where name like 'somename_%' . ...

how to select the records whose several fields' combination will equal to a specific value

Hi all, Assume I have the following style table, col1 col2 and col3 have same value scopes, I want to select the records when two of the 3 columns have a value combination such as ('ab' and 'bc'), in the following example, the first 3 records should be selected. Any good way to do this? I am using Sybase. | id | col1 | col2 | col3 | ...

DataTableReader is invalid for current DataTable 'TempTable'

Hi, I'm getting the following error whenever my code creates a DataTableReader from a valid DataTable Object: "DataTableReader is invalid for current DataTable 'TempTable'." The thing is, if I reboot my machine, it works fine for an undetermined amount of time, then dies with the above. The code that throws this error could have been ...

Forum board example schema in YAML format - modify for Nested set?

I have created a forum board app, based on YAML schema found in 'real world examples' of Doctrine Manual, which looks similar to this: --- Forum_Category: columns: root_category_id: integer(10) parent_category_id: integer(10) name: string(50) description: string(99999) relations: Subcategory: class: Forum_C...

Re-use aliased field in SQL SELECT STATEMENT

Hi, the question is hard to define without giving an example, e.g. I'd like to achieve something like this : SELECT (CASE WHEN ...) AS FieldA, 20 + FieldA AS FieldB FROM Tbl Assuming that by "..." I've replaced a long and complex CASE statement, hence I don't want to repeat it when selecting FieldB and use the aliased FieldA instea...

PostgreSQL - Error: SQL state: XX000.

I have a table in Postgres that looks like this: CREATE TABLE "Population" ( "Id" bigint NOT NULL DEFAULT nextval('"population_Id_seq"'::regclass), "Name" character varying(255) NOT NULL, "Description" character varying(1024), "IsVisible" boolean NOT NULL CONSTRAINT "pk_Population" PRIMARY KEY ("Id") ) WITH ( OIDS=FALSE ); ...

counting employee attendance

I am trying to write a statement for counting the employees attendance and execute their id , name and the days that he has working on the last 3 months by counting the duplicate id on NewTimeAttendance for month 1, 2 and 3. I tried to count: Select COUNT(employeeid) from NewTimeAttendance where employeeid=1 and (month=1 or month =...

SQL SELECT Join?

I have a MySql DB. There is a table with products and orders with the structure: Products: product_id, name, manufacturers_id Orders: orders_id, product_id, quantity Now I want to get all orders (show only products where product manufacturers_id=1). I tried: SELECT orders.orders_id, orders.product_id FROM products, orders WHERE p...

SQL server 2005, syntax error

This line do not work: (the problem is in the last line) SELECT Book_Name FROM Books WHERE (Year, Faculty) = (SELECT Year, Faculty FROM Books WHERE Book_Id = 1112); How can I fix it? ...

SQL Server insert slow

Hi, I have two servers where I installed SQL Server 2008 Production: RAID 1 on SCSI disks Test: IDE disk When I try to execute a script with about 35.000 inserts, on the test server I need 30 sec and instead on the production server more than 2 min! Does anybody know why such difference? I mean, the DB are configured in the same way...

What is the scope of TRANSACTION in Sql server

I was creating a stored procedure and i got stuck in the writing methodology of me and my collegue. I am using SQL Server 2005 I was writing Stored procedure like this BEGIN TRAN BEGIN TRY INSERT INTO Tags.tblTopic (Topic, TopicCode, Description) VALUES(@Topic, @TopicCode, @Descripti...

SQL Server trigger that rounds values

I need to write a trigger that rounds a value whenever it is inserted/updated into a table ...

How to get values from SQL query made by php?

So I made a query like this global $connection; $query = "SELECT * FROM streams "; $streams_set = mysql_query($query, $connection); confirm_query($streams_set); in my DB there are filds ID, UID, SID, TIME (all INT type exept time) So I am triing to print query relult into form <form> <select class=...

SQL OUTER JOIN with NEWID to generate random data for each row

Hi, I want to generate some test data so for each row in a table I want to insert 10 random rows in another, see below: INSERT INTO CarFeatures (carID, featureID) SELECT C.ID, F.ID FROM dbo.Cars AS C OUTER APPLY ( SELECT TOP 10 ID FROM dbo.Features ORDER BY NEWID() ) AS F Only trouble is this returns the same value...

How to virtually delete data from multiple tables that are linked by a foreign key ?

I am using Sql Server 2005 This is a part of my database diagram. I want to perform deletion on my database which will start from tblDomain up tp tblSubTopics. Consider that each table has IsDeleted column which has to be marked true if request was made to delete data. But that data shoud remain their physically. Tables which will ...

Would this method work to scale out SQL queries?

I have a database containing a single huge table. At the moment a query can take anything from 10 to 20 minutes and I need that to go down to 10 seconds. I have spent months trying different products like GridSQL. GridSQL works fine, but is using its own parser which does not have all the needed features. I have also optimized my databas...

SQL column length query

i've been using the following query: select LEN(columnname) as columnmame from dbo.amu_datastaging This works, but is there a way to only return the greatest value instead of all the values? So if i return 1million records and the longest length is 400, the query would just return the value of 400? ...