SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Store procedure help


Store procedure help

Author
Message
OnlyOneRJ
OnlyOneRJ
Old Hand
Old Hand (346 reputation)Old Hand (346 reputation)Old Hand (346 reputation)Old Hand (346 reputation)Old Hand (346 reputation)Old Hand (346 reputation)Old Hand (346 reputation)Old Hand (346 reputation)

Group: General Forum Members
Points: 346 Visits: 690
I want to write a stored procedure where it will take 1 parameter that is DateTime..
but it is showing wrong output Sad

Below is the SP -


***********************************START
USE [Test]
GO
/****** Object: StoredProcedure [dbo].[sps_Final] Script Date: 08/28/2012 02:33:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Runal Jagtap
-- Create date: 28 AUG 2012
-- Description: Copying Data from FinalRecord Table to the Archieve Table (FinalRequiredRecord) & then Purging the data from FinalRecord according to the said Date.
-- =============================================
ALTER PROCEDURE [dbo].[sps_Final]
@FinaldtCompleted DateTime

AS
BEGIN

-- ====== Inserting Data from FinalRecord Table to FinalRequiredRecord Table ===============================
INSERT INTO dbo.FinalRequiredRecord
SELECT * from dbo.FinalRecord
WHERE convert(nvarchar(100), FinaldtCompleted, 106) <= 'convert(nvarchar(100), @FinaldtCompleted, 106)'
-- =============================================

-- ====== PURGING Data from FinalRecord Table ===============================
DELETE from dbo.FinalRecord
WHERE convert(nvarchar(100), FinaldtCompleted, 106) <= 'convert(nvarchar(100), @FinaldtCompleted, 106)'
-- =============================================*/
SELECT * FROM dbo.FinalRequiredRecord

END

***********************************END



Now actually the problem is the FinaldtCompleted format is '2012-08-28 03:26:07.697' (DateTime)
and while executing SP i want to give the simple parameter value..like - '2012-08-28' or any other..

please help Sad

************************************
Every Dog has a Tail !!!!! :-D
OnlyOneRJ
OnlyOneRJ
Old Hand
Old Hand (346 reputation)Old Hand (346 reputation)Old Hand (346 reputation)Old Hand (346 reputation)Old Hand (346 reputation)Old Hand (346 reputation)Old Hand (346 reputation)Old Hand (346 reputation)

Group: General Forum Members
Points: 346 Visits: 690
Hi all,



I made it... it got solved with slight modifications... Thanks alSmile

************************************
Every Dog has a Tail !!!!! :-D
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search