现在有个存储过程做判断
表名是用变量传进来的。@table
但是有两种情况 一个是单表
一种是几个表联查我传表的方式是用 比如: 单表: @table= aa
多表:@table= aa a,bb b,cc c 再用where a.id=b.id 不是用的join on
我的想法是 以是否存在逗号来判断是否是多表。不一定是要判断逗号,只要能判断是否是多表就行了,谢谢。
只有30分了 分少见谅
表名是用变量传进来的。@table
但是有两种情况 一个是单表
一种是几个表联查我传表的方式是用 比如: 单表: @table= aa
多表:@table= aa a,bb b,cc c 再用where a.id=b.id 不是用的join on
我的想法是 以是否存在逗号来判断是否是多表。不一定是要判断逗号,只要能判断是否是多表就行了,谢谢。
只有30分了 分少见谅
print'多表'
print '多表'
else
print '单表'
set @table='aa a,bb b,cc c'
if patindex('%[,]%',@table) > 0
print '多表'
else
print '单表'
go
declare @table varchar(20)
set @table='aa a'
if patindex('%[,]%',@table) > 0
print '多表'
else
print '单表'