久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

截?cái)啾砣缓髮?shù)據(jù)插入同一個(gè)表只插入 1 條記錄

Truncate table then insert data into same table only inserts 1 record(截?cái)啾砣缓髮?shù)據(jù)插入同一個(gè)表只插入 1 條記錄)
本文介紹了截?cái)啾砣缓髮?shù)據(jù)插入同一個(gè)表只插入 1 條記錄的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

有誰(shuí)知道我在這里做錯(cuò)了什么,我有一個(gè)從遠(yuǎn)程來(lái)源獲取貨幣數(shù)據(jù)的網(wǎng)頁(yè),我獲取數(shù)據(jù)并通過(guò)存儲(chǔ)過(guò)程將其插入到 sql 數(shù)據(jù)庫(kù)中.如果我將 truncate 放在 insert 語(yǔ)句的前面,它會(huì)截?cái)啾聿⒉迦胱詈笠粭l記錄.如果我刪除截?cái)啵鼤?huì)插入所有記錄.

Does anyone know what i'm doing wrong here, I have a webpage that gets currency data from a remote source, I get the data and insert it into sql database via a stored procedure. If i put truncate in front of the insert statement, it truncates the table and inserts the last record. If i remove the truncate, it inserts all the records.

truncate table tblTablename;

insert into tblTablename
(columns)
values
(data)

上面將插入 289 條記錄中的最后一條記錄.

The above will insert the last record from 289 records.

如果我刪除 truncate,所有 289 條記錄都會(huì)插入.

If i remove truncate all 289 records are inserted.

我曾嘗試使用waitfor 1 秒鐘,但也未能奏效.

I have tried using waitfor, for 1 second but that failed to work either.

我不知道還能做什么,所以任何幫助將不勝感激

I'm not sure what else to do, so any help would be appreciated

在網(wǎng)頁(yè)中我有一個(gè) foreach 循環(huán)

In webpage I have a foreach loop

喬治

/---------------------- SQL 代碼 -----------------

/---------------------- SQL Code -----------------

  ALTER PROCEDURE [dbo].[atSP_InsertCurrency]
-- Add the parameters for the stored procedure here
@CurrencyCountry VarChar(150),
@CurrencyRate VarChar(150),
@UpdateSuccessFail  INT OUTPUT 
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
TRUNCATE TABLE [dbo].[at_CurrencyRates];

WAITFOR DELAY '000:00:01'


INSERT INTO [dbo].[at_CurrencyRates]
(
    [CurrencyCode],
    [CurrencyExchangeRate]
)
VALUES
(
    @CurrencyCountry,
    @CurrencyRate
)
IF(@@ROWCOUNT > 0)
    BEGIN
    select  @UpdateSuccessFail = '1'
    END
    ELSE
    BEGIN
    select  @UpdateSuccessFail = '0'
    END
END

推薦答案

如果調(diào)用 289 次,則需要將 TRUNCATE TABLE [dbo].[at_CurrencyRates]; 移出存儲(chǔ)過(guò)程逐行插入.

You need to move TRUNCATE TABLE [dbo].[at_CurrencyRates]; out of the stored procedure if you are calling it 289 times to insert row by row.

每次調(diào)用存儲(chǔ)過(guò)程時(shí),它都會(huì)從表中刪除所有行,因此您最終只會(huì)得到剛剛插入的一行.

Every time you call the stored procedure it deletes all the rows from the table so you will always only end up with the one row that you just inserted.

最好改變存儲(chǔ)過(guò)程以一次性插入所有需要的行,而不是一次插入一個(gè).您可以使用表值參數(shù)來(lái)傳遞所有所需的行,然后您只需要一個(gè) TRUNCATE 后跟一個(gè) INSERT [dbo].[at_CurrencyRates] ... SELECT * FROM @TVP.

Better would be to alter the stored procedure to do the insert of all required rows in one go rather than just one at a time. You can use a table valued parameter to pass in all of the desired rows then you would just need a TRUNCATE followed by an INSERT [dbo].[at_CurrencyRates] ... SELECT * FROM @TVP.

這篇關(guān)于截?cái)啾砣缓髮?shù)據(jù)插入同一個(gè)表只插入 1 條記錄的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Modify Existing decimal places info(修改現(xiàn)有小數(shù)位信息)
The correlation name #39;CONVERT#39; is specified multiple times(多次指定相關(guān)名稱(chēng)“CONVERT)
T-SQL left join not returning null columns(T-SQL 左連接不返回空列)
remove duplicates from comma or pipeline operator string(從逗號(hào)或管道運(yùn)算符字符串中刪除重復(fù)項(xiàng))
Change an iterative query to a relational set-based query(將迭代查詢更改為基于關(guān)系集的查詢)
concatenate a zero onto sql server select value shows 4 digits still and not 5(將零連接到 sql server 選擇值仍然顯示 4 位而不是 5)
主站蜘蛛池模板: 日韩久久网 | 色综合久久天天综合网 | 亚洲成网 | 久久一区二区三区免费 | 毛片在线免费 | 色偷偷噜噜噜亚洲男人 | 成人美女免费网站视频 | 激情六月丁香 | 国产精品久久片 | 国产99久久久国产精品 | 免费黄色片在线观看 | 欧美黑人国产人伦爽爽爽 | 91综合网| 中文字幕在线观看一区二区 | 国产亚洲精品一区二区三区 | 日韩视频国产 | 四虎永久影院 | 蜜桃视频在线观看免费视频网站www | 欧美日韩高清一区二区三区 | 日韩高清国产一区在线 | 欧美中文一区 | 一区精品视频 | 精品视频一区二区在线观看 | 国产精品污www一区二区三区 | 久久69精品久久久久久久电影好 | 欧美黄在线观看 | 国产亚洲精品精品国产亚洲综合 | 国产日韩一区二区 | 精品久久久久久 | 成年网站在线观看 | 亚洲国产aⅴ成人精品无吗 亚洲精品久久久一区二区三区 | 成人福利影院 | 欧美专区在线 | 欧美在线播放一区 | 国产91精品久久久久久久网曝门 | 色精品视频 | 日韩高清一区二区 | 91精品国产一区二区 | 蜜臀网 | 国产精品久久视频 | 欧美精品一区二区三区在线播放 |