answersLogoWhite

0

--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

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

BlakeBlake
As your older brother, I've been where you are—maybe not exactly, but close enough.
Chat with Blake
CoachCoach
Success isn't just about winning—it's about vision, patience, and playing the long game.
Chat with Coach
EzraEzra
Faith is not about having all the answers, but learning to ask the right questions.
Chat with Ezra

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