declare @str varchar(100) set @str=''select @str=@str+','+a.[name] from syscolumns a,sysobjects b where a.id=b.id and b.id=object_id('表名') and a.name not in('列名','列名') order by a.colid set @str=stuff(@str,1,1,'') select @strexec('select '+@str+' from 表名') --这样呢?
declare @str varchar(100) set @str=''select @str=@str+','+a.[name] from syscolumns a,sysobjects b where a.id=b.id and b.id=object_id('表名') and a.name not in('列名','列名') order by a.colid set @str=stuff(@str,1,1,'') select @strexec('select '+@str+' from 表名') --这样呢?
不行 缺了几列 哪出问题了呢?? 我执行这些 declare @str varchar(100) set @str=''select @str=@str+','+a.[name] from syscolumns a,sysobjects b where a.id=b.id and b.id=object_id('表名') and a.name not in('列名','列名') order by a.colid set @str=stuff(@str,1,1,'') select @str 出现了语句顺序正常正常,可是一个字段名缺了个字母,我的字段名叫GRNS 可是最后查出来这个字符串str是GRN 以后的字段就查不出来了
declare @str varchar(1000) set @str=''select @str=@str+','+a.[name] from syscolumns a,sysobjects b where a.id=b.id and b.id=object_id('表名') and a.name not in('列名','列名') order by a.colid set @str=stuff(@str,1,1,'') select @strexec('select '+@str+' from 表名') --把@str的变量的长度加长呢?
这个问题是你解决的 到分就不这样了
http://community.csdn.net/Expert/topic/4629/4629096.xml?temp=.3574793
set @str=''select @str=@str+','+a.[name] from syscolumns a,sysobjects b where a.id=b.id and b.id=object_id('表名') and a.name not in('列名','列名') order by a.colid
set @str=stuff(@str,1,1,'')
select @strexec('select '+@str+' from 表名')
--这样呢?
set @str=''select @str=@str+','+a.[name] from syscolumns a,sysobjects b where a.id=b.id and b.id=object_id('表名') and a.name not in('列名','列名') order by a.colid
set @str=stuff(@str,1,1,'')
select @strexec('select '+@str+' from 表名')
--这样呢?
没必要按顺序ds.tables["table"].row[0]["列名"]
缺了几列 哪出问题了呢??
我执行这些
declare @str varchar(100)
set @str=''select @str=@str+','+a.[name] from syscolumns a,sysobjects b where a.id=b.id and b.id=object_id('表名') and a.name not in('列名','列名') order by a.colid
set @str=stuff(@str,1,1,'')
select @str
出现了语句顺序正常正常,可是一个字段名缺了个字母,我的字段名叫GRNS 可是最后查出来这个字符串str是GRN 以后的字段就查不出来了
set @str=''select @str=@str+','+a.[name] from syscolumns a,sysobjects b where a.id=b.id and b.id=object_id('表名') and a.name not in('列名','列名') order by a.colid
set @str=stuff(@str,1,1,'')
select @strexec('select '+@str+' from 表名')
--把@str的变量的长度加长呢?
ds.tables["table"].row[0][i]
没必要按顺序ds.tables["table"].row[0]["列名"]
我的是一个for循环取的列
比如
for(int i=0;i<5;i++)
{
ds.tables["table"].row[0][i]
}
我是这样动态读取的,如果没有这个顺序我的就没有办法去对应了
--不够长的话就改成8000
太感谢xeqtr1982(ShaKa)了
我要结贴了