Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7666455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:50:13+00:00 2026-05-31T14:50:13+00:00

I am beginner at SQL. I am doing research about managing hierarchical data by

  • 0

I am beginner at SQL. I am doing research about managing hierarchical data by using ms sql r2 2008. Here is the link from where I referred
http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/
But now I having a problem in Finding the Depth of the Nodes
I Copy the sql query to my ms sql

SELECT CONCAT( REPEAT(' ', COUNT(parent.name) - 1), node.name) AS name
FROM nested_category AS node, nested_category AS parent
WHERE node.lft BETWEEN parent.lft AND parent.rgt
GROUP BY node.name
ORDER BY node.lft;

It return me

Msg 195, Level 15, State 10, Line 1 ‘REPEAT’ is not a recognized built-in function name.

Can anyone please help me correct the sql query?
In addition, anyone got a better solution for manage hierarchical data?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T14:50:15+00:00Added an answer on May 31, 2026 at 2:50 pm

    You using code from a MySQL article on MS SQL Server.

    Much will translate fine, but much won’t. As @FilipDeVos says, the equivilent to REPEAT() in SQL Server is REPLICATE(), and you’re going to find many more cases like this.

    When you find them, you need to search on line for the SQL Server equivilent to the MySQL statements that you are using.

    As for different methods of managing hierarchies, the most common is probably adjaceny-lists, then nested-sets that you’re using in that article. It depends on your needs, keep researching, there is no universall golden answer.

    EDIT

    If you keep going through that article and ask here about every difference, you’ll be here forever. You need to search the web for your answers 😉

    But, for now, after your added question about CONCAT(), try this…

    SELECT REPLICATE(' ', COUNT(parent.name) - 1) + node.name AS name 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please help this beginner here... I have a SQL Server 2008 R2 running on
I'm using this simple SQL query to retrieve data from two tables in my
I am a beginner at SQL and I don't know much about Transact-SQL. I
SQL beginner here. I have a query which takes around 10 seconds to run,
I am a beginner in sql server.I have read about buffer cache in sql
I am very beginner in SQL Server 2005 and I am learning it from
I am going out of my mind here ... I am an SQL beginner
SQL server 2008 sp2 I am a beginner and finding that XQuery syntax especially
I'm a beginner in sql and I am doing this through a php document.
SQL 2008 - Beginner to DBA I am confused between SQL Server Network Configuration

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.