Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 9th, 2013, 09:28 AM
Registered User
 
Join Date: Sep 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default convert from Stored procedure to SQL Query

Hi Everybody,

I have this:


Code:
OPEN @WeekdayCursor
--
--SET @Weekdays = ''
--FETCH NEXT FROM @WeekdayCursor
--INTO @PriceAddID, @StartDate, @EndDate, @Weekdays
--
--WHILE @@FETCH_STATUS = 0
--BEGIN
--DECLARE @Position int
--  SET @Position = 0
--
--  DECLARE @NumDays int
--  SET @NumDays = DATEDIFF(day, @StartDate, @EndDate)
--
--  DECLARE @CurrentDate    datetime
--  DECLARE @CurrentBWeekday  int
--  DECLARE @Weekday int
--
--  WHILE (@Position < @NumDays + 1)
--  BEGIN
--    SET @CurrentDate = DATEADD(day, @Position, @StartDate)
--    -- Remember, SET DATEFIRST 1 for Monday
--    SET @CurrentBWeekday    = dbo.f_BWeekday(@CurrentDate)
--    -- Validate the weekday
--      --SET @Position = @Position + 1
--  IF (@Weekdays > 0 AND @CurrentBWeekday & @Weekdays <> @CurrentBWeekday)
--    BEGIN
--      SET @Position = @Position + 1
--      CONTINUE
--    END
--  SET @Weekday= (SELECT dbo.f_Bweekday(@CurrentDate))
--    INSERT INTO #weekdayprice VALUES(@PriceAddID, @StartDate, @EndDate, @Weekday)
--    SET @Position = @Position + 1
--  END
--
----Logic
--FETCH NEXT FROM @WeekdayCursor
--INTO @PriceAddID, @StartDate, @EndDate, @Weekdays
--END
--
--CLOSE @WeekdayCursor
--DEALLOCATE @WeekdayCursor
en this is the enum for weekdays:

Code:
SELECT DISTINCT(weekdays), PriceAddID,
CASE weekdays	WHEN 0 THEN 'none'
				WHEN 1 THEN 'mo'
				WHEN 2 THEN 'tu'
				WHEN 4 THEN 'we'
				WHEN 8 THEN 'th'
				WHEN 16 THEN 'fr'
				WHEN 32 THEN 'sa'
				WHEN 64 THEN 'su'
END AS weekdayss
FROM #weekdayprice ORDER BY PriceAddID

DROP TABLE #weekdayprice

How to make a SQL QUERY of it?

Thanks

Last edited by savantKing99; September 9th, 2013 at 09:36 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to convert query to stored procedure nanu yaru SQL Server 2000 2 April 1st, 2008 07:46 AM
Query Parameter of a Stored Procedure tarang SQL Server 2000 4 July 25th, 2007 11:43 AM
Oracle Stored Procedure and Microsoft Query Raoul Oracle 0 January 23rd, 2006 03:41 AM
Stored Procedure Query anilmohakar SQL Server 2000 1 November 12th, 2005 12:31 AM
convert a Stored procedure to DLL by VC++ rosalynb Visual C++ 0 November 4th, 2003 06:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.