Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to insert images in SQLServer database

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

It is believed that many inexperienced people have no idea about how to insert images into SQLServer database. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

1. Create a stored procedure

CREATEPROCEDUREsp_textcopy (@ srvnamevarchar (30), @ loginvarchar (30), @ passwordvarchar (30), @ dbnamevarchar (30), @ tbnamevarchar (30), @ colnamevarchar (30), @ filenamevarchar (30), @ whereclausevarchar (40) @ directionchar (1) ASDECLARE@exec_strvarchar (255) SELECT@exec_str='textcopy/S'+@srvname+'/U'+@login+'/P'+@password+'/D'+@dbname+'/T'+@tbname+'/C'+@colname+'/W "'+ @ whereclause+'" / F'+@filename+'/'+@directionEXECmaster..xp_cmdshell@exec_str

2. Create tables and initialize data

Createtable table name (serial int,image column name image) goinsert table name values (1memo 0x)-required and not nullinsert table name values (2je 0x)-required and not nullgo

How to insert Image in SQLServer Database

3. Read in the image

Sp_textcopy' your server name', 'sa',' your password', 'table name', 'table name', 'image column name','c:\ picture .bmp', 'where number = 1 copy your server name', 'sa',' your password', 'library name', 'table name', 'image list name','c:\ bb.doc','where number = 2' 'i will pay attention to the condition that the number is 2go

4. Read it into a document

Sp_textcopy' your server name', 'sa',' your password', 'table name', 'table name', 'image column name','c:\ picture .bmp', 'where number = 1 copy your server name', 'sa',' your password', 'library name', 'table name', 'image list name','c:\ bb.doc','where number = 2' Olympian-note that the condition is number = 2go if textcopy is not an executable file Go to the C:\ ProgramFiles\ MicrosoftSQLServer\ MSSQL\ Binn directory and copy the textcopy.exe to: C:\ ProgramFiles\ MicrosoftSQLServer\ 80\ Tools\ Binn.

After reading the above, have you mastered the method of how to insert images in SQLServer database? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report