sql

unique pair in a "friendship" database

I'm posting this question which is somewhat a summary of my other question. I have two databases: 1) db_users. 2) db_friends. I stress that they're stored in separate databases on different servers and therefore no foreign keys can be used. In 'db_friends' I have the table 'tbl_friends' which has the following columns: - id_user - id_...

TableName using stored procedure in SQL

I have some problems to passing the @TableName inside a Nearby procedure to use in one StoreLocator. I need to get in 3 tables. I have tested using QUOTENAME but the problem is always here. Can someone help me to fix this problem. Thanks ALTER PROCEDURE [dbo].[GetNearbyTable] @Table sysname, @CenterLatitude FLOAT, @Cente...

How do I locate a file in a directory using PL/SQL?

Possible Duplicate: Using pl/sql how do I locate a file in a directory and move the file? How do I locate a file in a directory using PL/SQL? ...

Stored Procedure Problem

I have a problem with accessing output in the stored procedure below DbParameter DbParm = command.CreateParameter(); DbParm.Direction = ParameterDirection.Output; DbParm.ParameterName = "@SomeValue"; DbParm.DbType = DbType.Int32; DbParm.Value = null; command.Parameters.Add(DbParm); Afte...

Attaching arbitrary data to DirectoryInfo/FileInfo?

I have a site which is akin to SVN, but without the version control.. Users can upload and download to Projects, where each Project has a directory (with subdirs and files) on the server. What i'd like to do is attach further information to files, like who uploaded it, how many times its been downloaded, and so on. Is there a way to do t...

Can anyone recommend a tutorial for how to create and use an entity class in C# for VS 2008?

Can anyone recommend a tutorial for how to create and use an entity class in C# for VS 2008? Thanks! ...

return count 0 with mysql group by

database table like this ============================ = suburb_id | value = 1 | 2 = 1 | 3 = 2 | 4 = 3 | 5 query is SELECT COUNT(suburb_id) AS total, suburb_id FROM suburbs where suburb_id IN (1,2,3,4) GROUP BY suburb_id however, while I run this query, it doesn't give CO...

Does anyone see anything wrong with this? Mysql+PHP Error

I'm running the following line : mysql_query("INSERT INTO tags SET tag = '".$onesearch."', SET date = '".date('d-m-Y')."'") or die(mysql_error()); ...and its dieing saying this: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right synt...

How to intert image in SQLServer uing sql query without using parameters.

I am trying to insert image in my databse .However I dont want to use the parameters as my set up of coding pattern does not allow this.Is there a way out? I know that following code inserts the image byte[] imageData = ReadFile(txtImagePath.Text); SqlConnection CN = new SqlConnection(txtConnectionString.Text); string qry = "i...

Is TRUNCATE a DML statement?

Can we classify/say that TRUNCATE belongs to/falls under DML statement? Check here for PostgreSQL TRUNCATE compatibility. NOTE: TRUNCATE is part of SQL standard ANSI SQL 2008 - F200 ...

SQL - Updating a table, such that a column is summed given another column's key

Given a table: | id | price | item | total | | 0 | 1.0 | A | | | 1 | 1.0 | A | | | 2 | 0.1 | B | | | 3 | 1.0 | B | | | 4 | 2.1 | B | | | 5 | 1.0 | A | | | 6 | 2.0 | C | | is there an SQL statement that will lead to this ?. | id | price | item | tota...

multiple cluster indices effect

My question is about limitation of clustered index on a table. By theory, in a single table we can have only one cluster index. But what if I have datetime columns in a table say "From date" and "To date"? These columns will often required in WHERE clause to populate reports in my application. And if I also require a cluster index on pri...

What's the problem in the next sequence of Java/SQL code?

Hi! I made an update to a table in access via Java code, and it doesn't work. But, when I print to the console the result of executeUpdate(), it shows me 1, but in the database, no change. Can you tell me where's the problem, please? System.out.println("here"); PreparedStatement st = conn.prepareStatement( "UPDATE StocProduseCuFact...

Creating indexes for 'OR' operator in queries

I have some MySQL queries with conditions like where field1=val1 or field2=val2 and some like where fieldx=valx and fieldy=valy and (field1=val1 or field2=val2) How can I optimize these queries by creating indexes? My intuition is to create separate indexes for field1 and field2 for first query as it is an OR, so a composite index ...

What is ADO.NET

Hi, I puzzled with understanding ADO.NET, after reading several articles I do not have a clear idea what is all about. Please notice I am very new at developing. - What is ADO.NET? - ADO.NET could be associated with SQL STORED PROCEDURES or are different things? Thanks guys! ...

Issue in date comparison in MySQL

I have MySQL with below settings Server version: 5.0.77 MySQL client version: 5.0.41 Protocol version: 10 MySQL charset: UTF-8 Unicode (utf8) MySQL connection collation: utf8_unicode_ci I am just doing a simple query and it returned wrong SELECT * FROM table1 WHERE mydate >= '2010-08-30' Today is 8/30 and I have 1 row with mydate is '2...

Select query in SQL

I have a very curious question. We have query to select records from table based on some condition. In general the syntax for the query is as below SELECT * FROM TABLENAME WHERE COLUMNNAME='VALUE'; Now the question is that will this query will work if we interchange the position of COLUMNNAME and 'VALUE'. ...

Auto Increment userdefined id

Hi can anyone give me an idea how to create an auto generated id like ED01,ED02 etc., so that when i am entering data the id should be automatically incremented ...

How to drop all triggers in a Firebird 1.5 database

Hi For debug purposes I need to send 1 table of an existing Firebird 1.5 database to someone. In stead of sending the whole db , I want to send just the db with just this table - no triggers, no constraints. I can't copy the data to another db because it's just that that we want to check - why this one table is given troubles. I am ju...

Fetch only N rows at a time (MySQL)

I'm looking for a way to fetch all data from a huge table in smaller chunks. Please advise. ...