使用批量插入将 .csv 文件上传到包含唯一标识符的 SQL 表
我需要通过 asp.net 上传控件将 .csv 文件上传到 sql 表。我已准备好 sql 批量插入命令,但我需要它,以便它自动为从 .csv 文件上传的每条记录分配一个唯一标识符(guid)。这不包含在 .csv 文件中。有人可以帮助我吗?
I need to upload a .csv file to a sql table through an asp.net upload control. I have the sql bulk insert command ready but I need to have it so it assigns each record that is uploaded from the .csv file a uniqueidentifier (guid) automatically. This isnt included in the .csv file. Can someone help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将表设置为使用默认的
NEWID()
,以便在插入记录时自动添加唯一标识符。当您进行批量插入时,每一行都会添加一个唯一的标识符。
You can set your table up to use a default
NEWID()
so that the unique identifier is added automatically when a record is inserted.When you do your bulk insert, each row will have a unique identifier added to it.