I am trying to write a code to identify the delimiter in the file ( which is in the form of table(id, raw) in system)
then I take this delimiter and pass it as a parameter to SP which perform cleaning of this file(table) and creates another clean table.
The problem I am facing is until now the file was coming with one fixed (TAB) delimiter, but now it has come with different (SPACE), now here I want to develop the code to identify the delimiter place it in a variable an pass this as parameter to cleaning SP.
begin
--here i want to develop code to identify delimiter from hosts_equiv file which has data as below
select * from hosts_equiv where left(raw,1) not in ('#','*') and isnull(raw,'')<>''
Raw id
---------------- ---
hiper USER1 1
hiper2 USER1 2
APX user2 3
Need to identify delimiter between e.g. hiper USER1 and pass it as a parameter to the raw_parse sp
declare Tab varchar(10)
set Tab = char(9)
exec raw_Parse
'hosts_equiv', -- From table ( entire file content is stored as table with Id record no sequence generated)
'CleanedHosts_Equiv', -- To table name, when passed it will clean the from table and places the cleaned data in to_table
Tab, -- delimiter
'#', -- Comment character, line starts with # to be ignored
'HostName VARCHAR(MAX), UserName VARCHAR(MAX)' -- column names for the to_table passed dynamically ( we know before hand there are only 2 colummns
end
The raw parse SP is working fine if we pass the correct delimiter to it, else it errors out.