码迷,mamicode.com
首页 > 数据库 > 详细

SQL 批量插入和更改数据

时间:2016-01-04 17:05:28      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:sql

批量插入数据:

declare @i int
set @i = 12 
while @i < 14
begin 
INSERT INTO [mdm1220].[dbo].[DEVICE]
           ([SERIAL_NUMBER]
           ,[IMEI]
           ,[WIFI_MAC_ADDR]
           ,[BLUETOOTH_MAC_ADDR]
           ,[ACTIVESYNC_ID]
           ,[STRONG_ID]
           ,[LAST_INVENTORY_TIME]
           ,[FIRST_CONNECTION_DATE]
           ,[LAST_AUTH_DATE]
           ,[LAST_USERNAME]
           ,[LAST_PROFILE_INVENT_TIME]
           ,[OS_FAMILY]
           ,[LAST_USER_ID]
           ,[WHITELIST_COMPLIANT]
           ,[BLACKLIST_COMPLIANT]
           ,[DEVICE_PROPERTIES_TIMESTAMP]
           ,[ALL_WHITELIST_COMPLIANT]
           ,[LAST_ACTIVITY]
           ,[MANAGED]
           ,[COOKIE_TOKEN]
           ,[COOKIE_EXP]
           ,[SHARED_STATUS]
           ,[PROFILE_STATUS])

    VALUES
           (@i
           ,‘35 698206 450366 6‘
           ,‘64:9A:BE:85:7E:81‘
           ,‘64:9A:BE:85:75:67‘
           ,‘2TQ3F2Q4VT69V447KFOP7REQQ4‘
           ,‘CF8Q44AA‘
           ,‘2015-12-31 01:03:07.993‘
           ,‘2015-12-30 23:08:30.497‘
           ,‘2015-12-31 01:03:08.323‘
           ,‘huifu2@worx.net "huifu2 wen"‘
           ,‘2015-12-31 01:03:08.243‘
           ,‘ANDROID‘
           ,11
           ,1
           ,1
           ,‘2015-12-30 23:09:38.317‘
           ,1
           ,‘2015-12-31 01:03:08.323‘
           ,1
           ,NULL
           ,NULL
           ,0
           ,0
           )
           
    set @i = @i + 1

end

更新数据

declare @i int
set @i = 1 
while @i < 14

begin 

UPDATE [mdm1220].[dbo].[DEVICE]
   SET ACTIVESYNC_ID = ‘ActiveSyncChangedFOP7REQQ4‘

   WHERE ACTIVESYNC_ID = ‘2TQ3F2Q4VT69V447KFOP7REQQ4‘
 

   set @i = @i + 1

end


SQL 批量插入和更改数据

标签:sql

原文地址:http://huifu.blog.51cto.com/2107077/1731374

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!