怎麼來更新需要的資料?

2021-06-15 22:34:00 字數 1654 閱讀 1205

有張資料庫a表

商品編碼    商品名稱    標誌    數量      單價       總價     日期

00100       數位相機      0      2        2500       5000    2007-02-01

00200       u盤           0      3        200        600     2007-01-01

00500       u盤           0      1        300        300     2007-01-01

c盤裡有個a.txt檔案,裡面有如下資料:(商品編碼、名稱、**和備註)

"110100","數位相機",2500,""

"20200","u盤",200,""

現在要把c盤a.txt裡的商品編碼作為判斷條件來更新a表裡的標誌,a表要實現的結果:

商品編碼    商品名稱    標誌    數量      單價       總價     日期

00100       數位相機      1      2        2500       5000    2007-02-01

00200       u盤           1      3        200        600     2007-01-01

00500       u盤           0      1        300        300     2007-01-01

測試環境

create table a

(商品編碼  char(5),

商品名稱  nvarchar(10),

標誌  bit,

數量  int,

單價  int,

總價  int,

日期  varchar(10))

insert a select '00100',       n'數位相機',      0,      2,        2500,       5000,    '2007-02-01'

union all select '00200',       n'u盤',               0,      3,        200,         600,      '2007-01-01'

union all select '00500',       n'u盤',               0,      1,        300,         300,      '2007-01-01'

怎麼來建臨時表更新呢?

create procedure sp_test

asbegin

create table #t(商品編碼 char(5),名稱 nvarchar(10), ** int, 備註 nvarchar(100))

bulk insert #t

from 'c:/a.txt'

with (

fieldterminator =',',

rowterminator ='/n'

) update a set 標誌 = 1 from a inner join #t b on a.商品編碼 = b.商品編碼

drop table #t

endgo

exec sp_test

select * from a

4 5 怎麼來的

step1 4的補碼 正數的原碼 補碼 反碼都相同為0100,第一位為符號位,0為正,1為負。step2 為按位取反,包含第一位的符號碼,此時補碼變為1011,要求該補碼對應的十進位制數值 step3 補碼 反碼 1,反碼為1010 原碼 反碼按位取反 不包含第一位的符號碼 原碼為1101 step...

SEO優化高階的內容更新怎麼來做更合適?

seo優化高階的內容更新怎麼來做更合適?內容更新對seo的意義 一般來說對於 內容更新有三種,一種是純複製,第二種是偽原創,第三種是純原創。對於 seo來說自然是純原創效果最好,但是同樣的相對而言純原創成本最高。所以正常來說,www.ymjump.com 我們會選擇偽原創。但是偽原創不是簡單的用一些...

java se web向需要的資料整理2(更新中)

ploymorphism upcase downcase eg class father public class son extends father public void say1 public static void main string args instanceof this keyw...