sql

Why can I select something out of left join on a NULL column?(with contrived example to reproduce it locally,probably a bug!)

VERSION I'm using Server version: 5.1.36-community-log MySQL Community Server (GPL) I've finally contrived a easy example to reproduce it easily! setup: create table t1(id integer unsigned,link integer unsigned); create table t2(id integer unsigned auto_increment,primary key(id)); create table t3(id integer unsigned,content varchar(30...

SQL SERVER 2005 Connectivity Problems

I am having a hell of a time trying to connect to the SQL SERVER 2005 database. I am using Windows 7. Here is the screenshot of the error thrown: I have been battling this issue for the past week and still no progress. I have tried the following in the server name: (local) localhost computername none of them worked! I just...

How to use MySQL index columns?

When do you use each MySQL index type? PRIMARY - Primary key columns? UNIQUE - Foreign keys? INDEX - ?? For really large tables, do indexed columns improve performance? ...

What is the difference between ";" and "GO" in TSQL (SQL 2008) ?

I use ADO.NET or the sqlcmd utility to send sql scripts to SQL 2008. What is the difference between using ";" and "GO" to separate chunks of SQL? Thanks, NEstor ...

MySQL query gone wild!?

Can anyone tell me why the following is happening, and how to fix it? I have a MySQL query with an ORDER BY clause that looks like this.. ORDER BY (did_voteup-did_votedown) DESC, did_voteup DESC So it should order the results by their "effective" rating, as in.. 1st. 10 up - 1 down = 9 effective 2nd. 10 up - 5 down = 5 effective 3rd...

SQL: Update on join, in standards?

I know that most sql server software allows you to do "A Update on a Join", but I am wondering, is this in the SQL standards? (eg. can I assume that any software package allows this?) Note: I am asking this because I am writing a database library that should be easily extensible to database software that is not included in the original ...

save (postgre) sql output to csv file

hi there, what is the easiest way to save PL/pgSQL output from a PostgreSQL database to a csv file? I'm using PostgreSQL 8.4 with pgAdmin III and psql plugin where I run queries from... thanks! martin ...

PostgreSQL and Sequential Data

I have a dataset that contains: Table { date itemName } The date for the most part is sequential. There are no duplicates of the date [as it is the primary key]. The question is split up into multiple parts (all with respect to using SQL): Is it possible to find gaps in the date series listed in the table? For example: Dates 1/2/09...

Oracle: Find previous record for a ranked list of forecasts

Hi I am faced with a difficult problem: I have a table (oracle 9i) of weather forecasts (many 100's of millions of records in size.) whose makeup looks like this: stationid forecastdate forecastinterval forecastcreated forecastvalue --------------------------------------------------------------------------------- varchar (...

Wildcards in GRANT statement?

The following does work as expected: GRANT ALL ON *.* to 'someuser'@'%' identified by 'somepass'; Can I use wildcards for Database name like: GRANT ALL ON someDB*.* to 'someuser'@'%' identified by 'somepass'; ...

Sql Server: storing text and keeping newlines?

Hi, I suppose this question is kinda easy to answer, but I can't seem to figure it out. I'm trying to store text (email bodies) into a nvarchar(max) column, but when I go read it, the newlines are all gone. At first I thought this might be some encoding/collation problem, but it doesn't seem to be the case. I've searched around and ha...

C# SQL Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.

I'm getting this error (Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.) when trying to run a stored procedure from C# on a SQL Server 2005 database. I'm not actively/purposefully using transactions or anything, which is what makes this error weird. I can run the stored proced...

How shall i get my friends of friends using mysql and PHP

Currently I am in need to find the friends of friends in my application using PHP and MYSQL For example : Database structure is like this. Table Name : tbl_friendlist Ident mem_id friend_id 1 2 1 2 1 2 3 1 3 1 4 1 5 1 8 How can i achieve this I am...

Mysql inner query not working

$sql= "select tblservergroup.id, tblservergroup.groupname, if(tblservergroup.defserverpaid='0', '0', select concat(tblservers.ipaddress, ' (', tblservers.name, ')' ) as defaultserverpaiddesc from tblservers where tblservers.id=tblservergroup.defserverpaid), if(tblservergroup.defserverfree='0', '0...

SQL Server: Retrieve the duplicate value in a column

Hi all, How could I filter out the duplicate value in a column with SQL syntax? Thanks. ...

Trim the ' (apostrophe) character in an sql statement

I'm using the DBMS_SQL package that returns the value '12345' as a value for a column name. How do you trim the apostrophes out from the value so that it could be converted into a number? ...

Problem with Rolling back a linq2sql insert transaction in C#

Hi, i am trying to insert the contents of a CSV file into a database table using linq2SQL. I want to be able to rollback the transaction if ANY of the inserts fail but when i try with this code i get the following error at - db.Transaction.Commit() System.InvalidOperationException was unhandled: This SqlTransaction has completed; it is...

MySQL "NOT IN" query

I wanted to run a simple query to throw up all the rows of Table1 where a principal column value is not present in a column in another table (Table2). I tried using: SELECT * FROM Table1 WHERE Table1.principal NOT IN Table2.principal This is instead throwing a syntax error. Google search led me to forums where people were saying that...

SQL Server 2000 DTS - Cannot resolve collation conflict for equal to operation.

I have a SQL Server 2000 DTS package. One of the steps of this package has the following SQL: SELECT * FROM [Crocus_Limited$OrderRequestDetail] WHERE (rep_updated > GETDATE() -2) AND NOT EXISTS (SELECT OrderID FROM NavisionUpgrade.navision4.dbo.[WEBOrderDetails] rd WHERE rd.OrderID = [Crocus_Limited$OrderRequestDetail].OrderID ...

MSAccess Insert with sub select wont work

Hi all. I have simple query, but when I'm trying to execute this query I'm getting error: Query input must contain at least one table or query. (Error 3067) Query: INSERT INTO FV_Ko ( FvId, OldPriceNetto ) SELECT [PFvId], (SELECT FV.PriceNetto1 FROM FV WHERE FV.FVnr = '123'); Thanks in advance ...