【发布时间】:2020-05-04 09:13:00
【问题描述】:
我需要将输入参数值传递给 LIKE 运算符,以用于表 BillOfMaterials 中名为 BillOfMaterialsID 的列。 如果我们想对值进行硬编码,我们将使用 OR 运算符,如下所示,
SELECT *
FROM [AdventureWorks2017].[Production].[BillOfMaterials]
Where StartDate>='2010-05-26 00:00:00.000' and StartDate<'2010-07-08 00:00:00.000'
AND (BillOfMaterialsID LIKE '%' + '308' + '%' OR BillOfMaterialsID LIKE '%' + '335' + '%' OR BillOfMaterialsID LIKE '%' + '27' + '%')
但是如果输入值是根据 Input Filter 值动态变化的,那么我们应该如何在 SQL Server 中处理这样的条件呢?
例如,我在报表应用程序中有 3 个输入参数,即开始日期时间、结束日期时间和 BillOfMaterialsID。 开始日期时间和结束日期时间值将在 Calender Pick 中选择,对于输入 BillOfMaterialsID,我们有文本框。
所以无论我们用逗号分隔输入什么代码,所有值都应该单独应用于查询条件和应该通过的 SQL 语句 从应用程序到数据库如下所示,
SELECT *
FROM [AdventureWorks2017].[Production].[BillOfMaterials]
Where StartDate>='2010-05-26 00:00:00.000' and StartDate<'2010-07-08 00:00:00.000'
AND (BillOfMaterialsID LIKE '%' + '308' + '%' OR BillOfMaterialsID LIKE '%' + '335' + '%' OR BillOfMaterialsID LIKE '%' + '27' + '%')
ELSE 任何方式都受到高度赞赏,因为我对逻辑很感兴趣。
CREATE TABLE [Production].[BillOfMaterials](
[BillOfMaterialsID] [int] IDENTITY(1,1) NOT NULL,
[ProductAssemblyID] [int] NULL,
[ComponentID] [int] NOT NULL,
[StartDate] [datetime] NOT NULL,
[EndDate] [datetime] NULL,
[UnitMeasureCode] [nchar](3) NOT NULL,
[BOMLevel] [smallint] NOT NULL,
[PerAssemblyQty] [decimal](8, 2) NOT NULL,
[ModifiedDate] [datetime] NOT NULL
)
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (893, NULL, 749, CAST(N'2010-05-26T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-05-12T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (271, NULL, 750, CAST(N'2010-03-04T00:00:00.000' AS DateTime), CAST(N'2010-05-03T00:00:00.000' AS DateTime), N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-05-03T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (34, NULL, 750, CAST(N'2010-05-04T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-04-20T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (830, NULL, 751, CAST(N'2010-05-26T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-05-12T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (2074, NULL, 752, CAST(N'2010-07-08T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-06-24T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (1950, NULL, 753, CAST(N'2010-06-19T00:00:00.000' AS DateTime), CAST(N'2010-08-18T00:00:00.000' AS DateTime), N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-08-18T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (1761, NULL, 753, CAST(N'2010-08-19T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-08-05T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (3088, NULL, 754, CAST(N'2010-12-15T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-12-01T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (3351, NULL, 755, CAST(N'2010-12-23T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-12-09T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (3246, NULL, 756, CAST(N'2010-12-23T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-12-09T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (2760, NULL, 757, CAST(N'2010-09-15T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-09-01T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (2395, NULL, 758, CAST(N'2010-08-05T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-07-22T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (3087, NULL, 759, CAST(N'2010-12-15T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-12-01T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (3350, NULL, 760, CAST(N'2010-12-23T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-12-09T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (2822, NULL, 761, CAST(N'2010-09-15T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-09-01T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (3245, NULL, 762, CAST(N'2010-12-23T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-12-09T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (2759, NULL, 763, CAST(N'2010-09-15T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-09-01T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (2394, NULL, 764, CAST(N'2010-08-05T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-07-22T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (3341, NULL, 765, CAST(N'2010-12-23T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-12-09T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (2815, NULL, 766, CAST(N'2010-09-15T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-09-01T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (2449, NULL, 767, CAST(N'2010-08-05T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-07-22T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (2899, NULL, 768, CAST(N'2010-09-15T00:00:00.000' AS DateTime), CAST(N'2010-11-14T00:00:00.000' AS DateTime), N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-11-14T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (2738, NULL, 768, CAST(N'2010-11-15T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-11-01T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (2363, NULL, 769, CAST(N'2010-08-05T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-07-22T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (1265, NULL, 770, CAST(N'2010-06-09T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-05-26T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (1195, NULL, 771, CAST(N'2010-06-09T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-05-26T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (3017, NULL, 772, CAST(N'2010-12-15T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-12-01T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (3281, NULL, 773, CAST(N'2010-12-23T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-12-09T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (2783, NULL, 774, CAST(N'2010-09-15T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-09-01T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (5, NULL, 775, CAST(N'2010-03-04T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-02-18T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (2737, NULL, 776, CAST(N'2010-09-15T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-09-01T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (2362, NULL, 777, CAST(N'2010-08-05T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-07-22T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (1264, NULL, 778, CAST(N'2010-06-09T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-05-26T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (1642, NULL, 779, CAST(N'2010-06-19T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-06-05T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (393, NULL, 780, CAST(N'2010-03-18T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-03-04T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (52, NULL, 781, CAST(N'2010-03-04T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-02-18T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (3217, NULL, 782, CAST(N'2010-12-23T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-12-09T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (808, NULL, 783, CAST(N'2010-05-26T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-05-12T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (2049, NULL, 784, CAST(N'2010-07-08T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-06-24T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (4, NULL, 785, CAST(N'2010-03-04T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-02-18T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (2736, NULL, 786, CAST(N'2010-09-15T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-09-01T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (2361, NULL, 787, CAST(N'2010-08-05T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-07-22T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (1263, NULL, 788, CAST(N'2010-06-09T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-05-26T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (3247, NULL, 789, CAST(N'2010-12-23T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-12-09T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (2761, NULL, 790, CAST(N'2010-09-15T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-09-01T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (2396, NULL, 791, CAST(N'2010-08-05T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-07-22T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (3089, NULL, 792, CAST(N'2010-12-15T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-12-01T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (2739, NULL, 793, CAST(N'2010-09-15T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-09-01T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (2364, NULL, 794, CAST(N'2010-08-05T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-07-22T00:00:00.000' AS DateTime))
GO
INSERT [Production].[BillOfMaterials] ([BillOfMaterialsID], [ProductAssemblyID], [ComponentID], [StartDate], [EndDate], [UnitMeasureCode], [BOMLevel], [PerAssemblyQty], [ModifiedDate]) VALUES (1266, NULL, 795, CAST(N'2010-06-09T00:00:00.000' AS DateTime), NULL, N'EA ', 0, CAST(1.00 AS Decimal(8, 2)), CAST(N'2010-05-26T00:00:00.000' AS DateTime))
GO
【问题讨论】:
标签: sql-server dynamic sql-like