Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

Converting Rrom Access Syntax To Sql Syntax

$
0
0

 

Ok I am tying to convert access syntax to Sql syntax to put it in a stored procedure or view..

Here is the part that I need to convert:

 

SELECT [2007_hours].proj_name, [2007_hours].task_name, [2007_hours].Employee,

 IIf(Mid([task_name],1,3)='PTO','PTO_Holiday',

             IIf(Mid([task_name],1,7)='Holiday','PTO_Holiday',

                         IIf(Mid([proj_name],1,9) In ('9900-2831','9900-2788'),'II Internal',

                                     IIf(Mid([proj_name],1,9)='9900-2787','Sales',

                                                 IIf(Mid([proj_name],1,9)='9910-2799','Sales',

                                                             IIf(Mid([proj_name],1,9)='9920-2791','Sales',

                                                                                                                                                

                                                            )

                                                )

                                    )

                        )

            ) AS timeType, Sum([2007_hours].Hours) AS SumOfHours

   from................

 

how can you convert it to sql syntax

 

I need to have a nested If statment which I can't do in sql (in sql I have to have select and from Together for example ( I can't do this in sql):

select ID, FName, LName
if(SUBSTRING(FirstName, 1, 4)= 'Mike')
Begin
    Replace(FirstNam,'Mike','MikeTest')
       if(SUBSTRING(LastName, 1, 4)= 'Kong')
         Begin
            Replace(LastNam,'Kong,'KongTest')
              if(SUBSTRING(Address, 1, 4)= '1245')
             Begin
                 .........
    End
   End

end

 

 

 

 Case Statement might be the solution but i could not do it.

 

 

 

 

 

 

Your input will be appreciated

 

Thank you


Viewing all articles
Browse latest Browse all 8428

Trending Articles