SELECT INTO Statements
You can use the SELECT INTO statement to export formatted data to a file.
Data Export with an SQL Query
The following query exports data into a file formatted in comma-separated values (CSV):
SELECT RespondentId, ChoiceId INTO [csv://MySurvey_Responses.txt] FROM [MySurvey_Responses] WHERE ChoiceText = 'blue'You can specify other formats in the file URI. The possible delimiters are tab, semicolon, and comma with the default being a comma. The following example exports tab-separated values:
SELECT RespondentId, ChoiceId INTO [csv://MySurvey_Responses.txt;delimiter=tab] FROM [MySurvey_Responses] WHERE ChoiceText = 'blue'
C#
String connectionString = "OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;CallbackURL=http://localhost:portNumber;"; using (SurveyMonkeyConnection connection = new SurveyMonkeyConnection(connectionString)) { SurveyMonkeyCommand cmd = new SurveyMonkeyCommand("SELECT RespondentId, ChoiceId INTO [csv://MySurvey_Responses.txt] FROM [MySurvey_Responses] WHERE ChoiceText = 'blue' ", connection); int rowsAffected = cmd.ExecuteNonQuery(); }
VB.NET
Dim connectionString As [String] = "OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;CallbackURL=http://localhost:portNumber;" Using connection As New SurveyMonkeyConnection(connectionString) Dim cmd As New SurveyMonkeyCommand("SELECT RespondentId, ChoiceId INTO [csv://MySurvey_Responses.txt] FROM [MySurvey_Responses] WHERE ChoiceText = 'blue'", connection) Dim rowsAffected As Integer = cmd.ExecuteNonQuery() End UsingYou can specify other file formats in the URI. The following example exports tab-separated values:
C#
String connectionString = "OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;CallbackURL=http://localhost:portNumber;"; using (SurveyMonkeyConnection connection = new SurveyMonkeyConnection(connectionString)) { SurveyMonkeyCommand cmd = new SurveyMonkeyCommand("SELECT * INTO [MySurvey_Responses] IN [csv://filename=c:/MySurvey_Responses.csv;delimiter=tab] FROM [MySurvey_Responses] WHERE ChoiceText = 'blue'", connection); int rowsAffected = cmd.ExecuteNonQuery(); }
VB.NET
Dim connectionString As [String] = "OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;CallbackURL=http://localhost:portNumber;" Using connection As New SurveyMonkeyConnection(connectionString) Dim cmd As New SurveyMonkeyCommand("SELECT * INTO [MySurvey_Responses] IN [csv://filename=c:/MySurvey_Responses.csv;delimiter=tab] FROM [MySurvey_Responses] WHERE ChoiceText = 'blue'", connection) Dim rowsAffected As Integer = cmd.ExecuteNonQuery() End Using