本文介绍了将我的sql过程转换为sql server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好朋友,这是一个在temp表中复制表数据的mysql程序.我在mysql中没有工作.请您帮我将其转换为sql server程序 提前感谢朋友.
hello friends ,this is a mysql procedure to copy a table data in temp table .I have not work in mysql.Can yuo please help me in converting it to sql server procedure .Thanks in advance freinds.
CREATE PROCEDURE sp_category_select3() as BEGIN declare done int default 0 declare categoryid int declare categoryname varchar(100) declare groupunderid int declare groupundername varchar(50) declare alias varchar(100) declare supercategory varchar(100) declare NotZero int default 0 declare cur1 cursor for select c.lcategoryid, c.ccategoryname, c.lundercategoryid, c.calias, s.csupercategoryname from category c inner join supercategory s on c.lsupercategoryid=s.lsupercategoryid where c.bdeleteflag=0 declare continue handler for not found set done = 1 drop table if exists temptablecategory create temporary table temptablecategory(cat_id int, cat_name varchar(100), cat_underid int, cat_under_group varchar(100), cat_alias varchar(100), cat_super varchar(100)) open cur1 repeat fetch cur1 into categoryid, categoryname, groupunderid, alias, supercategory set groupundername="" if not done Begin if groupunderid=0 Begin set groupundername="" elseif groupunderid<>0 Begin set groupundername=(select distinct c.ccategoryname as undercategoryname from category as c inner join category as d on c.lcategoryid=d.lundercategoryid where d.lundercategoryid=groupunderid and c.bdeleteflag=0) End insert into temptablecategory values(categoryid, categoryname, groupunderid,groupundername, alias, supercategory) End until done end repeat close cur1 select * from temptablecategory drop table temptablecategory END */$$ Go推荐答案
转到
语法对于MySQL而言并没有太大不同.您的代码使用cursor&您可以检查以下代码作为MySQL中游标的参考: www.java2s/Tutorial/MySQL/0240__Cursor/Usingwhilelooptoloopthroughacursor.htm [ ^ ] the syntax is not very different for MySQL. your code uses cursor& you can check the following code as a reference for cursors in MySQL: www.java2s/Tutorial/MySQL/0240__Cursor/Usingwhilelooptoloopthroughacursor.htm[^]
更多推荐
将我的sql过程转换为sql server
发布评论