Hi all,
I tried to import data to csv file by using linked server
the data transfers but it sort by last column.
when I open file in Excel or notepad it sort by CR_CARD_NO_MSK
instead of doc_id.
How could I fixed it?
Vadim
I tried to import data to csv file by using linked server
the data transfers but it sort by last column.
Code:
....
EXEC sp_addlinkedserver N'Account', N'Jet 4.0',
N'Microsoft.Jet.OLEDB.4.0',
N'C:\RexxxxlCxxxxxs\Exxxt',
NULL,
N'Text';
GO
EXEC sp_addlinkedsrvlogin 'Account'
GO
EXEC xp_cmdshell 'echo "DOC_ID","BUS_DAT","PMT_SEQ_NO","CR_CARD_NO"> C:\MyServer\RexxxxlCxxxxxs\Exxxt\LPI_5_PS_TKT_HIST_PMT_CR_CARD.csv';
GO
insert into Account...LPI_5_PS_TKT_HIST_PMT_CR_CARD#csv
SELECT
DOC_ID,CONVERT(VARCHAR(10),[BUS_DAT],101) + ' ' + substring(CONVERT(VARCHAR(30),[BUS_DAT],109),13, 26),
PMT_SEQ_NO,CR_CARD_NO_MSK
FROM [RetailConcepts].[dbo].[PS_TKT_HIST_PMT_CR_CARD]
where convert(varchar(10),bus_dat,120)
>= convert(varchar(10),'2012-05-30T00:00:00.000',120)
and convert(varchar(10),bus_dat,120)
<= convert(varchar(10),'2012-05-30T00:00:00.000',120)
order by doc_id
go
when I open file in Excel or notepad it sort by CR_CARD_NO_MSK
instead of doc_id.
How could I fixed it?
Vadim