2 Replies - 924 Views - Last Post: 12 December 2007 - 07:06 AM Rate Topic: -----

#1 pietervdl  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 09-October 07

Can Anyone Help me with SQL Stored Procedures

Post icon  Posted 11 December 2007 - 01:04 AM

Hi,
I don't know where to post this Question.
Let me begin by telling you what I have.
I have got three tables in one database in sql.Each table is displayed via a datagrid in a web application I am busy with.
I also created a fourth Table for the deleted Items.
I want to create a stored procedure with sql script.
I want the stored procedure to check the data that was deleted from each table and display that deleted data in a fourth data grid in my web application.
Here is the stored Procedure.
Hope someone can help me.
Thanks

IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'sp_DeletedItems')
	BEGIN
		DROP  Procedure  sp_DeletedItems
	END

GO

CREATE Procedure sp_DeletedItems
	@pint_ItemId int,
	@pnv_Type nvarchar(12)

AS
IF(@pnv_Type = 'Category')
	BEGIN

SELECT d.int_DeleteId, d.nv_CategoryName, d.nv_SubCategoryName, d.ntxt_Question, d.nv_UpdateUser, d.dt_LastUpdate, d.int_CategoryId, c.int_CategoryId, d.int_SubCategoryId, d.int_QuestionId
FROM tblDeletedItem d
	INNER JOIN tblCategories c
		ON d.int_CategoryId = c.int_CategoryId
ORDER BY d.dt_LastUpdate

	END

IF(@pnv_Type = 'Subcategory')
	BEGIN
SELECT d.int_DeleteId, d.nv_CategoryName, d.nv_SubCategoryName, d.ntxt_Question, d.nv_UpdateUser, d.dt_LastUpdate, d.int_CategoryId, s.int_SubCategoryId, d.int_SubCategoryId, d.int_QuestionId
FROM tblDeletedItem d
	INNER JOIN tblSubCategories s
		ON d.int_SubCategoryId = s.int_SubCategoryId
ORDER BY d.dt_LastUpdate

	END

IF(@pnv_Type = 'Question')
	BEGIN
SELECT d.int_DeleteId, d.nv_CategoryName, d.nv_SubCategoryName, d.ntxt_Question, d.nv_UpdateUser, d.dt_LastUpdate, d.int_CategoryId, q.int_QuestionId, d.int_SubCategoryId, d.int_QuestionId
FROM tblDeletedItem d
	INNER JOIN tblAssessmentQuestions q
		ON d.int_QuestionId = q.int_QuestionId
ORDER BY d.dt_LastUpdate

	END
	
GO

GRANT EXEC ON sp_DeletedItems TO PUBLIC

GO



Is This A Good Question/Topic? 0
  • +

Replies To: Can Anyone Help me with SQL Stored Procedures

#2 Lord Hadies  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 307
  • Joined: 24-November 06

Re: Can Anyone Help me with SQL Stored Procedures

Posted 11 December 2007 - 01:33 AM

Dude!!!you're capable of signing up, putting 14 posts, finding the lounge, even putting your qouting your code...why didn't you post your question in the DATABASE section???eish...its funny how people keeping putting posts wherever :)
Was This Post Helpful? 0
  • +
  • -

#3 Trogdor  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 15
  • View blog
  • Posts: 627
  • Joined: 06-October 06

Re: Can Anyone Help me with SQL Stored Procedures

Posted 12 December 2007 - 07:06 AM

ok. what is your question.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1