FirebirdSQL/最後篇 Firebird 綜合篇/FireBird&SQLServer

出自VFP Wiki

(修訂版本間差異)
跳轉到: 導航, 搜尋
(WHILE 條件使用的差異)
(迴圈使用上的差異)
第44行: 第44行:
=== 迴圈使用上的差異 ===
=== 迴圈使用上的差異 ===
-
------
+
<pre>
/* This is the original MS SQL statement, using the
/* This is the original MS SQL statement, using the
* traditional pubs database.*/
* traditional pubs database.*/
第90行: 第90行:
END
END
END
END
 +
</pre>
=== WHILE 條件使用的差異 ===
=== WHILE 條件使用的差異 ===

在2005年2月19日 (六) 01:38所做的修訂版本

'''[[== 文章未翻譯完成,請等待.. ==]]'''


目錄

如何從Microsoft SQL Server轉換到FirebirdSQL


Microsoft SQL Server適用的版本:MS SQL 6.5, MS SQL 7 and MS SQL 2000.

原文來自Marcelo Lopez Ruiz marcelo.lopezruiz@xlnet.com.ar

欄位型態對照表


MSSQL版本 Data Type Firebird MSSQL definition and comments
6.5 bigint INT64 8-byte integer type.


變數使用上的差異


For example, compare the following code snippets. /* This is MS SQL syntax. */ CREATE PROCEDURE my_procedure AS DECLARE @my_variable int SET @my_variable = 5

/* This is FireBird syntax. */ CREATE PROCEDURE my_procedure AS DECLARE VARIABLE my_variable int BEGIN my_variable = 5; END


迴圈使用上的差異

/* This is the original MS SQL statement, using the
* traditional pubs database.*/
CREATE PROCEDURE list_states
AS
SELECT
CASE state
WHEN 'CA' THEN 'California'
WHEN 'UT' THEN 'Utah'
ELSE 'unknown'
END
FROM authors

/* This is how it can be converted to Firebird. */
/* Isolate the CASE statement. */
CREATE PROCEDURE get_state_name (
state_code char(2)
) RETURNS (
state_name varchar(64)
)
AS
BEGIN
IF (state_code = 'CA') THEN
state_name = 'California';
ELSE IF (state_code = 'UT') THEN
state_name = 'Utah';
ELSE
state_name = 'unknown';
END

/* This is the selectable stored procedure. */
CREATE PROCEDURE list_states
RETURNS (state varchar(64))
AS
DECLARE VARIABLE short_state CHAR(2);
BEGIN
FOR
SELECT state
FROM authors
INTO :short_state
DO BEGIN
EXECUTE PROCEDURE get_state_name :short_state
RETURNING_VALUES :state;
SUSPEND;
END
END

WHILE 條件使用的差異


/* Firebird syntax. */ 
WHILE (i < 3) DO BEGIN
i = i + 1; 
j = j * 2; 
END 
/* MS SQL syntax. */ 
WHILE (i < 3) BEGIN 
SET @i = @i + 1 
SET @j = @j * 2 
END 

參考文章