Developers Challenge

K

Kimakia

Guest
#1
Platform :MS SQL Server
DatabaseName : ChallengeTest
TableName :TestData

Challenge :
Create a TSQL script to read data from SQL Table and dump all the rows onto a csv file,comma delimited.
 
K

Kimakia

Guest
#4
BEGIN
SELECT d.Csv
FROM (
SELECT convert(varchar(25),column1) +'~'+convert(varchar(200),column2)+','+convert(varchar(200),column3)+','+convert(varchar(200),column4)+','+convert(varchar(200),column5)+','+convert(varchar(200),column6)+','+convert(varchar(200),column7)+','+convert(varchar(200),column8)+','+convert(varchar(50),column9)+','+convert(varchar,column10)+','+convert(VARCHAR(20),column11)+','+convert(varchar(200),column12)+','+convert(varchar(200),column13)+','+convert(varchar(200),chYear)+','+convert(varchar(200),chStaffCode) AS Csv,2 AS SortOrder
FROM ChallengeTest.dbo.TestData AS Expr1
FROM ChallengeTest.dbo.TestData)
)d
ORDER BY d.SortOrder
END

Cough it out Using BCP Utility tool
 

Who will win the 2022 elections? Ruto vs Raila. Cast your vote!

Top