将我的sql过程转换为sql server

编程入门 行业动态 更新时间:2024-10-27 18:29:07
本文介绍了将我的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

本文发布于:2023-10-23 08:17:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1520291.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   过程   sql   server

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!