Hierarchical table sorting with a parent-child relationship

This code snippet works beautifully. Just replace the table/field names like so: 

  • AccountID with ID of your child record
  • name with name of your child record
  • parentID with the parent ID of of your child record
  • @tbl_accounts with the name of your hierarchical table

Run and done:

with cte as
(
select
    Accountid,
    name,
    parentid,
    cast(row_number()over(partition by parentid order by name) as varchar(max)) as [path]
from @tbl_accounts
where parentid = 0
union all
select
    t.AccountID,
    t.name,
    t.ParentID,
    [path] + cast(row_number()over(partition by t.parentid order by t.name) as varchar(max))
from
30.    cte
join @tbl_accounts t on cte.AccountID = t.ParentID
)
 
select 
    Accountid,
    name,
    ParentID,
    [path]
from cte
order by path

 

Thanks, Kev Riley!

http://ask.sqlservercentral.com/questions/48518/hierarchical-table-sorting-with-a-parent-child-rel.html

7 Ways BYOD (Bring Your Own Device) Can Boost Business

http://venturebeat.com/2012/05/13/7-ways-byod-will-boost-your-business/

While IT managers may cringe each time they hear “can you help me connect my iPad to the company server,” here are seven reasons businesses should embrace the consumerization of IT.

1. Real-time communication
In their personal lives, people are becoming more and more accustomed to web-based communication channels outside of email. When people are used to FaceTime, chat, and instant messaging at home, the act of sending an email to a vendor, or even sending a fax to a lawyer, seems like an artifact from a different, and far slower, era. If I can chat with my friends on Facebook, why can’t I interact with co-workers on our CRM system? Why I can’t I have a secure instant message session with my lawyer?

The socialization of enterprise applications gives workers, clients, colleagues, customers, and vendors better tools to communicate in real time. These tighter communication loops should ultimately drive key performance goals for any business, including employee productivity, operational efficiency, and customer satisfaction.

2. Greater accessibility
While traditional enterprise systems trap data in a single location, the cloud makes applications and business data available to more users on more devices in more locations. For employees, this can be a game changer, as the information they need is right at their fingertips – whether they’re at a client location, on route to a meeting, at home, or on vacation.

3. End-user buy-in
Ultimately the success of any technology initiative hinges on the ability to convince employees to actually use the software, device, or process. When employees clamor to bring their own tools into the workplace, there’s no risk that a new tool will sit idly by.  Throwing employees in front of a stodgy application is hardly a recipe for success. Rather, end users are more likely to use those tools that evoke the same look and feel of their friendly social networks and consumer apps.

4. Shorter end-user learning curve
A savvy workforce, familiar with its own favorite tools, can dive right into technology that leverages consumer elements in the corporate environment. Training costs go down, and employees can be productive with their new tools right out of the gate.

5. Affordability
Cloud-based applications shift the financial costs from the upfront capital expense of purchasing software licenses to an ongoing operating expense. When calculating the total cost of ownership, the benefits of cloud-based tools go beyond the cost of subscription vs. software seat to include: lower management costs, lower provisioning and upgrade hassles, and lower hardware costs. A 2009 report from Forrester Research concluded that Google Apps costs less than a third as much as on-premise email for equipping 15,000 employees with email.

6. Security
While data is often the chief concern holding businesses back from the cloud, web-hosted applications can actually increase data security, particularly for those small to mid-sized companies that don’t have proper in-house technical expertise or resources like a dedicated, lockable server room. In these cases, off-premise storage removes the company’s sensitive data from on-premise risks, such as access by cleaning staff, employee error, even physical threats like earthquake and fire.

7. Productivity
Consider for a moment who is behind the consumerization of IT. While Apple may benefit greatly as iPads and iPhones cross over to the enterprise, it’s the employee and not Apple who is pushing to use these devices for work. At the heart of this trend is the simple idea that employees know which tools can make their work day easier and, hopefully, happier.

The key question to ask is: If employees are asking to use their own tools so they can be more productive in the office or catch up on work after hours, is that such a scary prospect?

Apply excel formula to entire column – without dragging the mouse

http://answers.yahoo.com/question/index?qid=20080804112727AA9LUBh

copy your formula. Then go to a column that has figures all the way down all […] rows, press <End><Down>. This will shoot you all the way to the very bottom of that column. Now move back over to the column where your formula is. Hold down your <Shift> key, press <End><Up>. This will shoot you all the way back up to your original formula, and because you held down the <Shift> key, it will highlight all […] rows. Now press <Enter>. Voila!