Sql server 常用代码合集(长期更新……)

1.根据字段名查找其所在的数据表

select a.name 表名,b.name 列名 from sysobjects a,syscolumns b where a.id=b.id and b.name='gx1' and a.type='U'
--“gx1”改为自己要查找的字段
select [name] from sysobjects where id in(select id from syscolumns Where name='字段名')

2.取“*”号后面部分

如字段内容【我是*华仔】,该语句会取【华仔】 二字

substring(字段,charindex('*',字段,0)+1,100)

3.取“*”号前面部分

如字段内容【我是*华仔】,该语句会取【我是】二字

left(字段,charindex('*',字段)-1)
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容