Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 newbie sp questions

Author  Topic 

isdngirl
Starting Member

2 Posts

Posted - 2004-08-19 : 20:47:30
Youll have to forgive me a I am completly new to the world of SQL (been living access for years)

Apparently I have been told at my job I need to start using store procedures, so I started playing around with them and created my first after reading some post on here:o

CREATE PROCEDURE sp_numberOnlineCourses
(@RowCount INT OUTPUT
)
AS
SELECT resourceStatus,productName
FROM onlineCourseCatalog_qry
WHERE resourceStatus='Available'
ORDER BY resourceStatus,productName
SELECT @RowCount = @@RowCount
GO

So my question is, can a SP do more than one thing at once (right now it just returns the count of the records)?

If so how would I add this so it returns what it currently returns (the total about of records) and I also want it to return the amount of records grouped by product.

SELECT Count(*)as c, productName
FROM dbo.onlineCourseCatalog_qry
GROUP BY productName
ORDER BY productName


Not sure if that makes sense but basically I want it to do two things at once rather than writing 2 SPs.

In addition, would anyone be able to recommend a good books/on SP - something preferably for a newbie?

Thanks in advance
Sara Ogsbury

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-08-19 : 20:59:24
You really need to keep your recordset returns in seperate stored procedures so I would write two for this unless it's a report. If it's a report, just put in the second part before the GO.

Some good books are:

Teach Yourself Transact-SQL in 21 Days by Sams Publishing
Anything by Ken Henderson


http://www.sqlteam.com/store.asp


MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

isdngirl
Starting Member

2 Posts

Posted - 2004-08-20 : 10:31:10
Thanks derrickleggett:
It is for a report and I will defintly check out that book.

Cheers
Sara
Go to Top of Page
   

- Advertisement -