This is my stored procedure that works fine in MSSQL 2005 express edition but in MSSQl 2014 express edition where I want to migrate it is not executed, ie files are there but with 0 bytes! Code in cmd file that call procedure is:
cd C:\NI_SQLscripts
"C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\SQLCMD.EXE" -S ATLOCATION-P-VM -E -d BazneStanice -b -Q Svi_NI -o Rezultat.txt
and the procedure is:
USE [BazneStanice]
GO
/****** Object: StoredProcedure [dbo].[Svi_NI] Script Date: 5/11/2017 4:32:25 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[Svi_NI]
as
Declare @xmlsvi xml;
Declare @strsvi nvarchar(4000);
Declare @cmdsvi nvarchar(4000);
Declare @dan nvarchar(20);
Declare @sat nvarchar(20);
truncate table Upiti_NI_XML;
Set @xmlsvi=
(select
LOKime as Name,
sifra0 as Location_Code,
adresa as Address,
Gsirina as Coordinate_WGS84_Latitude,
Gduzina as Coordinate_WGS84_Longitude,
opstina as Municipality,
odrzava0 as Maintance,
grozd as cluster,
dolazak as Access_info_and_contact,
kolokacija as colocation,
vlasnik as Owner,
druginazivi as Alias,
zemlja as Country,
vaznostbs as PriorityBS,
vaznostpr as PriorityTransport,
napomena0 as Description
from lokacije where stanje='koriscenje'
FOR XML PATH ('Location'), ROOT ('Locations'), ELEMENTS);
Set @dan=(SELECT convert(varchar, getdate(), 112));
Set @sat=(select replace(Convert (varchar(8),GetDate(), 108),':',''));
insert into Upiti_NI_XML (upit, ime_upita, dan, sat) values (@xmlsvi, 'locations_NI', @dan, @sat );
Set @strsvi= 'select upit from [BazneStanice].[dbo].Upiti_NI_XML where ime_upita=' + '''locations_NI''';
Set @cmdsvi='bcp "' + @strsvi + '"' + ' queryout "C:\NI_Location_Data\locations.xml" -T -c -S "ATLOCATION-P-VM"';
exec xp_cmdshell @cmdsvi;
When I execute "manually" on SQL server stored procedure Svi_NI without that part "alter procedure" everything is ok. I have renamed bcp.exe in Sybase client that I have installed on same serverWhat I am missing here? Any help will be apperciated!