Oracle Select into is replaced with SQL Server

Source: Internet
Author: User
Tags rtrim

--oracle:declare n_count int;begin  Select Count (*) into N_count from from  m_test where entitylsh = 1;  Dbms_output.put_line (N_count); End --sql server:declare @is_exist_alert3 int; Select @is_exist_alert3 =count (*) from m_test where Entitylsh = 1;print (@is_exist_alert3);

The above single change from the expression of meaning, there are other differences

Differences encountered when using in triggers

--oraclecreate OR REPLACE TRIGGER tr_inst_alarm    before INSERT on m_alarm for each    rowbegin    select Entity_ SEQ. Nextval into:new. Entitylsh from dual;    Select ' A_ ' | | Trim (To_char (: New. Entitylsh, ' 00000000 ')) into                            : New. Alarmindex from dual; End;--entity_seq. Nextval take sequence next--the first SELECT statement means that the next value of the sequence is assigned to the Entitylsh field in the system table (new)--The second SELECT statement means to modify the system table (new) The Entitylsh field in the method of labeling and inserting--new is equivalent to inserting a table, which is maintained by the system as the table structure in the INSERT statement you trigger this trigger--sql servercreate TRIGGER Tr_inst_alarmon m_ Alarminstead of insertasbegindeclare @index varchar, @Orderindex varchar; Select @index =next value for Entity_seq ; Select @Orderindex = ' A_ ' +rtrim (LTrim (Right (cast (' 00000000 ' +rtrim (CAST (@index as int) as varchar)), INSERT Into M_alarm select @index           , @Orderindex           , Alarmdepartment           , Typemethodindex           , Alarmphenomenon           , ENTITYTYPE from Inserted; end;--meaning as above,--insert is similar to new in Oracle

  

Oracle Select into is replaced with SQL Server

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.