All Questions

Tagged with
Filter by
Sorted by
Tagged with
1735votes
32answers
2.3mviews

Insert results of a stored procedure into a temporary table

How do I do a SELECT * INTO [temp table] FROM [stored procedure]? Not FROM [Table] and without defining [temp table]? Select all data from BusinessLine into tmpBusLine works fine. select * into ...
user avatar
  • 20.4k
989votes
24answers
1.9mviews

Search text in stored procedure in SQL Server

I want to search a text from all my database stored procedures. I use the below SQL: SELECT DISTINCT o.name AS Object_Name, o.type_desc FROM sys.sql_modules m INNER JOIN ...
user avatar
  • 11.2k
930votes
21answers
717kviews

Function vs. Stored Procedure in SQL Server

I've been learning Functions and Stored Procedure for quite a while but I don't know why and when I should use a function or a stored procedure. They look same to me, maybe because I am kinda newbie ...
user avatar
  • 76k
431votes
7answers
557kviews

SQL Server SELECT into existing table

I am trying to select some fields from one table and insert them into an existing table from a stored procedure. Here is what I am trying: SELECT col1, col2 INTO dbo.TableTwo FROM dbo.TableOne ...
user avatar
  • 4,487
396votes
14answers
1.1mviews

How to SELECT FROM stored procedure

I have a stored procedure that returns rows: CREATE PROCEDURE MyProc AS BEGIN SELECT * FROM MyTable END My actual procedure is a little more complicated, which is why a stored procedure is ...
user avatar
329votes
12answers
849kviews

SQL Server Insert if not exists

I want to insert data into my table, but insert only data that doesn't already exist in my database. Here is my code: ALTER PROCEDURE [dbo].[EmailsRecebidosInsert] (@_DE nvarchar(50), @_ASSUNTO ...
user avatar
319votes
16answers
621kviews

How to check if a stored procedure exists before creating it

I have a SQL script that has to be run every time a client executes the "database management" functionality. The script includes creating stored procedures on the client database. Some of these ...
user avatar
  • 3,275
317votes
17answers
569kviews

What is a stored procedure?

What is a "stored procedure" and how do they work? What is the make-up of a stored procedure (things each must have to be a stored procedure)?
274votes
47answers
76kviews

What are the pros and cons to keeping SQL in Stored Procs versus Code [closed]

What are the advantages/disadvantages of keeping SQL in your C# source code or in Stored Procs? I've been discussing this with a friend on an open source project that we're working on (C# ASP.NET ...
222votes
7answers
310kviews

How do I execute a stored procedure once for each row returned by query?

I have a stored procedure that alters user data in a certain way. I pass it user_id and it does it's thing. I want to run a query on a table and then for each user_id I find run the stored procedure ...
user avatar
  • 40.9k
186votes
17answers
247kviews

SQL Call Stored Procedure for each Row without using a cursor

How can one call a stored procedure for each row in a table, where the columns of a row are input parameters to the sp without using a Cursor?
user avatar
185votes
10answers
235kviews

What is the difference between a stored procedure and a view?

I am confused about a few points: What is the difference between a stored procedure and a view? When should I use stored procedures, and when should I use views, in SQL Server? Do views allow the ...
user avatar
159votes
2answers
225kviews

The maximum recursion 100 has been exhausted before statement completion

I keep getting a max recursion error with this query. At first I thought it was because a null was being returned and then it would try and match the null values causing the error however, I rewrote ...
user avatar
  • 2,461
145votes
7answers
114kviews

Mysql - How to quit/exit from stored procedure

I have very simple question but i did't get any simple code to exit from SP using Mysql. Can anyone share with me how to do that? CREATE PROCEDURE SP_Reporting(IN tablename VARCHAR(20)) BEGIN IF ...
user avatar
  • 2,013
143votes
10answers
200kviews

How can I check if a View exists in a Database?

I have some SQL code that needs to be executed if a certain View exists in a database. How would I go about checking if the View exists? EDIT: The DBMS being used is Microsoft SQL Server
user avatar
  • 15.7k

15 30 50 per page
1
2 3 4 5
787