Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
jonnie_r
Starting Member
2 Posts |
Posted - 2014-12-15 : 07:13:55
|
Hi,I am still fairly new to SQL, having been tasked with creating a csv file from data now someone else has left.I can do the csv export using sqlcmd and I have the query sorted and am pulling out the right data, but it generates two rows, as one of the tables has multiple records per cardholder. See the query below, I know there is a way of doing it with XML PATH, I think, but it has got me slightly confused.set nocount onselect dbo.card.EncodedNumber, dbo.card.IsEnabled, dbo.Cardholder.FirstName, dbo.cardholder.LastName, dbo.card.ExpiryTime, dbo.PersonalDataString.Valuefrom dbo.cardinner join dbo.cardholder on dbo.card.CardholderID = dbo.cardholder.FTItemID inner join dbo.PersonalDataString on dbo.card.CardholderID = dbo.PersonalDataString.CardholderID where dbo.PersonalDataString.PersonalDataFieldID between 1904 and 1905order by dbo.card.EncodedNumberCan anyone point me in the right direction?Thanks,Jon |
|
bitsmed
Aged Yak Warrior
545 Posts |
Posted - 2014-12-15 : 12:35:45
|
Use "distinct" or "group by" |
|
|
jonnie_r
Starting Member
2 Posts |
Posted - 2014-12-15 : 14:39:51
|
Ok ta, I'll have a read up on them |
|
|
|
|
|
|
|