字符串变表带有表头

字符串变表带有表头,第1张

概述字符串表带表头

下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。

内存溢出小编现在分享给大家,也给大家做个参考。

declare @LSTR_Inserthead varchar(500)--列名declare @LSTR_InsertFIElds varchar(max)--数据字符串declare @splitrol varchar(2)--行分割符declare @splitcol varchar(2)--列分隔符set @splitrol='⒉'set @splitcol='⒈'set  @LSTR_Inserthead='product⒈unitID⒈levelID⒈cost'--表头参数set @LSTR_InsertFIElds='001888⒈8⒈9⒈¥⒉000507⒈⒈⒈¥⒉001339⒈⒈⒈¥⒉001340⒈⒈⒈¥⒉001335⒈⒈⒈¥'--数据参数set @[email protected][email protected]declare @headStr varchar(20)--列名declare @headsql varchar(200)--列头生成set @headsql='select 'while CHARINDEX('⒈',@LSTR_Inserthead)<>0begin	SET @headStr = substring(@LSTR_Inserthead,1,charindex(@splitcol,@LSTR_Inserthead)-1)--截取表头	if	@headsql='select '		set  @[email protected]+''''' as '[email protected]	else		set  @[email protected]+','''' as '[email protected]	SET @LSTR_Inserthead = stuff(@LSTR_Inserthead,@LSTR_Inserthead),'') --去掉已截取内容end/*以下为生成表*/set  @[email protected]+' where 1=2 union 'set @LSTR_InsertFIElds=REPLACE(@LSTR_InsertFIElds,@splitrol,''' union select ''')set @[email protected]+'select  '''+REPLACE(@LSTR_InsertFIElds,@splitcol,''',''')+''''print(@LSTR_InsertFIElds)exec(@LSTR_InsertFIElds)

以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

总结

以上是内存溢出为你收集整理的字符串变表带有表头全部内容,希望文章能够帮你解决字符串变表带有表头所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/1164804.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-01
下一篇 2022-06-01

发表评论

登录后才能评论

评论列表(0条)

保存