Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
4| Name | Data Type | Length | Description |
|---|---|---|---|
| @p_identificacion | varchar | 40 | |
| @p_cuerpo_clave | varchar | 40 | |
| @p_nombre_persona | varchar | 100 | |
| @p_todos_los_paises | bit | 1 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
--exec buscar_en_padron null, '20892565',null,0
CREATE OR ALTER PROCEDURE dbo.buscar_en_padron
@p_identificacion varchar(40),
@p_cuerpo_clave varchar(40),
@p_nombre_persona varchar(100),
@p_todos_los_paises bit = 0
AS
BEGIN
IF (@p_cuerpo_clave IS NOT NULL) AND (LEN(@p_cuerpo_clave) > 0)
if(@p_todos_los_paises = 1)
begin
SELECT top 20 identificacion,pre_clave, suf_clave,cuerpo_clave,nombre_persona,padrones.identificador,id_padron,identificadores.identificador, apellidos, nombres, sexo from dbo.padrones inner join identificadores on
identificadores.identificador = padrones.identificador
WHERE CONTAINS(cuerpo_clave,@p_cuerpo_clave) and pre_clave not in (30,33) and ( habilitado = 1 or habilitado is NULL)
end
else
begin
SELECT top 20 identificacion,pre_clave, suf_clave,cuerpo_clave,nombre_persona,padrones.identificador,id_padron,identificadores.identificador, apellidos, nombres, sexo from dbo.padrones inner join identificadores on
identificadores.identificador = padrones.identificador
WHERE CONTAINS(cuerpo_clave,@p_cuerpo_clave) and country_code in ('AR') and pre_clave not in (30,33) and ( habilitado = 1 or habilitado is NULL)
end
ELSE IF (@p_nombre_persona IS NOT NULL) AND (LEN(@p_nombre_persona) > 0)
if(@p_todos_los_paises = 1)
begin
SELECT top 20 identificacion,pre_clave, suf_clave,cuerpo_clave,nombre_persona,padrones.identificador,id_padron,identificadores.identificador, apellidos, nombres, sexo from dbo.padrones inner join identificadores on
identificadores.identificador = padrones.identificador
WHERE CONTAINS(nombre_persona,@p_nombre_persona) and ( habilitado = 1 or habilitado is NULL)
end
else
begin
SELECT top 20 identificacion,pre_clave, suf_clave,cuerpo_clave,nombre_persona,padrones.identificador,id_padron,identificadores.identificador, apellidos, nombres, sexo from dbo.padrones inner join identificadores on
identificadores.identificador = padrones.identificador
WHERE CONTAINS(nombre_persona,@p_nombre_persona) and country_code in ('AR') and padrones.identificador = 'CUIT' and ( habilitado = 1 or habilitado is NULL)
end
ELSE IF (@p_identificacion IS NOT NULL) AND (LEN(@p_identificacion) > 0)
if(@p_todos_los_paises = 1)
begin
SELECT top 20 identificacion,pre_clave, suf_clave,cuerpo_clave,nombre_persona,padrones.identificador,id_padron,identificadores.identificador , apellidos, nombres, sexo from dbo.padrones inner join identificadores on
identificadores.identificador = padrones.identificador
WHERE CONTAINS(identificacion,@p_identificacion) and ( habilitado = 1 or habilitado is NULL)
end
else
begin
SELECT top 20 identificacion,pre_clave, suf_clave,cuerpo_clave,nombre_persona,padrones.identificador,id_padron,identificadores.identificador, apellidos, nombres, sexo from dbo.padrones inner join identificadores on
identificadores.identificador = padrones.identificador
WHERE CONTAINS(identificacion,@p_identificacion) and country_code in ('AR') and ( habilitado = 1 or habilitado is NULL)
end
END
GO
GO
--exec buscar_en_padron null, '20892565',null,0
CREATE OR ALTER PROCEDURE dbo.buscar_en_padron
@p_identificacion varchar(40),
@p_cuerpo_clave varchar(40),
@p_nombre_persona varchar(100),
@p_todos_los_paises bit = 0
AS
BEGIN
IF (@p_cuerpo_clave IS NOT NULL) AND (LEN(@p_cuerpo_clave) > 0)
if(@p_todos_los_paises = 1)
begin
SELECT top 20 identificacion,pre_clave, suf_clave,cuerpo_clave,nombre_persona,padrones.identificador,id_padron,identificadores.identificador, apellidos, nombres, sexo from dbo.padrones inner join identificadores on
identificadores.identificador = padrones.identificador
WHERE CONTAINS(cuerpo_clave,@p_cuerpo_clave) and pre_clave not in (30,33) and ( habilitado = 1 or habilitado is NULL)
end
else
begin
SELECT top 20 identificacion,pre_clave, suf_clave,cuerpo_clave,nombre_persona,padrones.identificador,id_padron,identificadores.identificador, apellidos, nombres, sexo from dbo.padrones inner join identificadores on
identificadores.identificador = padrones.identificador
WHERE CONTAINS(cuerpo_clave,@p_cuerpo_clave) and country_code in ('AR') and pre_clave not in (30,33) and ( habilitado = 1 or habilitado is NULL)
end
ELSE IF (@p_nombre_persona IS NOT NULL) AND (LEN(@p_nombre_persona) > 0)
if(@p_todos_los_paises = 1)
begin
SELECT top 20 identificacion,pre_clave, suf_clave,cuerpo_clave,nombre_persona,padrones.identificador,id_padron,identificadores.identificador, apellidos, nombres, sexo from dbo.padrones inner join identificadores on
identificadores.identificador = padrones.identificador
WHERE CONTAINS(nombre_persona,@p_nombre_persona) and ( habilitado = 1 or habilitado is NULL)
end
else
begin
SELECT top 20 identificacion,pre_clave, suf_clave,cuerpo_clave,nombre_persona,padrones.identificador,id_padron,identificadores.identificador, apellidos, nombres, sexo from dbo.padrones inner join identificadores on
identificadores.identificador = padrones.identificador
WHERE CONTAINS(nombre_persona,@p_nombre_persona) and country_code in ('AR') and padrones.identificador = 'CUIT' and ( habilitado = 1 or habilitado is NULL)
end
ELSE IF (@p_identificacion IS NOT NULL) AND (LEN(@p_identificacion) > 0)
if(@p_todos_los_paises = 1)
begin
SELECT top 20 identificacion,pre_clave, suf_clave,cuerpo_clave,nombre_persona,padrones.identificador,id_padron,identificadores.identificador , apellidos, nombres, sexo from dbo.padrones inner join identificadores on
identificadores.identificador = padrones.identificador
WHERE CONTAINS(identificacion,@p_identificacion) and ( habilitado = 1 or habilitado is NULL)
end
else
begin
SELECT top 20 identificacion,pre_clave, suf_clave,cuerpo_clave,nombre_persona,padrones.identificador,id_padron,identificadores.identificador, apellidos, nombres, sexo from dbo.padrones inner join identificadores on
identificadores.identificador = padrones.identificador
WHERE CONTAINS(identificacion,@p_identificacion) and country_code in ('AR') and ( habilitado = 1 or habilitado is NULL)
end
END
GO
Depends On
2Used By
No items found