Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2002
    Posts
    59

    Unanswered: converting from Oracle to SQL Server

    I have this Oracle Sql statement but I need to convert it to SQL Server Statement.
    "SELECT LPAD('-', 2*(LEVEL-1),'-') || DESCRIPTION DESCRIPTION, LEVEL_CODE
    FROM T_NBS_LEVELS"SQLStr=SQLStr&"
    START WITH PARENT_CODE = 0"SQLStr=SQLStr&"
    CONNECT BY PRIOR LEVEL_CODE=PARENT_CODE "

    Sql Server gives Run time error message which is about LPAD is not recognized etc...

    Also does anybody know a tool that converts Oracle Sql statements to SQL Server Statement?

  2. #2
    Join Date
    Oct 2001
    Posts
    1
    since you know the total length that you want to display, you can use the replicate function, along with the length function.

    Say that you want to "LPAD" the au_lname field in the pubs..authors table so that it displays a total of 25 characters. You could use the following code:

    use pubs
    go
    select replicate('*', 25 - (len(au_lname))) + au_lname
    from authors

    Hope this helps. And BTW, I don't think that there is a tool to convert PL/SQL to T-SQL. Even if there was, would you trust it to convert your code correctly?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •