Hi have have this problem, I have a table called PABX that has all the callings registry and what I need to do is for each client(PABX.cod_client) I have 2 types of calls (VC1, VC2) , and for these types I need to select all the registries chaging the dialed number(PABX.NRTELEFONE) for the new one (TROCAR.NRTELEFONE) and for those client that doesn't need to change select the PABX.NRTELEFONE
is it possible through SQL Server 2000(via stored procedure) or I'll need to do it by my application using a vector ?
Thanks
Could you give us the table structure, a bit of data, and what you expect as a return? It will make it easier to understand your requirements.|||Here it is,
The main table
CREATE TABLE [dbo].[PABX] (
[COD_CLIENTE] [varchar] (5) COLLATE Latin1_General_CI_AS NULL ,
[DATA_HORA] [datetime] NULL ,
[NRTELEFONE] [varchar] (255) COLLATE Latin1_General_CI_AS NULL ,
[RAMAL] [varchar] (255) COLLATE Latin1_General_CI_AS NULL ,
[TEMPO_SEGUNDOS] [real] NULL ,
[TIPO] [varchar] (255) COLLATE Latin1_General_CI_AS NULL ,
[TEMPO_ATENDIMENTO] [varchar] (255) COLLATE Latin1_General_CI_AS NULL ,
[JAPROCESSADO] [int] NULL ,
[VALOR] [money] NULL ,
[VALOR_CONC] [money] NULL ,
[VALOR_TARIFA] [money] NULL ,
[VALOR_TARIFA_CONC] [money] NULL ,
[CLASSIFICA] [varchar] (50) COLLATE Latin1_General_CI_AS NULL ,
[LOCALIDADE] [varchar] (255) COLLATE Latin1_General_CI_AS NULL ,
[VALOR_TEMPO] [money] NULL ,
[NUMERO_E1] [varchar] (50) COLLATE Latin1_General_CI_AS NULL ,
[BLOQUEADO] [bit] NULL ,
[TABELA_TELEFONICA] [bit] NULL
) ON [PRIMARY]
GO
The table that I want to fill, with the query...
CREATE TABLE [dbo].[TELEFONICA] (
[DATA_HORA] [datetime] NULL ,
[TEMPO_SEGUNDOS] [real] NULL ,
[TIPO] [varchar] (255) COLLATE Latin1_General_CI_AS NULL ,
[LOCALIDADE] [varchar] (255) COLLATE Latin1_General_CI_AS NULL ,
[VALOR_TEMPO] [money] NULL ,
[VALOR_TARIFA] [money] NULL ,
[NUMERO_DIA] [int] NULL ,
[CLASSIFICA_TELEFONICA] [varchar] (50) COLLATE Latin1_General_CI_AS NULL ,
[TIPO_TELEFONICA] [varchar] (50) COLLATE Latin1_General_CI_AS NULL ,
[VALOR_TOTAL] [money] NULL ,
[NRTELEFONE] [varchar] (50) COLLATE Latin1_General_CI_AS NULL ,
[NUMERO_E1] [varchar] (50) COLLATE Latin1_General_CI_AS NULL
) ON [PRIMARY]
GO
And this is one row from pabx
"233";"2006-01-13 12:31:03.000";"01130214088";"130";31.0";"2";"0";NULL";"0.0760";"0.1100";"0.0760";"0.1100";"LOCAL";"SAO PAULO - SP";"1.0000";"01138333388";"0";"1"
|||I think I understand, though I don't see how we are filling the telefonica table (perhaps the TROCAR is a tabe that was not scripted.
This might be what you want to do something like:
select coalesce( new.number, old.number)
from existingData as old
left outer join changedData as new
on old.key = new.key
coalesce gets the first non-null value (from as many scalar expressions as you want.) I know this is a bit of a struggle between us language wise, if I totally missed the point let me know.
No comments:
Post a Comment