sql

why do i need left outer join if i have right outer join ?

Possible Duplicate: When or why would you use a right outer join instead of left? What ever the functionality i get with left outer join i can get it by interchanging table names.Then, what is the need for having two outer joins ( left and right) ? If there is any specific need can some body explain with an example ? ...

TSQL Computed column limitations

CREATE TABLE [dbo].[MembershipModule]( [Id] [uniqueidentifier] ROWGUIDCOL NOT NULL, [ParentId] [uniqueidentifier] NULL, [TargetId] [int] NULL, [WebContentId] [uniqueidentifier] NULL, [Name] [varchar](35) NOT NULL, [NameUpper] AS (isnull(upper([Name]),'')) PERSISTED NOT NULL, [UriPrefix] [varchar](max) NULL, [UriText] [varchar](...

Finding the hash value of a row in postgresql

Hi, Is there a way to get the hash code of a row in postgresql? I need to export some data only if there is some changes in the data after the last export, the last exported data rows can be stored in a table, the when the again I need to export the data I can get the hash values of all the data and export only those rows who has a d...

Timezone offsets (and st/dst changes) in MySQL / PHP

Basically I have a site that allows stores to store their open/close times. Now, I'm trying to add the feature of giving their visitors the ability to see if the store is closed. I understand I can run a query like: SELECT * FROM `store_hours` WHERE TIME(NOW()) BETWEEN `opens` AND `closes` ... and the query works and retrieves the s...

Can Sphinx be configured to give more weight to certain fields?

Hey, so I'm wondering if it's possible for Sphinx to weight certain fields of document over others in its results. For example, if I did a search for 'the rock show', is it possible to configure sphinx to give much higher precedence to a song named 'the rock show' over a song which has 'the rock show' in its lyrics? ...

delete from table1,table2,table3 where?

Hi there, If all tables I want to delete from have the column gamer_id can i do a delete from table1, table2, table3 where gamer_id = 123? or is there a different syntax? ...

80 3 column rows, or 1 81 column rows

Hi there, I Have some data to store, I must store this data for every user, The data is more or less key: 0 value: 107, key: 1 value 213 There are about 80 key/value sets per user So my question is, Do I have one row that is basically user_id key1, key2... key80 or do I have 80 rows of user_id, key, value Data I must ...

Replace String in Oracle Procedure

I have a problem about oracle procedure,since I'm new in sql language :D, here is my query CREATE OR REPLACE PROCEDURE MONDESINT.UPDATECOADESCRIPTION IS DESCRIPT MONDES_MSTR_CHART_OF_ACCOUNT.NAMA_AKUN%type; BEGIN FOR SATU IN (select NO_AKUN, NAMA_AKUN from mondes_mstr_chart_of_account where NO_A...

Table variable vs temp table in SQL Server 2008

Possible Duplicate: What's the difference between a temp table and table variable in SQL Server? What is the difference between table variable and temp table, actually I have two question on it. how to decide when to use what? which one is better in performance and WHY ? ...

Using the result of an Stored procedure in a Select statement

i have an stored procedure wich return a Dataset(Table) how i can use the result of this stored procedure in a select statement? i need something like this Select T1.* from Dummy T0 INNER JOIN (EXEC [dbo].[SPGetResults] '900',300,'USD') T1 ON T1.aKey=T0.aKey i ' am using sql server 2005 ...

Why does column = NULL return no rows?

Possible Duplicate: Why does NULL = NULL evaluate to false in SQL server If you generate a query to insert the data in table "MyTab" for column --- Age, Sex, DOB, ID INSERT INTO MyTab VALUES (22, '', '', 4) What'll be the value in column Sex & DOB ? Is it NULL ? If value is NULL then --- SELECT * FROM MyTab WHERE Sex=...

How to rewrite a subquery to use joins when you used DISTINCT in the subquery?

I have a query where I use a sub query, and I would like to rewrite into a join, to have better performance. The subquery uses DISTINCT as there are many records, and the problem I have is that they end up multiple times in the join when I use the join. So how do I rewrite a query like this to use join: SELECT * FROM table1 a ...

Convert SQl 2008 SSIS dtsx package to SQl 2005 format

Anybody knows how, if at all, can I convert an SSIS package created in VS 2008, for SQl 2008, to be loaded in VS 2005, for SQl 2005? It is a simple file copy and looping package. No fancy stuff in it. ...

How I can use a function which returns a table in a select statement with an inner join?

I need to use a function which returns a table, in a inner join sentence passing a parameter. When executed, the sentence like this is not working. SELECT T0.Code,T0.Data1,T0,Data2 FROM [dbo].[FNGet_Data] (T1.Code,'2010-01','USD') T0 INNER JOIN Codes T1 ON T1.Code=T0.Code When executed the sentence using a constant parameter works...

Help with SQL Server query

I have table that contain name and date. I need to count how many names I have in a one day, and make average to all days. How to do it? Thanks in advance ...

NullReferenceException in MySqlClient.NativeDriver

I have a long running program that exectues some mySQL-Queries every 5 minutes (timed thread). After it has run for approximately 10 hours a NullReferenceException is thrown with the following stacktrace: at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int32& insertedId) bei MySql.Data.MySqlClient.Driver.GetResul...

Help Building SQL query

Hi all. I have following 2 tables Channels: Id int PK Title varchar SubChannels: ChannelId int SubchannelId int When I receive data from service I'm trying to persist it to SQL. I receive a few Channel instance, so I store it in Channels table, after that I'm trying to persist every subchannel (every channel contains list of subchann...

Optimize a simple JOIN or IN query

I have this query: SELECT DISTINCT id, label FROM bbproduct_cust WHERE CUSTNO IN (SELECT CUSTNO FROM customer WHERE SLSRPTGRP = '1996') AND DEPTNO = '0' ORDER BY label ASC EXPLAIN shows id select_type table type possible_keys key ...

How to pass a record as parameter for PL/pgSQL function ?

I keep looking for this answer online but I cannot find it. I am trying to pass one record over a PL/pgSQL function. I tried it in two ways. Fist way : CREATE OR REPLACE FUNCTION translateToReadableDate(mRecord dim_date%ROWTYPE) RETURNS void AS $$ That is the ouput : psql:requestExample.sql:21: ERROR: syntax error at or near "%" L...

String concatenation issue in CTE SQL

I have the following CTE SQL WITH Tasks AS ( SELECT TaskID, ParentTaskID, CAST(SortKey AS nChar) AS sort_key /*,cast(SortKey as char) as sort_key */ FROM oaTasks AS s WHERE (TaskID = 1) UNION ALL SELECT s2.TaskID, s2.ParentTaskID ,Cast( '0.'+ cast(Tasks_2.sort_key as...