FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
Herramientas | Buscar en Tema | Desplegado |
|
#1
|
|||
|
|||
Procedimiento almacenado en SQL Server
hola, tengo un SP que deberia chequear si existe el nombre de una empresa
antes de darla de alta, entonces si ya existe una empresa con ese nombre lo guarda en la variable @nombre, luego pregunto si la variable me devuelve un valor no nulo entonces ya existe una empresa con ese nombre, pero el SP me da el siguiente error: Mens 208, Nivel 16, Estado 6, Procedimiento SP_EXISTE_EMPRESA, Línea 17 Invalid object name 'dbo.SP_EXISTE_EMPRESA'. estoy usando Microsoft SQL Server Managment Studio Express, desde ya muchas gracias. ALTERPROCEDURE [dbo].[SP_EXISTE_EMPRESA] -- Add the parameters for the stored procedure here @SP_NOMBRE NVARCHAR(50), @NOMBRE NVARCHAR(50) OUTPUT AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; SELECT EMPRESAS.NOMBRE FROM EMPRESAS WHERE EMPRESAS.NOMBRE = @SP_NOMBRE RETURN @NOMBRE -- Insert statements for procedure here END |
#2
|
|||
|
|||
pusiste todo el codigo del SP?? el error menciona una linea 17 y todo lo que pusiste son 14 lineas, ya pudiste correr 1 vez el procedimiento? esto porque usas el Alter pero si no existe no lo modifica, necesitas primero el create procedure y despues el Alter
|
#3
|
|||
|
|||
Este es el codigo completo del SP, gracias
-- ================================================ -- Template generated from Template Explorer using: -- Create Procedure (New Menu).SQL -- -- Use the Specify Values for Template Parameters -- command (Ctrl-Shift-M) to fill in the parameter -- values below. -- -- This block of comments will not be included in -- the definition of the procedure. -- ================================================ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= CREATEPROCEDURE [dbo].[SP_EXISTE_EMPRESA] -- Add the parameters for the stored procedure here @SP_NOMBRE NVARCHAR(50), @NOMBRE NVARCHAR(50) OUTPUT AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; SELECT EMPRESAS.NOMBRE FROM EMPRESAS WHERE EMPRESAS.NOMBRE = @SP_NOMBRE RETURN @NOMBRE -- Insert statements for procedure here END GO |
#4
|
||||
|
||||
Pues yo lo he probado y funciona perfectamente, salvo por una cosa:
* En el CREATEPROCEDURE te falta un espacio entre ambas palabras (supongo que es error de transcripción) Supongo además que cuando ya está creado, utilizas ALTER PROCEDURE en lugar de CREATE PROCEDURE para modificarlo. Por lo demás lo dicho, a mi me funciona bien.
__________________
Germán Estévez => Web/Blog Guía de estilo, Guía alternativa Utiliza TAG's en tus mensajes. Contactar con el Clubdelphi P.D: Más tiempo dedicado a la pregunta=Mejores respuestas. |
#5
|
||||
|
||||
Salvo el espacio en "CREATE PROCEDURE", a mi también me funcionó bien.
__________________
|
#6
|
||||
|
||||
Si el procedimiento no existe deberias usar CREATE PROCEDURE en vez de ALTER PROCEDURE y ademas creo que deberias asignar el valor a tu variable de salida:
Saludos Última edición por jcarteagaf fecha: 04-02-2009 a las 22:00:30. |
#7
|
||||
|
||||
Ese error indica que estás tratando de modificar un SP que no existe,
Arega el siguiente encabezado:
Saludos.
__________________
Conoce mi blog http://www.edgartec.com |
|
|
Temas Similares | ||||
Tema | Autor | Foro | Respuestas | Último mensaje |
procedimiento almacenado | sargento elias | Firebird e Interbase | 1 | 14-04-2008 13:04:35 |
Procedimiento almacenado | efelix | MS SQL Server | 7 | 21-11-2007 17:53:00 |
ejecutar Procedimiento almacenado en SQL Server, Intraweb. | Roilo | Internet | 9 | 25-07-2007 18:01:32 |
Procedimiento Almacenado | scooterjgm | Conexión con bases de datos | 5 | 18-01-2005 18:21:32 |
Procedimiento Almacenado | Ulises | Providers | 3 | 30-01-2004 18:14:58 |
|