SQL Server - error 512

 
Vista:
sin imagen de perfil
Val: 4
Ha disminuido su posición en 7 puestos en SQL Server (en relación al último mes)
Gráfica de SQL Server

error 512

Publicado por William (3 intervenciones) el 15/12/2020 22:06:32
alguien me podría ayudar a encontrar el error 512

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
ALTER PROCEDURE [dbo].[ModificarAlojamiento]
	@nombreNEW varchar(30),
	@nombreOLD varchar(30),
	@direccion varchar(40),
	@telefono varchar(20),
	@contacto int,
	@PersonalAlj PersonalTipo READONLY,
	@HabitacionAlj HabitacionTipo READONLY,
	@ActividadAlj ActividadTipo  READONLY,
	@resultado int output
AS
BEGIN
	SET NOCOUNT ON;
	BEGIN TRANSACTION
	BEGIN TRY
			update Alojamiento
			set nombre = @nombreNEW,
				direccion = @direccion,
				telefono = @telefono,
				contacto = case when @contacto = -1
								then null
								else @contacto
							end
			where nombre = @nombreOLD;
			delete from Personal where codigo not in (select codigo from @PersonalAlj);
			SET IDENTITY_INSERT Personal ON;
			INSERT INTO Personal (codigo, nombre, direccion, nif, nombre_alojam)
				select 	pa.codigo, pa.nombre, pa.direccion, pa.nif, pa.nombre_alojam
				from @PersonalAlj pa
				where pa.codigo not in (select codigo from Personal);
			SET IDENTITY_INSERT Personal OFF;
 
			delete from Habitacion where numero not in (select numero from @HabitacionAlj);
			SET IDENTITY_INSERT Habitacion ON;
			INSERT INTO Habitacion(nombre_alojamiento, numero, tipo, baño, precio)
				select 	ha.nombre_alojamiento, ha.numero, ha.tipo, ha.baño, ha.precio
				from @HabitacionAlj ha
				where ha.numero not in (select numero from Habitacion);
			SET IDENTITY_INSERT Habitacion OFF;
 
			if((Select COUNT(*) from @ActividadAlj)<>0)
			begin
				delete from Actividad where codigo not in (select distinct(codigo) from @ActividadAlj);
				SET IDENTITY_INSERT Actividad ON;
				INSERT INTO Actividad(codigo, nombre, descripcion, dificultad)
					select 	a.codigo, a.nombre, a.descripcion, a.dificultad
					from @ActividadAlj a
					where a.codigo not in (select codigo from Actividad);
				SET IDENTITY_INSERT Actividad OFF;
 
				INSERT INTO Realiza(nombre_alojam, codigo_actividad, dia_semana)
					select a.nombre_alojam, a.codigo, a.dia_semana
					from @ActividadAlj a
					where (a.codigo not in (select distinct(codigo_actividad) from Realiza) and a.nombre_alojam not in (select distinct(nombre_alojam) from Realiza))
							or
						  (a.codigo in (select distinct(codigo_actividad) from Realiza) and a.nombre_alojam not in (select distinct(nombre_alojam) from Realiza))
							or
						  (a.codigo not in (select distinct(codigo_actividad) from Realiza) and a.nombre_alojam in (select distinct(nombre_alojam) from Realiza));
			end;
			set @resultado=0;
			COMMIT TRANSACTION
	END TRY
	BEGIN CATCH
	    set @resultado=ERROR_NUMBER();
		IF (XACT_STATE()) = -1
			ROLLBACK TRANSACTION;
		IF (XACT_STATE()) = 1
			COMMIT TRANSACTION
	END CATCH
END
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Isaias
Val: 3.250
Oro
Ha mantenido su posición en SQL Server (en relación al último mes)
Gráfica de SQL Server

error 512

Publicado por Isaias (4558 intervenciones) el 16/12/2020 15:51:01
¿Cual es el TEXTO del error 512?, ¿Que versión tienes de SQL Server?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Isaias
Val: 3.250
Oro
Ha mantenido su posición en SQL Server (en relación al último mes)
Gráfica de SQL Server

error 512

Publicado por Isaias (4558 intervenciones) el 16/12/2020 19:13:10
¿Es este el texto?

Microsoft SQL Server reported SQL message 512, severity 16: [21000][512][Microsoft][SQL Server Native Client 11.0][SQL Server]Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. :EAS_InsertOrUpdateProperty

Ademas, cambia el NOT IN, por el NOT EXISTS
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar