如果(fSortCode,fSortName,fSortIcon)唯一,可以
select fSortGuid from 表 where fSortCode=@fSortCode and fSortName=@fSortName and fSortIcon=@fSortIcon如果不唯一,可以改一下你的存储过程:
declare @fSortGuid uniqueidentifier
set @fSortGuid=newid()
insert into tSort
(fSortGuid,fSortCode,fSortName,fSortIcon)
values
(@fSortGuid,@fSortCode,@fSortName,@fSortIcon)
select fSortGuid from 表 where fSortCode=@fSortCode and fSortName=@fSortName and fSortIcon=@fSortIcon如果不唯一,可以改一下你的存储过程:
declare @fSortGuid uniqueidentifier
set @fSortGuid=newid()
insert into tSort
(fSortGuid,fSortCode,fSortName,fSortIcon)
values
(@fSortGuid,@fSortCode,@fSortName,@fSortIcon)
我先试试,那在tSort表中的默认值newid(),要不要删除呢?另外小弟还有一事相求,
怎么把: 张三|李四|王五.............|....|...
拆成到一个列中??是这样的,
我要在该存储过程中,先对论坛类别进入插入,而且每个论坛都有多个版主,故想对关联表tSort_Host
进入插入!
关联表tSort_Host(fSortGuid,fHostGuid)还得麻烦这位兄台帮我解决!
你有时间,烦请你帮我解决一下上面的附加问题!
declare @str varchar(100)
set @str='张三|李四|王五'
while charindex('|',@str)>0
begin
insert @tb select left(@str,charindex('|',@str)-1)
set @str=stuff(@str,1,charindex('|',@str),'')
end
insert @tb select @strselect * from @tb--结果
/*
name
----------
张三
李四
王五(所影响的行数为 3 行)
*/
declare @str varchar(100)
set @str='张三|李四|王五'
while charindex('|',@str)>0
begin
insert @tb select left(@str,charindex('|',@str)-1)
set @str=stuff(@str,1,charindex('|',@str),'')
end
insert @tb select @strselect * from @tb--结果
/*
name
----------
张三
李四
王五(所影响的行数为 3 行)
*/
declare @str varchar(100)
set @str='张三|李四|王五'
while charindex('|',@str)>0
begin
insert @tb select left(@str,charindex('|',@str)-1)
set @str=stuff(@str,1,charindex('|',@str),'')
end
insert @tb select @strselect * from @tb--结果
/*
name
----------
张三
李四
王五(所影响的行数为 3 行)
*/