3
我想排除文件中的特定內容。例如 我的示例代碼:只讀文件中的一個部分
GO
CREATE TABLE [dbo].[Employee] (
[EmployeeID] INT NULL,
[Name] VARCHAR (50) NULL
);
GO
CREATE TABLE #tempAP_Data_new (
planeID INT ,
APNM INT,
)
DECLARE
@APNM [VARCHAR] (100) ,
@MajorModel [VARCHAR] (100) ,
@MinorModel [VARCHAR] (100) ,
CREATE TABLE #tempnew_Data(
planeNum INT ,
APNMID INT,
)
GO
在此我只需要CREATE TABLE
聲明,直到去,而不是CREATE TABLE #
。輸出應該是:
CREATE TABLE [dbo].[Employee] (
[EmployeeID] INT NULL,
[Name] VARCHAR(50)NULL
);
我的代碼是:
$searchCreateTable = "CREATE TABLE"
$alterTable = (Get-Content $path\$deltaFile -Delimiter 'GO') -match "(?m)^$searchCreateTable*"
創建聲明並不總是處於確切位置。它實際上是一個增量文件 – avk
這個邏輯實際上不會工作,因爲它不能總是在索引2中 – avk