Answer the question
In order to leave comments, you need to log in
OpenRowSet BULK TSQL How to load files into the database?
Hello. I'm trying to load pictures into a table through a loop using BULK, but I can't add a variable, a field, or even join rows in BULK.
How to solve this situation?
WHILE @i <= (SELECT Count(*) FROM [dbo].[Charity])
BEGIN
UPDATE [dbo].[Charity]
SET [CharityLogoImg] = (SELECT * FROM OpenRowSet (BULK N'H:\Charity\' + CharityLogo, SINGLE_BLOB) As Файл)
WHERE [CharityId] = @i
SET @i = @i + 1
END
GO
Answer the question
In order to leave comments, you need to log in
Well, firstly, set field = (select * ...) and will not work, because "select *" means returning a lot of columns ...
therefore, at least set поле = (select конкретное_поле from ...)
secondly, the loop in this construction is not needed
, you can use
update t2
set t2.field=t1.field
from t1
join t2 on t2.id=t1.id
where ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question