星空网 > 软件开发 > 数据库

根据目标列的内容使用sql获取列名

    最近需要将房源数据以

declare @tableName varchar(30),@columnStr varchar(200)declare @column varchar(30),@str varchar(300)--要查询的表名set @tableName='article'--要查询的内容set @columnStr='花'declare cur cursor forSelect name from syscolumns Where ID=OBJECT_ID(@tableName) open cur fetch next from cur into @column while (@@FETCH_STATUS=0)  begin   set @str='declare @count int	 set @count=( select top(1) 1 from '+@tableName+' with(nolock) where '+@column +' like ''%'+@columnStr+'%'' )	 if @count=1	 begin	  print '''+@column+char(13) +''' 	 end'	 fetch next from cur into @column	EXEC(@str);  end  close cur  deallocate cur

      期望这段代码能够对有相同需求的人有所帮助。




原标题:根据目标列的内容使用sql获取列名

关键词:sql

sql
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

亚马逊卖断货!“粉红幽灵毛毯”被TikTok带爆:https://www.kjdsnews.com/a/1603051.html
企业短视频引流全流程:https://www.kjdsnews.com/a/1603052.html
一跨境服务商冲刺IPO;鄂州花湖机场完成货运航线转场工作:https://www.kjdsnews.com/a/1603053.html
广告CPC过高该如何有效解决?:https://www.kjdsnews.com/a/1603054.html
2023年谷歌广告投放新思路:https://www.kjdsnews.com/a/1603055.html
8月海外热门广告素材盘点:6秒视频单日播放破百万!在国外真的很吃香:https://www.kjdsnews.com/a/1603056.html
黔南瓮安AAA以上旅游景点 黔南瓮安aaa以上旅游景点:https://www.vstour.cn/a/408237.html
泰国甲米,曼谷怎么玩?有哪些景点和去处值得:https://www.vstour.cn/a/408238.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流