PDA

View Full Version : converting from Oracle to SQL Server


cuneyt
11-22-02, 03:56
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?

meastland
01-09-03, 17:43
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?