sql

Convert SQL - LINQ - Problem with using both Min/Max

Hello all, Is there a online system which converts SQL - LINQ or can anyone else help convert the SQL - LINQ below? SELECT MIN(startTime) As startTime, MAX(endTime) As endTime FROM tblRA LEFT JOIN tblA ON tblRA.asID = tblA.asID WHERE 'xxxxxx' BETWEEN tblRA.startDate AND tblRA.endDate AND tblA.availabilityDayOfWeek = 7 The main area I...

In Oracle, what is the SQL to query for occurences of line feed?

I need to find the rows where a certain column contains line feed. This does not work: select * from [table] where [column] like '%\n%' In SO, I found the solution for SQL Server: http://stackoverflow.com/questions/1085662/new-line-in-sql-query But this does not work in Oracle. Is there any ANSI SQL solution? This should be a standard...

How to create a dynamic query using EOD SQL?

Hello guys. This should be fairly simple, though I can't seem to find a single example. I want to create a query looking like this: SELECT column_name FROM table_name WHERE column_name IN (value1,value2,...) As an option I could append OR-clauses to the end of the query. The code I have written so far keeps blowing up with a Nullpoi...

MySQL: Suggesting objects (optimizing a multi-join query)

Goal: Suggest objects based on user's choices Data: Table containing info on how users would order a subset of objects from the worst to the best; Example: 1 2 3 4 5 6 John: A B G J S O Mary: A C G L Joan: B C L J K Stan: G J C L There's about 20 times as many users as objects, every user's lineup contains 5...

SQLServer: How to pair up ordered data for sequences of arbitrary (and unequal length)?

Here's my scenario: I have two tables A, B which (for the sake of this question are identical): Table X (PK) ID 1 2 Table A: ID FKID Value Sort 1 1 a 1 2 1 aa 2 3 1 aaa 3 4 2 aaaa 1 5 2 aaaaa 2 Table B: ID FKID Value Sort 1 1 b 1 2 1 bb 2 3 2 bbb 1 4 2 bbbb 2 5 2 bbbbb ...

SQL Expressions in Crystal Reports

I am not at all familiar with SQL expressions and was hoping to get some help I have this: "Reservations"."NY IT Services/Computer Presentation" which is a boolean How would i write this to say "If "Reservations"."NY IT Services/Computer Presentation" is a 1, then display, else do not display? I need to do this in Crystal Reports and ...

Re-Sequence a set of data in SQL Server

I have a table of values like this: CREATE TABLE ( Name1 VARCHAR (50), Name2 VARCHAR (50), Sequence INT ) In this table I have rows like this 'Bob', 'Jones', 1 'James','Ant', 2 I want the best way to UPDATE (UPDATE SET) sequence based on the order of say the Name2 column, so when re-sequenced the values are: 'James','...

PHP help with building query

I have several drop lists where if no option is selected then the value is = ""... I cant figure out how to build the query for mysql in PHP. query = SELECT * FROM db ...

SQL Looping through results

I do a select and it brings back a list of IDs. I then want to call another procedure for each ID that calculates a result, so I end up with a list of results. How can I do this? I need some kind of loop but I am not very good at SQL. Edit: Microsoft SQL 2008, and purely in SQL ...

SQL Search in Ruby

Ok, this seems like a duplicate question to this: http://stackoverflow.com/questions/1545893/sql-super-search but it's a different approach. Before I was looking for a lean and efficient way to do this entirely on the database side, but now I was wondering if anyone knoew how to do something like this in Ruby. I've tried this, and while...

How to speed up query with multiple INNER JOINs

I've been toying around with switching from ms-access files to SQLite files for my simple database needs; for the usual reasons: smaller file size, less overhead, open source, etc. One thing that is preventing me from making the switch is what seems to be a lack of speed in SQLite. For simple SELECT queries, SQLite seems to perform as ...

RegEx for not matching items in a quote

So I am trying to figure out a Regular Expression and am having some issues. What I want to find (match) is all of the SQL parameters in a large script file, but NOT match items in single quotes (such as email addresses). For example: INSERT INTO [User] ( [UserGuid], [CompanyGuid], [Name], [EmailAddress] ) VALUES ( @UserGuid1, @C...

Unneeded MySQL indices

We have one of our tables in our database that is starting to be pretty big : 10M rows 2.14G for data 3.55G for indices I was pretty surprised to see that the indices are almost twice as big as the data itself :/ So I showed the indices : show index from entries; +---------+------------+----------------------------------------+-------...

Functions in SQL Server 2008

Does sql server cache the execution plan of functions? ...

Control flow in T-SQL SP using IF..ELSE IF - are there other ways?

I need to branch my T-SQL stored procedure (MS SQL 2008) control flow to a number of directions: CREATE PROCEDURE [fooBar] @inputParam INT AS BEGIN IF @inputParam = 1 BEGIN ... END ELSE IF @inputParam = 3 BEGIN ... END ELSE IF @inputParam = 3 BEGIN ... END END Is there any other ways? For example, in C...

How do I determine if I have execute permissions on a DB programatically?

I have a Windows Service that requires execute permissions on a DB. On start up I check to see if I can connect to the DB and stop the service if I can't. I also want to do a check to see if I can execute a stored procedure using that connection. Is there a way to do that without actually attempting to execute a sproc and looking at the ...

Fastest way to count total number and then list a set of records in MySQL

I have a SQL statement to select results from a table. I need to know the total number of records found, and then list a sub-set of them (pagination). Normally, I would make 2 SQL calls: one for counting the total number of records (using COUNT), the other for returning the sub-set (using LIMIT). But, this way, you are really du...

Will I run into performance issues if I use a blob field as primary key in SQLite?

I have a sqlite database where all the primary keys are GUIDs. Currently they are stored as fixed length strings but I want to store them as blobs because it simplifies the code for storing and retrieving data. I converted part of the database and everything is functioning as expected. However, I'm not sure if I will run into performa...

uncommitted reads?

I was looking at potential concurrency issues in DB so i went to read up. I found http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/admin/c0005267.htm and it mentions access to uncommitted data. Access to uncommitted data. Application A might update a value in the database, and application B ...

SQL Server dynamic column list in contains function

I have a database table in SQL Server 2008 with 5 nvarchar(max) columns. We're using the CONTAINS function to look for text in these columns. We can look in all five columns using this kind of query: SELECT * FROM SomeTable ST WHERE CONTAINS( (ST.ColumnA, ST.ColumnB, ST.ColumnC, ST.ColumnD, ST.ColumnE) , '"Strawberry"') Now we want ...