我在下面的表格里有数据,
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tbl_Test](
[Id1] [int] NOT NULL,
[Id2] [int] NOT NULL,
[id3] [int] NOT NULL,
[D_OldValue] [varchar](100) NOT NULL,
[R_Value] [varchar](100) NOT NULL,
CONSTRAINT [PK_tbl_Test] PRIMARY KEY CLUSTERED
(
[Id1] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
USE [temporary_databases];
SET NOCOUNT ON;
SET XACT_ABORT ON;
GO
BEGIN TRANSACTION;
INSERT INTO [dbo].[tbl_Test]([Id1], [Id2], [id3], [D_OldValue], [R_Value])
SELECT 437, 163, 163, N'BW', N'Ford' UNION ALL
SELECT 493, 163, 163, N'BW', N'Stock' UNION ALL
SELECT 1224, 163, 163, N'BW', N'Wood' UNION ALL
SELECT 1225, 163, 163, N'BW', N'FRD' UNION ALL
SELECT 1232, 163, 163, N'BW', N'COW' UNION ALL
SELECT 1240, 163, 163, N'BW', N'FRD1' UNION ALL
SELECT 2160, 163, 163, N'BW', N'Log'
COMMIT;
RAISERROR (N'[dbo].[tbl_Test]: Insert Batch: 1.....Done!', 10, 1) WITH NOWAIT;
GO
我的excel里有如下要求
+------+-----+-----+
3条答案
按热度按时间dwbf0jvd1#
--+---------+
wi3ka0sx2#
--+
现在我需要用d\u newvalue(excel表)更新(tbl\u test)中的d\u oldvalue列,我已经尝试过像update tbl\u test set d\u oldvalue='bf'这样的简单更新查询,其中d\u oldvalue='bw',但它会将所有bw更新为bf最终输出应该是
flvlnr443#
通过使用下面的查询,所有行都将被更新。如果要更新特定行,请添加where条件