sql

How can I merge data within a DB table by a SQL statement?

I have an interesting problem for Interbase. I have a record set which amongst other things has a data entry field and a timestamp for each record. I would like to be able to copy the timestamp from records so that at the end of the day the final field will read along the lines of: TIMESTAMP <Carriage return> <carriage return> Origina...

SQL not equals & null

We'd like to write this query: select * from table where col1 != 'blah' and col2 = 'something' We want the query to include rows where col1 is null (and col2 = 'something'). Currently the query won't do this for the rows where col1 is null. Is the below query the best and fastest way? select * from table where (col1 != 'blah' or ...

SQL: filter on a combination of two column values

I have a table balances with the following columns: bank | account | date | amount I also have a table accounts that has bank and account as its composite primary key. I want to do a query like the following pseudocode: select date, sum(amount) as amount from balances where bank and account in (list of bank and account pairs) group...

System.InvalidOperationException: Transaction does not match connection. linq to sql

Any one ever seen this? It comes from a .net remoting endpoint hosted in IIS with a 16 process web garden. So there are many concurrent transactions in each thread pool per process. We are using linq to sql and the Transaction object that is from the DataContext, NOT the transactionScope object. It seems to happen either around the dispo...

Design Question - Put hundreds of Yes/No switches in columns, rows, or other?

We are porting an old application that used a hierarchical database to a relational web app, and are trying to figure out the best way to port configuration switches (Y/N values). Our old system had 256 distinct switches (per client) that were each stored as a bit in one of 8 32-bit data fields. Each client would typically have ~100 ...

how to access table across multiple data server

I have two Sysbase servers , server1 and server2 . I have a stored procedure declared and running on server1. In that SP i want to access table from server2. How can i do that? Also my both instances are running in a UNIX box ...

SQL: How to SELECT tablename.*

Hi, I tried doing this but it failed. SELECT table2.ID, table1.* FROM table2 LEFT JOIN table1 ON table1.ID = table2.table1ID How do you select all columns from a table? EDIT: There is no error in the above query. I don't know what caused the error but the code is now working. ...

MSSQL Server - get a whole part of a decimal value in the computed column

Here's my simplified table (SQL Server 2005): table1: col1 int, col2 int, col3 cast(col1/col2 as int) [computed column] for some reason the above doesn't work. i just want to save a WHOLE part of col1/col2, how do i do that? example: col1 = 5, col2 = 3 ... col3 should be 1 ...

Mysql::Error: Subquery returns more than 1 row:

In my rails app, I am running a sql query using find_by_sql() since I need subqueries. This works if I do either the first or second query but when I add them together with the AND, it starts complaining about more than 1 row in subquery. I want all rows (records) returned that match the criteria. What needs to be fixed/changes here? W...

Constraint for only one record marked as default.

How could I set a constraint on a table so that only one of the records has its isDefault bit field set to 1? The constraint is not table scope, but one default per set of rows, specified by a FormID. ...

selecting subsequent records arbitrarily with limit

I want to do a query to retrieve the record immediately after a record for any given record, in a result set ordered by list. I do not understand how to make use of the limit keyword in sql syntax to do this. I can use WHERE primarykey = number, but how will limiting the result help when I will only have one result? How would I obtain ...

In SQL how can I convert a money datatype to a decimal?

I want to convert a money datatype to a decimal, because I want to record the results to 8 decimal places. For example, in a currency rate table I see the rate stored as 2871047428.20 as a money datatype; using Microsoft SQL Management Studio, I want to divide that by 10000000 in order to achieve the result 287.10474282; however the res...

How do I join two tables ON a column, that has the same name in both tables?

see above... ...

Paging depending on grouping of items in Django

For a website implemented in Django/Python we have the following requirement: On a view page there are 15 messages per web paging shown. When there are more two or more messages from the same source, that follow each other on the view, they should be grouped together. Maybe not clear, but with the following exemple it might be: An ex...

MySQL - How do I order the results randomly inside a column?

I need to retrieve rows from a table (i.e: 'orders') ordered by a column (lets say 'user') randomly. That is, I need all orders from the same user to remain together (one after the other) and users to be ordered randomly. ...

Public ASP.NET Application Security Considerations

An extremely secure ASP.NET application is having to be written at my work and instead of trawling through the Internet looking for best practices I was wondering as to what considerations and generally what things should be done to ensure a public web application is safe. Of course we've taken into consideration user/pass combinations ...

SQL query to calculate correct leadtime in table (MS Access)

Hi, I have the following table: log(productId, status, statusDate, department...), where productId, status and statusDate is the primary key. Example: id1 01 01/01/2009 id1 02 02/01/2009 id1 03 03/01/2009 id1 01 06/01/2009 id1 02 07/01/2009 id1 03 09/01/2009 id2 01 02/01/2009 id2 02 03/01/2009 id2 01 04/01/2009 id2 03 06/01/2009 id3 01 0...

SSIS Derived Column Missing Downstream

I've created a derived column that translates a 1 to an 'M' and a 2 to 'F'. i.e. a gender indicator. The derived column feeds into a Fuzzy Lookup transformation and then to a conditional split. The problem is the derived field does not show up in any of the downstream components. In the Fuzzy Lookup transform the "Pass Through" check...

SQL query: put values of an attribute as columns

I have a table errors(errorId, category, eDate). I am trying to show as result the number of errors per week and categories. The query result should be something like: Week Category1 Category2 01 2 5 02 0 20 ...

Content Management - ASP.NET Recommendations

Build vs. Buy... We've all been down this road... It seems like content management solutions need to be a tool that you keep inside the toolbox for some quick wins and they are only getting better. I could certainly look at building one, but by the time you get all the bells and whistles in there, it would have been cheaper to get one...