CREATE PROCEDURE Demo1
@x int = 0
AS
BEGIN
while @x < 2
begin
declare @pathnvarchar(200)
set @path = N'insert into xtable(value)
select * from openrowset
(bulk''F:\data\'
+ right(cast(@x as nvarchar),5) + N'’,SINGLE_CLOB) as x';
EXECsp_executesql @path
set @x = @x + 1
end
END
明显是 set @path句有错,请问应该怎么写???
t-sqlopenrowset?bulkt-sqlbulk存储过程
分享到:
------解决方案--------------------
ALTER PROCEDURE Demo1
@x int = 0
AS
BEGIN
while @x < 2
begin
declare @path nvarchar(4000) --长度不够
declare @strname nvarchar(200)
set @strname = right(cast(@x as nvarchar),5)
set @path = N'
insert into xtable(name,value)
select '''+ @strname +''',BulkColumn from /*--拼的话,记得加''号,且转义*/
(