May 26, 2014 at 7:44 am
Hello everybody,
I have to export the records of a table in a .txt file but in a strange way (in a column). For example I have this table with 3 fields:
create table prova
(cod varchar(1),
des1 varchar(2),
des2 Varchar (2)
)
insert into prova values (1, 'A1', 'A2')
insert into prova values (2, 'B1', 'B2')
I need to have the output in this way:
1 cod 1
1 des1 A1
1 des2 A2
8 S
1 cod 2
1 des1 B1
1 des2 B2
8 S
So, I have to put '1' at the begining of every field and '8 S' at the end of every record.
Anyboody helps me to do this?
In sql server 2008 and 2012 this functions properly but in sql server 2005 doesn't:
select d.Val
from prova
cross apply values('1 cod ' + Cod),('1 des1 ' + des1),('1 des2 ' + des2),('8 S') d(Val)
May 26, 2014 at 8:25 am
Answer in the following thread:
http://www.sqlservercentral.com/Forums/Topic1574051-3077-1.aspx
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply