常用sql语句
1.将字段前四位替换
update [TDCBJYQSN].[dbo].[XZQH] set XZQHBM ='5405'+substring(XZQHBM,5, len(XZQHBM)) WHERE left(XZQHBM,4)='5422'
2.从一个表中查询数据,保存进另一个表中
INSERT INTO [TDCBJYQSN].[dbo].[XZQH] select [QSDWMC],[QSDWDM] FROM [XZQH].[dbo].[QSDWDMB]
3.将乡镇的行政区划代码改为9位
update QSDWDMB set QSDWDM = SUBSTRING(QSDWDM,1,12) where QSDWDM like '540521%' and SUBSTRING(QSDWMC,LEN(QSDWMC),1) in ('镇','乡')
持续更新中~~~~
钻研不已,转载请注明出处。