There are several ways to do that
1. Use the ExecuteXmlReader() method to run a SELECT statement that returns XML.
2.
SqlDataAdapter objSQLADP = new SqlDataAdapter("select * from tableName", "your_conn_str");
DataSet ds=new DataSet;
objSQLADP.Fill(ds,"tableName");
ds.WriteXml("file.xml");