Migrate the data script under SQL Server to Sybase Asa

zhaozj2021-02-16  87

I need to change the data script previously implemented in SQL Server to ASA, you need to pay attention to the following points (SQLSERVER below) (ASA)

Nchar ???????????? ----> char * 2

Nvarcher ?????? -----> varcher * 2

Finishing ";" -----> The end is not added ";", ASA ";" equivalent to "go"

EXEC (@SQL) ??? -----> exec @SQL ?? Execute the storage process,

?????????????????????? -> execute (@SQL) execute SQL statement

?????????????????????? ----> execute @SQL execution storage process

SET ?? l ?? SELECT? @variant = "" -----> SELECT @ variant = ""

After ??????? -----> for

? Next, a few common examples:

1, create triggers

--------------- SQL Serverif EXISTS (Select * from dbo.sysObjects where id = Object_id (n '[dbo]. [TRGNAME]') And ObjectProperty (ID, N'ISTRIGER ' ) = 1)? DROP TRIGGER [DBO]. [TRGNAME] Create Trigger TRGNAME ON? TABLENAME? AFTER DELETE AS

-------- Trigger content GO

--------------- ASA Trigger line level INSERT trigger CREATE TRIGGER CHECK_BIRTH_DATE? AFTER INSERT ON EMPLOYEE? - Insert Create Trigger MyTrigger Before Insert on Employe ?? - Trigger before insertion REFERENCING NEW AS new_employeeFOR EACH ROWBEGIN ?? DECLARE err_user_error EXCEPTION ?? FOR SQLSTATE '99999'; ?? IF new_employee.birth_date> 'June 6, 2001' THEN ????? SIGNAL err_user_error; ?? END IF; ENDDELETE trigger example CREATE tRIGGER mytrigger BEFORE DELETE ON employeeCREATE tRIGGER mytrigger AFTER UPDATE ON employeeREFERENCING OLD AS oldtableFOR EACH ROWBEGIN ?? ... END statement-level UPDATE trigger example CREATE tRIGGER mytrigger AFTER UPDATE ON employeeREFERENCING NEW AS table_after_update ?????????? ? Old as table_before_updatefor each statementbegin ?? ... End

2, query specified table column name and type

SQL Server 2000:??? Select sc.name, st.name from syscolumns as sc INNER join systypes as st on st.xtype = sc.xtypewhere sc.id in (select id FROM sysobjects WHERE name = 'TableName' AND type = 'U') order by idASA: select column_name, domain_name from SYS.SYSCOLUMN join SYS.SYSDOMAIN where table_id in (select table_id from SYS.SYSTABLE where table_name = 'TableName') order by column_id

3, create a storage process

----------- SQL Serverif Exists (Select * from dbo.sysObjects where id = Object_id (n '[dbo]. [Proname]') And ObjectProperty (ID, n'isprocedure ') = 1) Drop Procedure [DBO]. [PRONAME] CREATE PROCEDURE PRONAME? @ Name1? Nvarchar (256) ,? @ Name2? Nvarchar (256) = nullas ------------- Content GO

----------- Asaif EXISTS (?? SELECT 1 from sys.sysprocedure ?? Where proc_name = 'proname' ???? And create = user_id ('dba'))? Drop Procedure DBA.proname

GOCREATE Procedure AddSubscribeInfo @ name1? Varchar (512), @ name2? Varchar (512) = nullas ------------- Content GO

转载请注明原文地址:https://www.9cbs.com/read-11645.html

New Post(0)