troubleshooting Question

SQL Server 2008 Stored Procedure code reading

Avatar of RadhaKrishnaKiJaya
RadhaKrishnaKiJaya asked on
Microsoft SQL Server.NET ProgrammingMicrosoft SQL Server 2008
6 Comments1 Solution295 ViewsLast Modified:
Hi Experts,
I am trying to understand the following code which is there in the function and this function is called from SP.  

DECLARE @sqlWDay INT

IF @DOWeek IS NOT NULL
    BEGIN
        SELECT @sqlWDay = CASE @DOWeek
        WHEN 'Su' THEN 1
        WHEN 'Mo' THEN 2
        WHEN 'Tu' THEN 3
        WHEN 'We' THEN 4
        WHEN 'Th' THEN 5
        WHEN 'Fr' THEN 6
        WHEN 'Sa' THEN 7
    END
END


I have a String field in the table called DOWeek, whose possible value are

  1. Blank
  2. 'MoTuWeThFr'
  3. 'MoWeTh'
  4. 'Th'
  5. 'FrTh'
  6. 'Fr'
etc. etc.

The above function is called from the SP with DOWeek as parameter.  But, I don't know what would be the possible value of @SqlWDay.  In other words, I don't understand how the (code), or the value of @DOWeek would be translated to @sqlWDay.  Please try to help me.  Thank you a lot in advance.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros