xml import
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/f44039e4-cb89-4dfe-bade-133842ca571a/importing-xml-files-into-sql-server-2008?forum=transactsql
static void Main(string[] args) { String connectionString = "Data Source=ServerName;Initial Catalog=QA;Integrated Security=True"; using (SqlConnection sqlconn = new SqlConnection(connectionString)) { DataSet ds = new DataSet(); DataTable sourcedata = new DataTable(); ds.ReadXml(@"http://ws.geonames.org/countryCode?lat=40.417&lng=-3.703&type=xml"); sourcedata = ds.Tables[0]; sqlconn.Open(); using (SqlBulkCopy bulkcopy = new SqlBulkCopy(sqlconn)) { bulkcopy.DestinationTableName = "dbo.Geonames"; bulkcopy.ColumnMappings.Add("countryCode", "countryCode"); bulkcopy.ColumnMappings.Add("countryName", "countryName"); bulkcopy.ColumnMappings.Add("languages", "languages"); bulkcopy.ColumnMappings.Add("distance", "distance"); bulkcopy.WriteToServer(sourcedata); } Console.ReadLine(); } }
//
http://stackoverflow.com/questions/16838627/import-xml-into-sql-server
0 comments:
Post a Comment