sql

make server name as a variable

I am trying to get data from different sever, and the sever name might change. So I set the server name as a parameter. The idea of my sql store procedure is something like this CREATE PROCEDURE [dbo].[GetData] @ServerName AS BEGIN SELECT * FROM @ServerName.ClientDataBase.dbo.Client END Does anyone know how to achieve this...

operator precedence in mysql

Which operator: / or * will have the higher priority in MySQL? ...

Modeling Tools that understand both Relational and LDAP

I am looking to do some modeling and would like to have a tool that can capture not only a relational model like ERWIN but also allow us to easily port to LDAP as an option. NOTE: Visio can connect to an existing LDAP server and draw, but does not allow for you to model first and then deploy, unlike its relational capabilities. ...

Standard SQL Query much faster than Linq 2 SQL

Hey there I got a problem with my code, I compared three ways of implementing a query on a database Standard SQL Query (From * Select ...) LinQ Query Precompiled LinqQuery (CompiledQuery) Now the result I got is that the Precompiled LingQuery is 5 times faster than the LinQ Query but much more interesting ist that the Standard SQL Q...

getBytes vs getBinaryStream vs getBlob for getting data out of a BLOB column

There are 3 different ways to get data out of a Blob column: getBytes getBinaryStream getBlob Also, the Blob object returned by getBlob also has a getBytes and getBinaryStream on it. Are there any particular reasons (performance, memory, database specific problems) that I should pick one over the other? The Blob object also has a fre...

How to do a Select in a Select

I have a table containing a unique ID field. Another field (REF) contains a reference to another dataset's ID field. Now I have to select all datasets where REF points to a dataset that doesn't exist. SELECT * FROM table WHERE ("no dataset with ID=REF exists") How can I do this? ...

What's the best method to stop duplicate inserts into the database

I have a forum application using asp.net, c#, sql server and linq to sql. It suffers from multiple inserts, I think when the insert button is pressed but also maybe when the browser is refreshed or back is clicked. What's the most comprehensive way, or ways to prevent this. UPDATE: I currently use response.redirect after inserting text...

SQL Query Help

Duplicate: How to do a Select in a Select I have 2 tables: TABLE1 Table1Id TABLE2 Table2Id Table1Id UserId TABLE2 has thousands of entries in it. I want to return a list of TABLE1 entries where there isn't an entry in TABLE2 for it for a particular user. So, where there isn't a foreign key entry in TABLE2. A query like: select...

How does the IN predicate work in SQL?

After prepairing an answer for this question I found I couldn't verify my answer. In my first programming job I was told that a query within the IN () predicate gets executed for every row contained in the parent query, and therefore using IN should be avoided. For example, given the query: SELECT count(*) FROM Table1 WHERE Table1Id N...

Tool to migrate data between different DBMS?

There are some tool (free preferentially) to to migrate data between different DBMS (like from MySql to Firebird, or Sql Server to Sqlite, etc)? Edit: I want specifically to migrate from "Firebird Embed" to "Sqlite". But in another situations (like migration of my customers websites) I need migrate from MySql to Sql Server (and vice-ver...

DB2Command ExecuteNonQuery Insert multiple rows problem

I'm attempting to insert multiple rows into a DB2 database using C# code like this: string query = "INSERT INTO TESTDB2.RG_Table (V,E,L,N,Q,B,S,P) values" + "('lkjlkj', 'iouoiu', '2009-03-27 12:01:19', 'nnne', 'sdfdf', NULL, NULL, NULL)," + "('lkjlk2', 'iuoiu2', '2009-03-27 12:01:19', 'nnne2', 'sddf2', NULL, NULL, NULL)"; DB2Command cm...

Mixing implicit and explicit JOINs

I am having a problem with Hibernate generating invalid SQL. Specifically, mixing and matching implicit and explicit joins. This seems to be an open bug. However, I'm not sure why this is invalid SQL. I have come up with a small toy example that generates the same syntax exception. Schema CREATE TABLE Employee ( employeeID INT, name...

Can PostgreSQL select from an array returned by a function?

This query fails: SELECT xpath('/my/xpath/expr', my_xml)[1] FROM my_table ERROR: syntax error at or near "[" But this one works: SELECT x[1] FROM (SELECT xpath('/my/xpath/expr', my_xml) as x FROM my_table) as ss My xpath expression always returns only a single value, but the Postgres xpath function returns an array. I want t...

How can I check for average concurrent events in a SQL table based on the date, time and duration of the events?

I have a set of call detail records, and from those records, I'm supposed to determine the average concurrent active calls per system, per hour (at a precision of one minute). If I query 7pm to 8pm, I should see the average concurrent calls for the hour (averaging the concurrent calls for each minute) within that hour (for each system). ...

Best Way to Handle SQL Parameters?

This is really a VB.NET/C# question. Ok, so I essentially have a database layer that is totally isolated from any business logic. This means that whenever I get ready to commit some business data to a database, I have to pass all of the business properties into the data method's parameter. For example: Public Function Commit(foo as o...

problem with SQL statement in high score database

I have created a letter game in java and i need to include a high score function into it. Using Microsoft access database through JDBC. The table in the database contains the following Table name Easy fields Name Score Time In need an SQL statement that displays the top 5 scores in the order highest score and lowest time. eg. if the...

Introduction to database interaction with C#

Up to now in my programming career (two years) I have not had much database experience, but the company where I now work uses databases extensively for their product, and I feel behind the curve. So I would like to know how best to start learning database interaction with C#. I've read about LINQ-to-SQL and ADO.net. Are these the right ...

Access query (SQL) to return records sorted (grouped by) WEEKS

Greetings SQL gurus, I don't know if you can help me, but I will try. I have several large databases grouped by year (each year in a different database). I want to be able to compare values from a particular week from one year to the next. For example, "show me week 17 of 2008 vs. week 17 of 2002." I have the following definition of w...

How do I Insert values into a Microsoft Access Database through JDBC?

I have created a letter game in Java and I need to include a high score function in it using a Microsoft Access database through JDBC. The table in the database contains the following fields Table Name: Scores Name (Text) Difficulty (Text) Characters (Number) Accuracy (Text) Time (Text) Score (Text) I need a SQL st...

MySql: Selecting from multiple tables

Hello guys, i dont know how to go about this but i need urgent assistance from you guys. I have two tables namely States, Package_Details. Below are the details of the table. States state_id state_name Package_Details id sender_state //Stores state with state ID receiver_state //Stores state with state ID ...