0
我想可以右键点击一个文件(S)和“发送到”本地MSSQL数据库。细节是,我想将文件内容存储在“内容”栏和文件名,在“文件名”列... :)快捷方式文件添加到本地SQL数据库
*在大多数情况下,如何在新的文件内容是HTML。
好像透过窗户在使用的快捷方式命令shell/SQL壳牌它应该是可能的“壳:SENDTO”文件夹中。
我想可以右键点击一个文件(S)和“发送到”本地MSSQL数据库。细节是,我想将文件内容存储在“内容”栏和文件名,在“文件名”列... :)快捷方式文件添加到本地SQL数据库
*在大多数情况下,如何在新的文件内容是HTML。
好像透过窗户在使用的快捷方式命令shell/SQL壳牌它应该是可能的“壳:SENDTO”文件夹中。
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | Out-Null
$Server1 = New-Object ("Microsoft.SqlServer.Management.Smo.Server") 'SQLSERVER'
$Server1.databases["DB"].tables["Table"].rowcount
$RowCount = $server1.databases["DB"].tables["Table"].rowcount.ToString()
$TotalRecords = [int]$RowCount
$wc = New-Object system.net.WebClient
$url = ""
$files = @(Get-ChildItem c:\test\*.*)
"Number of files $($files.length)"
# Errors out when no files are found
if($files.length -lt 1) { return }
foreach($file1 in $files) {
# $txt = Get-Content($file1)
# $txt = $txt.Replace("'", "''")
# Write-Host $file1.name + " - - " + $Txt
$url1 = $url + $file1
Write-Host("URL is " + $url1)
$webpage = $wc.DownloadData($url1)
$string = [System.Text.Encoding]::ASCII.GetString($webpage)
$string = $string.Replace("'", "''")
Invoke-SqlCmd -ServerInstance SERVER -Query "Insert into DATABASE.dbo.Table(text,filename) Values ('$string','$file1')"}