sql

Recommendations for SQL Server 2005 IntelliSense tools/add-ins?

I am your average Visual Studio .NET developer who has become dependent on Intellisense and Pre-compile syntax checking. I am looking for similar Intellisense functionality for MSSQL Server 2005 and T-SQL I was wondering what editors or add-ins people have had success with and would be happy to recommend. What key features do you use r...

String truncation error in Delphi DBExpress/Firebird paramatised queries

I have a query in Delphi using DBExpress TSQLQuery that looks like so ActiveSQL.sql.add('SELECT * FROM MYTABLE where MYFIELD=(:AMYFIELD) '); ActiveSQL.ParamByName('AMYFIELD').AsString := 'Some random string that is to long for the field'; ActiveSQL.Open; If I run it, when it executes the open command I get the following exceptio...

Retrieving data on separate sql servers

We have a situation where our application calls some stored procedures on a sql 2000 server. Now we must get some of the data from another sql 2000 box connected by a vpn. What would the syntax look like for performing CRUD operations from one sql server to another sql server? Both database servers are SQL 2000 and running Windows 2003...

Update in Oracle

I need to update the comments field in a table for a large list of customer_ids. The comment needs to be updated to include the existing comment and appending some text and the password which is in another table. I'm not quite sure how to do this. Here is some code that does this for a single customer id. How would I go about doing t...

SQL string formatter

Does anyone know of a program, a utility, or some programmatic library, preferably for Linux, that takes an unformatted SQL string and pretty prints it? For example I would like the following select * from users where name = 'Paul' be changed to something like this select * from users where name = 'Paul' The exact formatting i...

Why 'delete from table' takes a long time when 'truncate table' takes 0 time?

(I've tried this in MySql) I believe they're semantically equivalent. Why not identify this trivial case and speed it up? ...

Query three non-bisecting sets of data

I am retrieving three different sets of data (or what should be "unique" rows). In total, I expect 3 different unique sets of rows because I have to complete different operations on each set of data. I am, however, retrieving more rows than there are in total in the table, meaning that I must be retrieving duplicate rows somewhere. He...

SELECT FOR UPDATE for locked queries

I'm using MySql 5.x and in my environment, I have a table with the name CALLS. Table CALLS has a column status which takes an enum {inprogress, completed}. I want reads/updates of the table to be row-locked, so: SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; SET AUTOCOMMIT = 0; SELECT amount from CALLS where callId=1213 FOR UPDATE; COM...

How to do it in mysql: If id=idold THEN UPDATE status=1

Hi I would like to compare two tables and then update if some logic is true, In pseudo code: SELECT * FROM users, usersold IF users.id=usersold.id THEN UPDATE users.status=1; Is there a way to do it in mysql? ...

Stackoverflow's Related Questions

Just wondering how you would go about implementing something similar to stackoverflow'd related questions. Would you simply match the tags, match similar words in the titles, or words in the entire question? Particular interested in a linqtosql method. Cheers! ...

SQL query or sub-query?

I've got a table of student information in MySQL that looks like this (simplified): | age : int | city : text | name : text | ----------------------------------------------------- | | | | I wish to select all student names and ages within a given city, and also, per student, ho...

Converting an Oracle merge query into mysql mySQL query

MERGE INTO PAGEEDITCONTROL A USING (SELECT '1585' AS PAGEID ,'admin' AS EDITUSER ,sysdate AS EDITDATE FROM DUAL) B ON (A.PAGEID = B.PAGEID) WHEN MATCHED THEN UPDATE SET A.EDITUSER = B.EDITUSER ,A.EDITDATE = B.EDITDATE WHEN NOT MATCHED THEN INSERT ( ...

Sql cache dependency using EntLib caching block

how to implement sql cache dependency using Enterprise library application block? ...

Creating An Insert Statement -- Windows application Vb.Net

I am doing windows appliction in vb.net. i have customer object contains save method. how do i generate insert query? I need to save the object in relational database (SQL server). I need to know which is the correct way of doing the insertion ie,. Inside the save method i have written the SQL statement to save the object. Is it the cor...

How to query SQL Server table based on a specific date

I have a table in SQL Server 2005 which has three columns: id (int), message (text), timestamp (datetime) There is an index on timestamp and id. I am interested in doing a query which retrieves all messages for a given date, say '12/20/2008'. However I know that simply doing where timestamp='12/20/2008' won't give me the correct r...

How do you talk SQL directly to MySQL from Ruby?

I want to write a script in Ruby to clean up some messed up keys in several copies of the same MySQL schema. I'd like to do something like SHOW CREATE TABLE, then look at what comes back and delete keys if they exist. I know in the Rails environment you can do this... ActiveRecord::Base.connection.execute( some sql ) But what you get...

[SQL] What's the best way to get related data from their ID's in a single query?

I have a table where each row has a few fields that have ID's that relate to some other data from some other tables. Let's say it's called people, and each person has the ID of a city, state and country. So there will be three more tables, cities, states and countries where each has an ID and a name. When I'm selecting a person, what'...

SQL Inner Join syntax

Hi, the two bits of SQL below get the same result SELECT c.name, o.product FROM customer c, order o WHERE c.id = o.cust_id AND o.value = 150 SELECT c.name, o.product FROM customer c INNER JOIN order o on c.id = o.cust_id WHERE o.value = 150 I've seen both styles used as standard at different companies. From what I've se...

Help with recursive query

Hi, I've following problem, which I've not been able to do successfully. Your help will be appreciated. I'm using SQL 2005, and trying to do this using CTE. Table has following 2 columns DocNum DocEntry 1 234 2 324 2 746 3 876 3 764 4 100 4 3...

SQL in an e-mail app

I would like to be able to perform SQL queries on my e-mail inbox. With the output, I can make graphs about how much e-mails I send or receive for example. I want to analyze my performance and what keeps me busy. My mailbox seems like a good place to start. I'm using Gmail on-line, and Thunderbird, Outlook 2007 and Mail.app trough IMAP...