answersLogoWhite

0

How do you create stored procedure?

Updated: 11/1/2022
User Avatar

Wiki User

14y ago

Best Answer

--Takes three arguments, the last one is optional

CREATE PROCEDURE sp1 (@AuthorId int, @DateFrom DateTime,

@DateTo DateTime = NULL)

AS

BEGIN

--strip any time portion from the date passed in

SELECT @DateFrom = Convert(datetime,convert(char(10),@DateFrom,101))

--if no 'dateto' provided, then default to 23 hours, 59 minutes and 59 seconds

--this is because dates are stored by default as 00:00:00, and

--we only want to get data for one day

IF @DateTo IS NULL

BEGIN

SET @DateTo = DATEADD ( second , -1, @DateFrom + 1 )

END

SELECT a.Name,

a.Body,

t.Description,

u.Name

FROM Article a

INNER JOIN Topic t on a.TopicId = t.Id

LEFT OUTER JOIN Users u on u.Id = a.AuthorId

WHERE a.AuthorId = @AuthorId

AND a.CreatedDate >= @DateFrom

AND e.CreatedDate <= @DateTo

END

GO

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you create stored procedure?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Can You Write Trigger in Stored Procedures?

A trigger is a stored procedure. It is a special stored procedure that runs in response to some defined event, such as an insert into a table.


How do you compile a PLSQL procedure?

You can do that with Sql*Plus: SQL&gt; CREATE OR REPLACE PROCEDURE foo ... IS ... END foo; / SHOW ERRORS


How do you create online shopping HTML?

Well, its a long procedure and yo can only get it if you search it on Google etc. and follow the instructions step by step.


Can we use javascript in SQL stored procedure?

Transact-SQL in an internationally standardised method to create, modify and delete databases and tables, as well as insert, retrieve, modify and delete data stored in a database. With Microsoft SQL Server 2005 you can also author procedures in any managed language such as C# or VB. This is because it is integrated with the CLR which allows you write powerful programs inside stored procedures. All functionality of the .NET Framework BCL (Base Class Library) is available to your stored procedures. This means that developers have access to thousands of pre-built classes and routines which can be accessed. The BCL includes classes that provide functionality for improved string functioning, advanced math operations, file access, cryptography, and more.


How do you hide an image within an exe file?

.exe stands for executeable. A .exe file can be any program such as internetexplorer.exe, or solitare.exe. the .exe files call on information stored in the program files, and puts them all togethor to create a program as you know it. I'm assuming you want to hide an image in a folder, where you would create a new foler, then drag the image to it. but, if you are making a .exe, you tell the computer to call on the picture which is stored somewhere

Related questions

How do you create procedures in MySQL?

One of the fastest ways to create a stored procedure is: In the database explorer, navigate to the Procedures node. Select New Procedure from the context menu. Specify the name of the procedure in the dialog box that opens and click &quot;Create&quot;. dbForge Studio for MySQL is a big help while working with stored programs are stored procedures and functions, triggers and events.


Difference between a local procedure and stored procedure?

local procedure wont store in database. Stored procedure store in database permanently and we can use it whenever we require. Other program also can use this stored procedure. And the transaction of stored procedure take care by DBA. But the local procedure transaction is take care by manually only


Can You Write Trigger in Stored Procedures?

A trigger is a stored procedure. It is a special stored procedure that runs in response to some defined event, such as an insert into a table.


What is the meaning of the term stored procedure?

A stored procedure is considered a subroutine, which is considered to be only available to the applications with access to a relational database system.


Is it possible to call a stored procedure from java script function and populate an aspnet dropdown list HTML control using the value returned by the SP?

No, a stored procedure can not be called from Javascript. A dropdown list however can be populated using a stored procedure.


Surgical procedure to create an alternative route for blood circulation?

The surgical procedure to create an alternate route is called a bypass.


What are stored procedures in data bases?

Stored procedure is the pl-sql block in precomplile from and can be used to excecute plsql statement


You created a stored procedure in sql server 2005 database and you called through aspnet page with connection then you are getting error as - Could not find stored procedure 'GetLoginInfo' solve pls?

The connections bruk.


How you create a bank account like cash account and what is the procedure to create?

how to create bank account?


What is the examples of Stored procedure?

sp_helpdb , sp_who2, sp_renamedb are a set of system defined stored procedures. We can also have user defined stored procedures which can be called in similar way.


When you create a device special file in what folder should it be stored in Linux?

Usually they are stored in /dev


Cactuses water stored?

yea they can create water