sql

What are the problems of using transactions in a database?

From this post. One obvious problem is scalability/performance. What are the other problems that transactions use will provoke? Could you say there are two sets of problems, one for long running transactions and one for short running ones? If yes, how would you define them? EDIT: Deadlock is another problem, but data inconsistency migh...

How do you do fuzzy searches using bound parameters in PDO?

Trying to do this sort of thing... WHERE username LIKE '%$str%' ...but using bound parameters to prepared statements in PDO. e.g.: $query = $db->prepare("select * from comments where comment like :search"); $query->bindParam(':search', $str); $query->execute(); I've tried numerous permutations of single quotes and % signs and it's ...

Getting random row through SQLAlchemy

How do I select a(or some) random row(s) from a table using SQLAlchemy? ...

SQL Select Bottom Records

I have a query where I wish to retrieve the oldest X records. At present my query is something like the following: SELECT Id, Title, Comments, CreatedDate FROM MyTable WHERE CreatedDate > @OlderThanDate ORDER BY CreatedDate DESC I know that normally I would remove the 'DESC' keyword to switch the order of the records, however in this...

Priority of a query in MS SQL

Is there a way to tell MS SQL that a query is not too important and that it can (and should) take it's time? Likewise is there a way to tell MS SQL that it should give higher priority to a query? ...

How do you create a database from an EDM?

How do you create a database from an Entity Data Model. So I created a database using the EDM Designer in VisualStudio 2008, and now I want to generate the SQL Server Schema to create storage in SQL Server. ...

How to check if a value exists in SQL table

I've got a table of URL's and I don't want any duplicate URL's. How do I check to see if a given URL is already in the table using PHP/MySQL? ...

What is a Covered Index?

I've just heard the term covered index in some database discussion - what does it mean? ...

reload a .sql schema without restarting mysqld

Is it possible to reload a schema file without having to restart mysqld? I am working in just one db in a sea of many and would like to have my changes refreshed without doing a cold-restart. ...

Best way of constructing dynamic sql queries in C#/.NET3.5?

Hello, A project I'm working on at the moment involves refactoring a C# Com Object which serves as a database access layer to some Sql 2005 databases. The author of the existent code has built all the sql queries manually using a string and many if-statements to construct the fairly complex sql statement (~10 joins, >10 sub selects, ~1...

C# SQL Restore database to default data location

I'm writing a C# application which downloads a compressed database backup via FTP. The application then needs to extract the backup and restore it to the default database location. Since I won't know what version of SQL will be installed on the machine where the application runs, I need to be able to find the default location based on ...

How do you perform an IF...THEN in a SQL SELECT

I want to be able to perform a IF...THEN in an SQL SELECT Statement. For Example; SELECT IF(Obsolete = 'N' or InStock = 'Y';1;0) as Salable, * FROM Product ...

What databases do I have permissions on

How can I find what databases I have a minimum of read access to in either basic SQL, MySQL specific or in PHP? ...

How do I show data in the header of a SQL 2005 Reporting Services report?

Out of the box SSRS reports cannot have data exposed in the page header. Is there a way to get this data to show? ...

How to replace a character programatically in Oracle 8.x series

Due to repetitive errors with one of our Java applications: Engine engine_0: Error in application action. org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x13) was found in the element content of the document. I need to "fix" some Unicode character in an Oracle database, ideally in a programmatic fashion. Once identi...

Is it possible to select from "show tables" in MySQL?

Well, yes, the title says it all. SELECT * FROM (SHOW TABLES) AS my_tables Something along these lines, though the above does not work (on 5.0.51a, at least). ...

SQL Server 2005 How Create a Unique Constraint?

How do I create a unique constraint on an existing table in SQL Server 2005? I am looking for both the TSQL and how to do it in the Database Diagram. ...

IsNull function in DB2 SQL?

Is there a performant equivalent to the isnull function for DB2? Imagine some of our products are internal, so they don't have names: Select product.id, isnull(product.name, "Internal) From product Might return: 1 Socks 2 Shoes 3 Internal 4 Pants ...

Linked List in SQL

Whats the best way to store a linked list in a mysql database so that inserts are simple (i.e. you dont have to reindex a bunch of stuff every time) and such that the list can easily be pulled out in order. ...

Which is faster/best? SELECT * or SELECT column1, colum2, column3, etc.

I've heard that SELECT * is generally bad practice to use when writing SQL commands because it is more efficient to SELECT columns you specifically need. If I need to SELECT every column in a table, should I use SELECT * or SELECT column1, colum2, column3, etc. Does the efficiency really matter in this case? I'd think SELECT * would be...