将文件添加到本地sql数据库的快捷方式

发布于 2024-11-09 17:50:13 字数 186 浏览 4 评论 0原文

我希望能够右键单击文件并“发送到”本地 MSSQL 数据库。详细信息是我想将文件内容存储在“内容”列中,将文件名存储在“文件名”列中......多么新颖:)

*在大多数情况下,文件内容是 HTML。

看起来应该可以通过 Windows shell/SQL Shell 使用“shell:sendto”文件夹中命令的快捷方式。

I would like to be able to right click on a file(s) and "send-to" a local MSSQL database. The details are that I would like to store the file contents in "contents" column and the file name in the "filename" column ... how novel :)

*In most cases the file contents is HTML.

It seems like it should be possible through windows shell/SQL Shell using a shortcut to a command in the "shell:sendto" folder.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悍妇囚夫 2024-11-16 17:50:14
[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')"}  
[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')"}  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文