Hello:
I have a table called PreferenciasCliente with the following fields.
[CodigoCliente] [char] (10) COLLATE Modern_Spanish_CI_AS NULL ,
[IdiomaCAT] [bit] NULL ,
[IdiomaCAST] [bit] NULL ,
[IdiomaFR] [bit] NULL ,
[IdiomaENG] [bit] NULL ,
[PaletUE] [bit] NULL ,
[PaletUEInt] [bit] NULL ,
[MasterColor] [varchar] (50) COLLATE Modern_Spanish_CI_AS NULL ,
[Impresion] [varchar] (50) COLLATE Modern_Spanish_CI_AS NULL ,
[Etiquetas] [varchar] (50) COLLATE Modern_Spanish_CI_AS NULL ,
[ContEtiq] [text] COLLATE Modern_Spanish_CI_AS NULL ,
[EspecEst] [text] COLLATE Modern_Spanish_CI_AS NULL
WHat I then have is two processes that interact with a single table. Right now, one deletes a record if [CodigoCliente] exists, if not it creates a new record. If it already exists, it gets overwritten. I now have another process which should update the following 4 fields:
[Impresion] [varchar] (50) COLLATE Modern_Spanish_CI_AS NULL ,
[Etiquetas] [varchar] (50) COLLATE Modern_Spanish_CI_AS NULL ,
[ContEtiq] [text] COLLATE Modern_Spanish_CI_AS NULL ,
[EspecEst] [text] COLLATE Modern_Spanish_CI_AS NULL
...BUt I can't delete and add now that I have 2 actions. What I have to do is use a stored procedure to first see if the [CodigoCliente] exists, if it does, it should do an update for the appropriate fields; if not, it should add a new record to the table. How can I do this?
thanks,
Joseph
>select @cnt = count(*) from PreferenciasCliente with(nolock)
>where CodigoCliente =@CodigoCliente
Eventhough this works, it will have some performance overheads. check my code
Aneesh R.