Most voted "stored-procedures" questions
Stored Procedure is a set of SQL commands that stores repetitive tasks and accepts input parameters for the task to be performed according to individual needs. This tag should be used when the problem/doubt relates to the construction, performance and/or call stored procedures.
Learn more…169 questions
Sort by count of
-
21
votes3
answers1556
viewsSQL in the code or in the database?
I’m having a big doubt about where I should put mine query SQL, whether in code or bank. Currently I have a Procedure which is mounted according to the parameters I have, ie, filtros. Procedure…
-
18
votes0
answers488
viewsRecursive call error in nested procedures
I have some procedures Mysql to do the following: The main code will always call the trial CALL sp_syncTabela. To sp_syncTabela will check if there is another specific process for the tableName…
-
8
votes1
answer7625
viewsDifference between Triggers and Stored Procedures
What are the differences between Triggers and Stored Procedures?
-
6
votes1
answer328
viewsError Based on Accentuation
Hello! I’m developing a Hybrid APP that uses a PHP Webservice to send an email and call a Procedure in Mysql by filling it with the same email details, until the email sending part is OK it sends…
-
5
votes1
answer190
viewsParameter for Stored Procedure not identified
I’m having a problem, which would be a mistake saying that there is no parameter being passed to the Procedure. It is running the following code: cmdProcedure.Parameters.AddWithValue("@id", 0);…
-
5
votes5
answers25936
viewsHow to pass a list of values to a Stored Procedure?
I’m creating a stored Procedure in SQL Server 2008 R2 and would like to pass a list of values per parameter, for example: Table produto ---------------- | id | nome | | 1 | maçã | | 2 | pera | | 3 |…
-
5
votes2
answers1969
viewsHow to get the Primary key Identity of an inserted record?
I need to create a stored procedure to insert a game into my database. A game relates to a championship through the table campeonatoJogo. The tables are basically: create table jogo( codJogo int…
-
5
votes1
answer695
viewsSELECT within variable in PROCEDURE
I’m not getting the result of a select within a variable. I want to add the column turno inside my WHERE. The problem is I get the value of @turnos in the following 3 formats: 1 - 'A' 2 - 'A','B' 3…
-
4
votes1
answer1914
viewsProcedure oracle to copy data between tables
I need to make a trial copy of my TAB_FORNECEDOR table, everything you have in it and pass to TAB_FORNECEDOR2 table. I know I need to make a loop cursor, a commit delete before everything, can give…
-
4
votes2
answers81
viewsSimple SQL query
I have a proc that gets a product ID. If it gets NULL, then it should list all products. If it gets the specific ID, it should list only that product. There is some way to do this without having to…
-
4
votes3
answers3810
viewsWhat is the difference between a View and a Stored Procedure in SQL?
I have come across SQL Views and also stored procedures. I would like to understand better, what is the difference between a view and a stored Procedure and what are its purposes? It would be…
-
4
votes2
answers160
viewsSQL Procedures: Can I use a table as a parameter for a procedure?
I’m a beginner in procedures. I am trying to insert data into a table using a procedure, where I get the table name, the column names and the values of these. How to receive the types of data I…
-
3
votes2
answers1269
viewsParameter varchar in Store Procedure
I have a mysql store as follows: CREATE PROCEDURE nome_procedure(campo VARCHAR(15)) BEGIN SELECT id as id, campo as value FROM tabela etc etc etc...; END $$ However, since the parameter I am passing…
-
3
votes2
answers619
viewsStored Procedure for log data insertion
I need to create a Stored Procedure in my SQL Server database. The purpose of this Stored Procedure is to record data in a Log table, which has three fields: date, time, ID of who logged in. Date…
-
3
votes1
answer193
viewsShow warning message without exception
I would like to display an alert message to the user without causing exception in the Database. I am using SQL Server. So I cannot use RAISERROR, nor PRINT, because it is not shown to the user.…
-
3
votes0
answers62
viewsDisplay image in Excel using binary code
I have a report on Excel where the data is displayed through a stored procedure. I have a problem because when I look for the value of the image field that is blob, it displays binary code instead…
-
3
votes2
answers3629
viewsError trying to remove a temporary table
I have a service where I load data from an ERP into a DW. The source of the data is SQL Server 2008 R2 10.50.1600.1 and the target server MS SQL Server 2008 10.0.5512.0 SP3. The service performs a…
-
3
votes3
answers6518
viewsHow to access the code behind a Stored Procedure?
How can I access the code behind a stored procedure? I’m using Microsoft SQL Server Management Studio.
-
3
votes1
answer580
viewsPass Parameters to Store Procedure
Follow the Search Function Code public List<Pessoa> Buscar(string Nome) { using(var db = new MyContext()) { var Result = db.Database.SqlQuery<Pessoa>("EXEC SP_Busca_Cliente @Nome",…
-
3
votes1
answer174
viewsSql Server Stored Procedures
I am starting the development of an application, basically it is a managerial control of companies. The application will issue NFC-e, Nfe, control stock, finance and etc, the database will be hosted…
-
3
votes1
answer809
viewsPHP Sqlserver Stored Procedure does not run correctly
Hello, I am developing an application using Laravel Framework Handler from my Backend and found the following error. My Sqlserver Express 2008 R2 database has a stored Procedure that performs a…
php sql-server laravel stored-procedures sql-server-2008asked 7 years, 11 months ago Jonatan Pietroski 109 -
3
votes1
answer350
viewsSelect with SUM until sum B is equal to or less than A
I have two tables, products and lots: Products codigo qtdatual Batches codigo qtdlote validade A select example would be: SELECT P.CODIGO, L.QTDLOTE, L.VALIDADE FROM LOTES L INNER JOIN PRODUTOS P…
-
3
votes2
answers426
viewsSQL command in String Mysql
I am making a precedent that saves a select in a varchar variable. Now I need to run this sql command, how do I do that? I am using Mysql. Procedure: delimiter $$ create procedure eixos_caminhao (in…
-
3
votes1
answer1428
viewsHow to quote a variable for Mysql query
I’m doing a trial, I need to put a variable varchar in the query, but it doesn’t go with the simple quotes, I tried to concatenate like this or something but it’s no use: set @comando :=…
-
3
votes3
answers1854
viewsSQL query to know the sales of a period (year), dividing by month and showing the total of each month and year
I work as a technical support in an automation system, a customer asked if there was a report in the system that showed the total sales of 2018 divided by month and showing the total of each month…
-
3
votes2
answers299
viewsError calling PROCEDURE in SQL Fiddle
When making a call PROCEDURE in SQL Fiddle, the following error is displayed: DDL and DML statements are not allowed in the query panel for Mysql; only SELECT statements are allowed. Put DDL and DML…
-
2
votes1
answer1825
viewsAllow a user to view stored procedures created by other users
I have a Mysql database populated with some stored procedures. The problem is that two different users have created several procedures, so that only the user who created the stored Procedure can see…
-
2
votes2
answers343
viewsHow to use store with Doctrine
How to use stored Procedure with Doctrine ? Should I use createNativeQuery ?
-
2
votes2
answers907
viewsMount Stored Procedure Dynamic Query in SQL Server
need to mount a conditional query with stored Procedure, to make clear my problem I will expose here to sp with what I want to work, note the end where I use Ifs, this there the problem. USE…
-
2
votes1
answer612
viewsWhat would be Pro*C/C++?
From what I saw it is using in Oracle, but I can use with another Bank? Pro*C/C++ useful these days? Could pass a Code Example? Does it differ from PL/SQL? Or are they used together?…
-
2
votes1
answer971
viewsStored Procedure com if
I have a table with the fields name, id and salary. I need a trial that changes the employee’s salary, if she receives one, should increase the salary by 300 reais, in case another value decreases…
-
2
votes1
answer26
viewsVariable returning null value
I’m creating a precedent for it to store the food name in the Procedure food variable, follow the code: DELIMITER $$ CREATE PROCEDURE armazena_nome(id INT, OUT alimento VARCHAR(20)) BEGIN SELECT…
-
2
votes2
answers224
viewsCondition for INSERT INTO
I need SQL to check that in the '@variable' sent there is a value equal to 1, 2 or 3; If true enter the value 1, otherwise enter the value 0. Note: the table and column can be given as examples as…
-
2
votes4
answers1225
viewsHow do I write a store that uses current and previous line values?
I have the following table, # id # dataTmp # referencia #nProduz#nStock # id2 #necessi# # 115237 # 31-01-2017 # VL03280103 # 0 # 0 # 6 # 0 # # 115238 # 01-02-2017 # VL03280103 # 0 # 0 # 7 # 0 # #…
-
2
votes1
answer674
viewsAssign a variable a Dynamic Date?
My goal is to create a SQL Server, which has by default two variables, one with the initial date of (hoje - 3 anos) and a final date equal to hoje. I already use for other operations (for example a…
-
2
votes1
answer1648
viewsHow to assign a EXECUTE SP_EXECUTESQL @SQLSTRING to a temporary table
It is possible in the same script to create a temporary table from an execution like this? --****************************EMPRESA****************************** if(Object_id('tempdb..#TBEmpresa') is…
-
2
votes1
answer64
viewsDoubt in conversion of rows into columns Sql Server 2012
I turned rows into columns and need to improve this query by adding another row in column: This is the query: --****************************EMPRESA******************************…
-
2
votes1
answer732
viewsCreate a precedent in Postgresql
I have created a database in Equipment Allocation Postgresql where one or many Equipments can be Allocated by one or many Sectors. That is, I have 3 tables in this relation: One is the Sector Table…
-
2
votes2
answers1061
viewsWhat are real and practical examples in the use of Stored Procedures?
When participating in an interview for the position of developer, I come across a question related to Stored Procedure (SP) and at first I have theoretical knowledge on the subject, but I have never…
-
2
votes0
answers44
viewsHow to execute an SQL statement concatenated with a variable in a Procedure in Mysql
I am creating a database to create a database and some tables within that database. I get the name of the database to be created by parameter. I’m having difficulty concatenating this parameter next…
-
2
votes1
answer45
viewsDatagridview displaying incomplete id
The grid displays only the first character of the "ID" For example: if the ID is 16 it displays 1; If it’s 20 displays 2; However from 1 to 9 displays correctly... Code that selects the data...…
-
2
votes0
answers49
viewsStored Procedures
I have a Mysql database with several stored procedures, like releasing only one for a particular user? I have a database Mysql with several stored procedures, how to release only one for a specific…
-
2
votes0
answers126
viewsHow to assign a null value to an input variable if the user leaves the field blank or type zero?
The context in which the problem arose is the following: I have a stored procedure that performs the registration of certain values in a table of my database. In this procedure I set all variables…
-
2
votes2
answers77
viewsGroup a conversion list within SELECT
I have a doubt in the SQL Server, I have a product table and another with a conversion list for each product I have a conversion list for that product. I need a product list with the conversion…
-
1
votes2
answers219
viewsTool to debug a stored Procedure on linux
would like to know if anyone knows or even used any tool to realize a debug in stored procedures in linux. I am currently using the Mysql Workbench and the Dbvisualizer, but as far as I know none of…
-
1
votes2
answers2023
viewsPass table field as parameter in a precedent
I made this precedent to bring records from a table between dates, but I need to pass the date field of the table for the between command to work, follow the code: DELIMITER // CREATE PROCEDURE…
-
1
votes1
answer238
viewsProcedure with out parameter (SYSREFCURSOR) with Entity Framework
I am having a problem that is keeping me awake. I am making a database migration, from SQL Server to Oracle, in a C#application. The application mentioned is using Entity Framework to perform…
-
1
votes2
answers71
viewsPassing value of a VARCHAR variable in the WHERE IN command
good night. I have the following example process CREATE PROCEDURE sp_listaFuncionarios @nome_dept varchar(50) as SELECT * FROM Funcionarios WHERE nome_departamento IN (@nome_dept) If during the…
-
1
votes3
answers412
viewsFilter records via datetime and bring them between an initial and final date
I have the balance table, that always when running a precedent, It is generated a new record in the same, You can have several record in the same day... However, when making a query, I want to bring…
-
1
votes1
answer603
viewsHow to stop a stored procedures in Mysql?
there is the possibility of stop one stored proceduresin the MySQL? I put a procedures to power a database table for load testing with 10 million records, but the insertion is too slow and wanted to…