Option
Explicit
Sub
x()
Dim
startInsert
As
String
startInsert =
"sqlcmd -S . -E -d InfoRo -Q "
"INSERT INTO [dbo].[Asociatii$]"
startInsert = startInsert &
" ([Denumire]"
startInsert = startInsert &
" ,[Numar inreg Reg National]"
startInsert = startInsert &
",[pozitie inchisa (da/nu)]"
startInsert = startInsert &
",[Starea actuala]"
startInsert = startInsert &
",[Judet]"
startInsert = startInsert &
",[Localitate]"
startInsert = startInsert &
",[Adresa]"
startInsert = startInsert &
",[Asociati/Fondatori]"
startInsert = startInsert &
",[Scop]"
startInsert = startInsert &
",[Consiliu director]"
startInsert = startInsert &
",[Apartenenta federatie]"
startInsert = startInsert &
",[HG utilitate publica]"
startInsert = startInsert &
",[Data HG utilitate publica]"
startInsert = startInsert &
",[F14])values("
Dim
i
As
Long
, j
As
Integer
, text
As
String
Dim
insert
As
String
For
i = 2
To
86813
insert = insert & startInsert
For
j = Asc(
"A"
)
To
Asc(
"M"
)
text = Sheet1.Range(Chr(j) & i).text
text = Replace(text, vbCr,
" "
)
text = Replace(text, vbLf,
" "
)
text = Trim(text)
text = Replace(text,
"'"
,
"''"
)
text = Replace(text,
" "
,
" "
)
insert = insert &
"'"
& text &
"',"
Next
j
insert = insert &
"null)"
&
""
""
insert = insert & vbCrLf
If
(i
Mod
150 = 0)
Then
Open
"C:\Users\Surface1\Desktop\2Percent\a.bat"
For
Append
As
#1
Print #1, insert
Close #1
insert =
""
End
If
Next
i
If
(Len(insert) > 0)
Then
Open
"C:\Users\Surface1\Desktop\2Percent\a.bat"
For
Append
As
#1
Print #1, insert
Close #1
insert =
""
End
If
End
Sub