I want to create an sp with a simple insert but my database manager does not find it for me once it is created.
SP code:
CREATE PROCEDURE InsertHistory
@vehiculoId varchar(30),
@FechaC date,
@FechaF date,
@CodigoQR int,
@FotoE varchar(40),
@Estatus varchar(20),
@Dueno varchar(30)
AS
begin
INSERT INTO tbHistorico(VehiculoId, FechaCreacion, FechaVigencia, CodigoQR, FotografiaEvidencia, Estatus, Dueño)
VALUES (@vehiculoId, @FechaC , @FechaF , @CodigoQR , @FotoE, @Estatus, @Dueno);
end
GO
Then I want to run it with exec
and it won't let me, it tells me that it can't find the sp, but it does exist.
exec InsertHistory;
When the sp is created in sql server, it is created in the following way:
I don't know if it has something to do with putting me db_datareader
at the beginning of the sp. But I don't know how to prevent this from happening.
By default on an MSSQL installation, the schema is
[dbo]
. If the Stored Procedure appears with a different schema in the browser, it is necessary to invoke it including the corresponding schema. That it hasdb_datareader
indicates that you are creating it with a user that leaves all objects by default in that schema.Whether it is created in dbo or in another scheme depends on which user you open the query window with in the SMSS application and which default scheme that user has.
Edit: flxtr is right and I forgot perhaps the most important thing: the way to run it as it is being created now.