There are databases on Firebird and SQL Server. I have working stored procedure in Firebird.
Question is: how to translate it to T-SQL syntax?
begin
IF ((:PHONE_N is NULL) or (STRLEN(:PHONE_N)<1)) THEN
BEGIN
O_PHONE_N = NULL;
EXIT;
END
IF (STRLEN(PHONE_N) > 3) THEN
BEGIN
O_PHONE_N = '(' || SUBSTR(:PHONE_N, 1, 3) || ') ';
PHONE_N = SUBSTR(:PHONE_N, 4, STRLEN(:PHONE_N));
IF (STRLEN(:PHONE_N)> 3) THEN
begin
O_PHONE_N = O_PHONE_N || SUBSTR(:PHONE_N, 1, 3);
PHONE_N = SUBSTR(:PHONE_N, 4, STRLEN(:PHONE_N));
IF (STRLEN(:PHONE_NUMBER)> 0) THEN
O_PHONE_N = O_PHONE_N || '-' ||:PHONE_N;
END
ELSE
O_PHONE_N = :O_PHONE_N || :PHONE_N;
END
ELSE
O_PHONE_N = :PHONE_N;
end
This link might help a bit: http://www.firebirdsql.org/manual/migration-mssql-syntax.html
This might help a bit:
@marks a T-SQL variable (e.g.@phone_n)STRLENis calledLEN()in T-SQLSUBSTRisSUBSTRINGCheck out the excellent MSDN documentation on T-SQL for more details on T-SQL syntax