Thursday, October 14, 2010

Some of the difference between MSSQL and MYSQL Syntax are as follows:

1) MSSQL support UDD(User Defined DataTypes), MYSQL does not support UDD

2) Use of -- for comment a line purpose in MSSQL, in otherside use /* */ or -- comments

3) Use prefix @symbol for variable in MSSQL, whereas in MYSQL remove @symbol.
e.g. declare @test int -- MSSQL Syntax
declare test int; --MYSQL Syntax

4) End marker(;) not required in MSSQL but in MYSQL all statement end with marker (;)

5) In MSSQL use SELECT getdate() for getting today's date , in MYSQL use SELECT now()

6) All queries should be available in Begin tran and Commit(Rollback) tran loop in MSSQL,
whereas MYSQL Start transaction and commit(Rollback) transaction.

7) Getting Top most record in MSSQL, Use SELECT TOP1 from Table_Name where
In MYSQl SELECT from Table_Name where limit 1;

8) For viewing table information use Sp_help Table_name in MSSQL, but in MYSQL use show table_name;

9) Use of + for concatenate two stings in MSSQLL whereas MYSQL SELECT concat('a','/','b')

10)In MSSQL SP_HELPTEXT for viewing the content of sp in otherside use the following syntax.
select routine_definition from information_schema.routines
where specific_name =
and routine_schema = ;

11)For assigning value to variable use Set @variable1 = 'test' in MSSQL,
but in MYSQL use Set variable =1 or set 1 into variable1;

12)In MSSQl, use of IF statement syntax,
Whereas in MYSQL,
if Then
leave sp_label;
end if;

13) In MSSQL Use RETURN Statement for returning values but in MYSQL use leave sp_level;

14) The convert datatype Syntax in MSSQL is select convert(type,expression) whereas in MYSQL select convert(expression,type);

15) In MSSQL the Dynamic SQL statement is
SELECT @a ='SELECT * from Table_Name where
execute (@a)
Prepare stmt1 from 'select * from Table_Name where column_name =?'
Set @a ='Value';
execute stmt using @a;

No comments:

Post a Comment