sql

The most efficient way to move psql databases

What is the most efficient, secure way to pipe the contents of a postgresSQL database into a compressed tarfile, then copy to another machine? This would be used for localhosting development, or backing up to a remote server, using *nix based machines at both ends. ...

Transact-SQL to sum up elapsed time

I have a table in my database the records start and stop times for a specific task. Here is a sample of the data: Start Stop 9/15/2008 5:59:46 PM 9/15/2008 6:26:28 PM 9/15/2008 6:30:45 PM 9/15/2008 6:40:49 PM 9/16/2008 8:30:45 PM 9/15/2008 9:20:29 PM 9/16/2008 12:30:45 PM 12/31/9999 12:0...

Why wouldn't DB2 let me have a column in WHERE clause?

I have a remote DB2 database that I'm accessing through ODBC. When I have a query like SELECT t.foo, t.bar, t.problemcolumn FROM problemtable t WHERE t.bar < 60; it works like a charm, so the table and columns obviously exist. But if I specify the problem column in the WHERE clause SELECT t.foo, t.bar, t.problemcolumn FROM problemta...

Initialization Troubles with BIRT Runtime Engine API

Hi, I'm new to BIRT and I'm trying to make the Reprt engine running. I'm using the code snippets provided in http://www.eclipse.org/birt/phoenix/deploy/reportEngineAPI.php But I have a strange exception: java.lang.AssertionError at org.eclipse.birt.core.framework.Platform.startup(Platform.java:86) and nothing in the log file. May...

MySQL tools which ease creation of SQL JOIN statements?

Does anyone know tools which look at a MySQL database, show you all the tables graphically and allow you to create complicated JOIN statements via drag-and-drop? ...

How do I list the tables in a SQLite database file

What SQL can be used to list the tables, and the rows within those tables, in a SQLite database file once i've ATTACHed it on the sqlite3 command line tool? ...

Stored procedures or OR mappers?

Which is better? Or use and OR mapper with SP's? If you have a system with SP's already, is an OR mapper worth it? ...

Sort with one option forced to top of list

I have a PHP application that displays a list of options to a user. The list is generated from a simple query against SQL 2000. What I would like to do is have a specific option at the top of the list, and then have the remaining options sorted alphabetically. For example, here's the options if sorted alphabetically: Calgary Edmonton ...

Trip time calculation in relational databases?

I had this question in mind and since I just discovered this site I decided to post it here. Let's say I have a table with a timestamp and a state for a given "object" (generic meaning, not OOP object); is there an optimal way to calculate the time between a state and the next occurrence of another (or same) state (what I call a "trip")...

String list in SqlCommand through Parameters in C#

Hi folks, Working with a SqlCommand in C# I've created a query that contains a IN (list...) part in the where clause. Instead of looping through my string list generating the list I need for the query (dangerous if you think in sqlInjection). I thought that I could create a parameter like: SELECT blahblahblah WHERE blahblahblah IN @LIS...

SQL Select Upcoming Birthdays

I'm trying to write a stored procedure to select employees who have birthdays that are upcoming. SELECT * FROM Employees WHERE Birthday > @Today AND Birthday < @Today + @NumDays This will not work because the birth year is part of Birthday, so if my birthday was '09-18-1983' that will not fall between '09-18-2008' and '09-25-2008'. ...

How to update a field with random data?

I've got a new varchar(10) field in a database with 1000+ records. I'd like to update the table so I can have random data in the field. I'm looking for a SQL solution. I know I can use a cursor, but that seems inelegant. MS-SQL 2000,BTW ...

SQLBindParameter to prepare for SQLPutData using C++ and SQL Native Client

I'm trying to use SQLBindParameter to prepare my driver for input via SQLPutData. The field in the database is a TEXT field. My function is crafted based on MS's example here: http://msdn.microsoft.com/en-us/library/ms713824(VS.85).aspx. I've setup the environment, made the connection, and prepared my statement successfully but when I ...

Cross-Database information_schema Joins in SQL Server

I am attempting to provide a general solution for the migration of data from one schema version to another. A problem arises when the column data type from the source schema does not match that of the destination. I would like to create a query that will perform a preliminary compare on the columns data types to return which columns need...

Reuse of SQL stored procedures across applications

I'm curious about people's approaches to using stored procedures in a database that is accessed by many applications. Specifically, do you tend to keep different sets of stored procedures for each application, do you try to use a shared set, or do you do a mix? On the one hand, reuse of SPs allows for fewer changes when there is a model...

Keep pagination repeatable if change operations are performed

If one wants to paginate results from a data source that supports pagination we have to go to a process of: defining the page size - that is the number of results to show per page; fetch each page requested by the user using an offset = page number (0 based) * page size show the results of the fetched page. All this is works just fin...

I traced a Stored Procedure as shown in the SQL Server 2005 Profiler. It's not found but works. Why?

This is pretty weird. I have my Profiler open and it obviously shows that a stored procedure is called. I open the database and the SP list, but the SP doesn't exist. However, there's another SP whose name is the same except it has a prefix 'x' Is SQL Server 2005 mapping the SP name to a different one for security purposes? EDIT: I fo...

Best way to version control T-SQL?

What's the best way to version control my tables, views, sprocs, etc? Preferably automated or at least semi-automated :) Thanks ...

How can I return the content of an XML field as a recordset?

Say I've got this table (SQL Server 2005): Id => integer MyField => XML Id MyField 1 < Object>< Type>AAA< /Type>< Value>10< /Value>< /Object>< Object>< Type>BBB< /Type>20< /Value>< /Object> 2 < Object>< Type>AAA< /Type>< Value>15< /Value>< /Object> 3 < Object>< Type>AAA< /Type>< Value>20< /Value>< /Object>< Object>< Type>BBB< /T...

Migrating from MySQL to arbitrary standards-compliant SQL2003 server

Is there an incantation of mysqldump or a similar tool that will produce a piece of SQL2003 code to create and fill the same databases in an arbitrary SQL2003 compliant RDBMS? (The one I'm trying right now is MonetDB) ...