sql server - VB - Get the strings inside IN statement -


working vb in .net 2.0 , want create simple program makes xml file out of script(text file) created views this:

use [archive-firstview] go /****** object:  view [dbo].[vabcdefg]    script date: 5/14/2015 8:01:58 ******/ set ansi_nulls on go set quoted_identifier on go create view [dbo].[vabcdefg] select        dbo.[document].docguid, dbo.[document].accountguid, dbo.[document].jobguid, dbo.[document].doc9docid, dbo.[document].docdate, dbo.[document].doctype,                       dbo.[document].docpages, dbo.[document].tscreated            dbo.acctlookupkey inner join                      dbo.[document] on dbo.acctlookupkey.docguid = dbo.[document].docguid        (dbo.acctlookupkey.ix = 3) , (dbo.acctlookupkey.val in ('abcdefg'))   go /****** object:  view [dbo].[vlmnop]    script date: 5/14/2015 8:01:58 ******/ set ansi_nulls on go set quoted_identifier on go   create view [dbo].[vlmnop]   select        dbo.[document].*            dbo.acctlookupkey inner join  dbo.[document] on dbo.acctlookupkey.docguid = dbo.[document].docguid        (dbo.acctlookupkey.ix = 3)  , (dbo.acctlookupkey.val in ('lmnop','lmnop (aeiou)')) 

i want retrieve text @ end of each line, example, first 1 retrieve 'abcdefg', , second 1 retrieve both 'lmnop', 'lmnop (aeiou)'

thanks help!

edit: want create xml file looks this:

<views code="firstview">     <view name="vabcdefg">         <criteria>abcdefg</criteria>     </view>     <view name="lmnop">         <criteria>lmnop</criteria>         <criteria>lmnop (aeiou)</criteria>     </view> <views> 

edit2: far, been able begin extracting of data, not way want look. before loading xml.

dim dir new directoryinfo("d:\input")     dim sw new streamwriter("d:\input\extract.txt")      each fi fileinfo in dir.getfiles("views.txt")         dim sr new streamreader(fi.fullname)         dim root string         dim child string         dim substring string         while not sr.endofstream             dim sline string = sr.readline              if sline.contains("use [")                 root = sline '.substring(13) - 1             end if              if sline.contains("create view")                 child = sline '.substring(19) - 1             end if              if sline.contains("(''")                 substring = sline             end if              sw.writeline(root)             sw.writeline(child)             sw.writeline(substring)         end while         sr.close() : sr.dispose()     next     sw.flush() : sw.close() : sw.dispose() 

this hacky, gives idea of go. uses microsoft.sqlserver.transactsql.scriptdom library parse tsql. lot more dependable/flexible looking specific strings in input.

imports microsoft.sqlserver.transactsql.scriptdom  module module1      sub main()         dim fragment tsqlfragment         dim parser new tsql120parser(true)         dim reader system.io.streamreader         dim errors ilist(of parseerror)          reader = io.file.opentext("script.sql")          fragment = parser.parse(reader, errors)          dim foundin boolean = false         dim foundview boolean = false         dim viewname string = ""          each tkn tsqlparsertoken in fragment.scripttokenstream             if tkn.tokentype = tsqltokentype.view                 foundview = true             end if             if tkn.tokentype = tsqltokentype.in                 foundin = true             end if              'once see view, take until see             if foundview = true , tkn.tokentype = tsqltokentype.as                 console.writeline(viewname.trim)                 viewname = ""                 foundview = false             elseif foundview = true                 viewname += tkn.text             end if              'once see in, collect ascii elements until right parentheses encountered.             if tkn.tokentype = tsqltokentype.asciistringliteral , foundin = true                 console.writeline(tkn.text)             elseif tkn.tokentype = tsqltokentype.rightparenthesis , foundin = true                 'end of in condition                 foundin = false             end if         next          console.readkey()     end sub  end module 

outputs this... enter image description here


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -