以下SQL Server语句在Oracle中将是什么?

时间:2018-10-16 16:22:36

标签: sql sql-server oracle tsql

我正在学习SQL Server与Oracle之间的区别,我想知道SQL Server中的以下语句在Oracle中会是什么:

DECLARE @Temp INT

SET @Temp = 9000

PRINT 'It's Over' + @Temp;

谢谢。

编辑:当然,该死的语法,也需要转换,感谢db提琴工具会大量使用它!

1 个答案:

答案 0 :(得分:3)

SQL Server:

Declare @Temp INT;
SET @Temp = 9000;           -- adding semicolons is a good practice
PRINT 'It's Over' + @Temp;  -- this line won't work at all 

-- should be
PRINT 'It''s Over' + CAST(@Temp AS VARCHAR(10));

Oracle:

DECLARE
   Temp INT;
BEGIN
   Temp := 9000;
   DBMS_OUTPUT.PUT_LINE('It''s Over' || Temp);
END;

db<>fiddle demo

相关:Guide to Migrating from Oracle to SQL Server 2014 and Azure SQL Database