Tech Off Post

Single Post Permalink

View Thread: Good SQL Fizz Buzz
  • User profile image

    Slight Rewrite (developed it over a coffee break):


    Declare @OldNode Varchar(5)
    Select @OldNode = '90909'

    Declare @OldPath  varchar(1000)
    Select @OldPath = '//90012/90909/90000'

    --if(Len(@OldNode) = 5) -- This will always return true


    Using TSQL:

    1)Assign the value of '90606' to a new variable called NewNode.
    2)Using OldNode and OldPath replace the instance of OldNode in OldPath with the value of NewNode and assign the result to a new variable called NewPath. Print the results to Messages.