sql

ODBC Connection String Problem

Hi there, I am having major trouble connecting to my database via ODBC. The db is local (but I have a mirror on a virtual machine), so I am trying to use the connectionstring: Dsn=MonetDB;host=TARBELL where TARBELL is the name of my computer. However, it doesn't connect. BUT, this string does: Dsn=MonetDB;host=localhost ...

Get most left|right|top|bottom point contained in box

I'm storing Points Of Interest (POI) in PostgreSQL database, and retrieve them via PHP script to Android application. To reduce internet usage I want my mobile app to know if there are any points in the neighborhood of currently displayed area. My idea is to store bounds of the rectangle containing all points already retrieved (in other...

to_date in SQL Server 2005

Does any one know how I would have to change the following to work with ms sql? WHERE registrationDate between to_date ('2003/01/01', 'yyyy/mm/dd') AND to_date ('2003/12/31', 'yyyy/mm/dd'); What I have read implies I would have to construct it using DATEPART() which could become very long winded. Especially when the goal would be to c...

SQL Stored Queries - use result of query as boolean based on existence of records

Just getting into SQL stored queries right now... anyway, here's my database schema (simplified for YOUR convenience): member ------ id INT PK board ------ id INT PK officer ------ id INT PK If you're into OOP, Officer Inherits Board Inherits Member. In other words, if someone is listed on the officer table, s/he is listed on the b...

Excel VBA to Update SQL Table

Hi All, I have a small excel program that is use to upload data to an SQL server. This has been working well for a while. My problem now is that I would like to offer to users a function to update an existing record in SQL. As each row on this table has a unique id columne. There is a column call UID which is the primary key. This ...

SQL - Finding continuous entries of a given size.

I am working on a system for reserving seats. A user inputs how many seats they wish to reserve and the database will return a set of suggested seats that are not previously reserved that matches the number of seats being reserved. For instance if I had the table: SeatID | Reserved ----------------- 1 | false 2 | true 3 ...

Alter Sql table (Change foreign key to Second primary of the table)

Hi, I've a sql table with a primary key(Auto Incremented) and a foreign key.Now I need to modify the table by modifying the foreign key to second primary key so that its values are not allowed to duplicate. How do i alter my table without affecting the data? Need the sql code. Regards, Vix ...

Boolean data type size and want to print its value?

I want to know size of data type boolean , i used VSIZE() function but it is not working for boolean and Want to print and store boolean value into table. Please let me know how oracle store boolean value ,is there any other way to see data type and value for boolean variable. Atleast tell me size of boolean i got this error when I ...

what really are database Constraints?

What really is constraints? Why i need to know about them? What are the types of constraints? ...

moving to NoSql

Hi , I recently read this article nosql-vs-rdbms and I don't know too much about nosql and I didn't use it in my projects, so I have some questions: What is the main feature that nosql has over RDBMSs? If you think that it is better than RDBMSs : Where and how can I learn about it (books - tutorials)? I want to be a DBA. What this car...

Best practices or tools for installing a SQL Server database

Best practices or tools for installing a SQL Server database I have a SQL Server database designed with the SQL Server GUI database editor/Visual Studio. What is the best way to "install" that database on other systems. Said another way how should I ship this thing? I know I can save the scripts and set the primary/foreign keys with T...

Rails more statements with ; doesnt work... :s

I have this code, but i cant make it work: images = Image.find_by_sql('PREPARE stmt FROM \' SELECT * FROM images AS i WHERE i.on_id = 1 AND i.on_type = "profile" ORDER BY i.updated_at LIMIT ?, 6\'; SET @lower_limit := ((5 DIV 6) * 6); EXECUTE stmt USING @lower_limit;') I got this error: Mysql::Error: You have an error in your SQL sy...

sql rounding value

I have been successful at rounding my value to one decimal point, but I would like to trim off the multitude of trailing zeros. For example, this: ROUND(SUM(Duration),1) ...ends up giving me: 16.9000000000000000 how do I trim all those trailing zeros. mssql ...

How to select parent row only if has at least one child?

I have a simple one-to-many relationship. I would like to select rows from the parent only when they have at least one child. So, if there are no children, then the parent row is not returned in the result set. Eg. Parent: +--+---------+ |id| text | +--+---------+ | 1| Blah | | 2| Blah2 | | 3| Blah3 | +--+---------+ Childre...

Return number of rows affected by SQL UPDATE statement in Java

I'm using a MySQL database and accessing it through Java. PreparedStatement prep1 = this.connection.prepareStatement("UPDATE user_table SET Level = 'Super' WHERE Username = ?"); prep1.setString(1, username); ...

Apache Derby supports natively script delimiters?

Hello, I know that I could separate all statements by pre-cutting before their execution, but I have a case in which I would like to insert a series of statements in one execution, currently I receive the following error: Caused by: java.sql.SQLException: Syntax Error: Encountered ";" at line 2, column 33. at org.apache.derby.impl.j...

MySQL: Order by field size/length

Here is a table structure (e.g. test): __________________________________________ | Field Name | Data Type | |________________|_________________________| | id | BIGINT (20) | |________________|_________________________| | ti...

Select Top N Records Ordered by X, But Have Results in Reverse Order

I'm trying to get the top N records (when ordered by some column X), but have the result set in reverse order. The following statement is incorrect, but probably demonstrates what I'm after: SELECT * FROM (SELECT TOP 10 * FROM FooTable ORDER BY X DESC) ORDER BY X ASC For example, column X could be an ID or a timestamp; I want the late...

Mysql Syntax Error

Any idea why this is popping up :( ? You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TABLE `clocks` ( `id` int(11) NOT NULL AUTO_INCREMENT, ' at line 6 ** Here is the query ** CREATE TABLE `clients` ( `id` int(11) N...

SQL Server Concatenate string column value to 5 char long

Scenario: I have a table1(col1 char(5)); A value in table1 may '001' or '01' or '1'. Requirement: Whatever value in col1, I need to retrive it in 5 char length concatenate with leading '0' to make it 5 char long. Technique I applied: select right(('00000' + col1),5) from table1; I didn't see any reason, why it doesn't work? but i...