zoukankan
html css js c++ java
SQL将以字符','分隔的字段值,循环插入表中
将以某单字符分隔的字段值,循环插入表
declare
@strChatRooms
nvarchar
(
1000
)
--
自定义参数,含有','符号的值
declare
@UserID
int
--
自定义参数
declare
@tmpNum
int
--
检查','字符,移动的位置
declare
@tmpID
int
--
获取分隔的值,用于插入表
declare
@iSuccess
int
--
返回查看错误
Begin
Tran
--
事例字符串
set
@strChatRooms
=
'
11,12,13,14,15,
'
--
初始化检查','符号位置,符号自定义
set
@tmpNum
=
1
--
进行循环将','符号分隔的数据插入信息表
while
len
(
@strChatRooms
)
>
0
begin
if
substring
(
@strChatRooms
,
@tmpNum
,
1
)
=
'
,
'
begin
set
@tmpID
=
cast
(
left
(
@strChatRooms
,
@tmpNum
-
1
)
as
int
)
set
@strChatRooms
=
right
(
@strChatRooms
,
len
(
@strChatRooms
)
-
@tmpNum
)
set
@tmpNum
=
1
Insert
into
ChatAdmin(UserID,ChatRoomID)
Values
(
@UserID
,
@tmpID
)
if
@@error
<>
0
begin
ROLLBACK
TRAN
set
@iSuccess
=
-
14
return
end
end
else
set
@tmpNum
=
@tmpNum
+
1
end
Commit
Tran
查看全文
相关阅读:
一起学Windows phone 7开发(四. DeepZoom)
设计模式Observer(观察者模式)
今天挺开心
设计模式Singleton(单例模式)
PointFromScreen和PointFromScreen的用法和区别
设计模式Adapter(适配器模式)
设计模式Abstract Factory(抽象工厂)
C++多线程信号量,互斥
linux bash 几个命令
大小端存储
原文地址:https://www.cnblogs.com/hanguoji/p/814413.html
最新文章
Win10如何打开系统服务列表?
HDU 1241 Oil Deposits
HDU 1028 Ignatius and the Princess III
POJ 1961 Period
HDU 1181 变形课
HDU 1425 sort
SDUT 2132 数据结构实验之栈二:一般算术表达式转换成后缀式
STL常用算法[转]
背包九讲[转]
HDU 1047 Integer Inquiry
热门文章
HDU 1262 寻找素数对 2098分拆素数和
[原创]准妈妈孕周计算器小软件 release版(mobile 版 )
Windows phone 7之初体验(七.微软真机秀)
一起学Windows phone7开发(五.一个时钟的例子)
Windows Phone 7之初体验(六.完整版模拟器)
一起学Windows phone 7开发(一.Application Bar)
Windows Phone 7之初体验(四.平台架构简介)
Windows Phone 7之初体验(五.我的第一个应用程序)
一起学Windows phone 7开发(二.页面间跳转与传值)
一起学Windows phone 7开发(三.页面)
Copyright © 2011-2022 走看看