0

我有一些输入

CREATE PROCEDURE dbo._ws_CallLogs_DeleteAll
(
    @UserId uniqueidentifier 
)
AS

或者

/*========== Script Analyzed by Sql Eye  on 11/30/2012 2:55:12 PM =======

  *====================== Total warnings : 0  =================================== */ 






SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
SET ANSI_PADDING ON
GO
IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CachedPlan_cached_plan_Job_id]') 
                AND parent_object_id = OBJECT_ID(N'[dbo].[CachedPlan]'))
ALTER TABLE [dbo].[CachedPlan] DROP CONSTRAINT [FK_CachedPlan_cached_plan_Job_id]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CachedPlan]') AND TYPE IN (N'U'))
DROP TABLE [dbo].[CachedPlan]
GO
CREATE TABLE [dbo].[CachedPlan](
    [cached_plan_id] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
    [cached_plan_Job_id] [int] NOT NULL,
    [dbId] [int] NOT NULL,
    [dbname] [varchar](100) NOT NULL,
    [plan_type] [varchar](50) NOT NULL,
    [objId] [int] NOT NULL,
    [objname] [varchar](100) NOT NULL,
    [sql_batch] [varchar](max) NOT NULL,

我需要挑选

PROCEDURE dbo._ws_CallLogs_DeleteAll

或者

TABLE [dbo].[CachedPlan]

最有效的方法是什么?

4

1 回答 1

2

使用正则表达式:

Match m = Regex.Match(inputString, @"CREATE\s+(?<obj>.+?)\s*\(", RegexOptions.Singleline);
string objectName = m.Groups["obj"].Value;
于 2013-05-14T09:39:47.193 回答