c# - What can be the most efficient way to parse the object name from the script? -
i have inputs
create procedure dbo._ws_calllogs_deleteall ( @userid uniqueidentifier ) or
/*========== script analyzed 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 * sys.foreign_keys object_id = object_id(n'[dbo].[fk_cachedplan_cached_plan_job_id]') , parent_object_id = object_id(n'[dbo].[cachedplan]')) alter table [dbo].[cachedplan] drop constraint [fk_cachedplan_cached_plan_job_id] go if exists (select * sys.objects object_id = object_id(n'[dbo].[cachedplan]') , type in (n'u')) drop table [dbo].[cachedplan] go create table [dbo].[cachedplan]( [cached_plan_id] [int] identity(1,1) not 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, i need pick out
procedure dbo._ws_calllogs_deleteall or
table [dbo].[cachedplan] what efficient way so?
use regular expression:
match m = regex.match(inputstring, @"create\s+(?<obj>.+?)\s*\(", regexoptions.singleline); string objectname = m.groups["obj"].value;
Comments
Post a Comment