Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- OrtizOL - xCSw - http://ortizol.blogspot.com
- DECLARE @NombreDepartamento nvarchar(50) = 'Engineering';
- DECLARE @NombreGrupo NVARCHAR(50) = 'Research and Development';
- DECLARE @Existe bit = 0;
- IF EXISTS (SELECT Name FROM HumanResources.Department WHERE Name = @NombreDepartamento)
- BEGIN
- SET @Existe = 1;
- GOTO OmitirInsertar;
- END;
- INSERT INTO HumanResources.Department
- (Name, GroupName)
- VALUES (@NombreDepartamento, @NombreGrupo);
- OmitirInsertar: IF @Existe = 1
- BEGIN
- PRINT 'El departmento ' + @NombreDepartamento + ' ya existe en `HumanResources.Department`.';
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement