谁能告诉我我在这里做错了什么?我正在尝试根据我操作的数据查询到一个平面文件。我不断收到下面的代码错误。感谢您的所有帮助!
谁能告诉我我在这里做错了什么?我正在尝试根据我操作的数据查询到一个平面文件。我不断收到下面的代码错误。感谢您的所有帮助!
declare variables....
select @effDate = effective_date from c_flt_src
if convert(varchar(10), @effDate, 112) = convert (varchar(10), GETDATE(),112)
set @sqleffdate = convert(varchar(10), @effDate, 112)
begin
select @all = store from c_flt_src where store = 'ALL'
if @@ROWCOUNT = 1 and @all = 'ALL'
select @action = action from c_flt_src
if @action = 'INCREASE' or @action = 'DECREASE'
set @actiontyp = 'UPDATE_STORE'
else if @action = 'REPLACE'
set @actiontyp = 'RESET_STORE'
select @a = a_amt from c_flt_src
select @b = b_amt from c_flt_src
begin
declare @c as cursor
set @c = CURSOR fast_forward for select distinct top 3 store from store_loc where store <> 0 order by store
open @c
fetch next from @c into @store
while @@FETCH_STATUS = 0
begin
--process data here
set @sql = @sqlaction + '|' + @actiontyp + '|' + @store + '|' + @a + '|' + @b
set @sql1 = '"'+'D:\file.'+@sqleffdate+'.9999999.'+REPLICATE ('0', 3-LEN(@store)) + @store +'.deltaloc' + '"'
select @sql1
declare @s varchar(max)
set @s = ''''+'bcp "select ''''' + @sql + '''''"' + ' queryout ' + @sql1+ ' -c -t "|" -T'+''''
select @s
execute master.dbo.xp_cmdshell @s
fetch next from @c into @store
end
close @c
deallocate @c
end
end