½«ExcelÎļþÊý¾Ý¿âµ¼ÈëSQL ServerµÄÈýÖÖ·½°¸
½«ExcelÎļþÊý¾Ý¿âµ¼ÈëSQL ServerµÄÈýÖÖ·½°¸
//·½°¸Ò»£º ͨ¹ýOleDB·½Ê½»ñÈ¡ExcelÎļþµÄÊý¾Ý£¬È»ºóͨ¹ýDataSetÖÐתµ½SQL Server
openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Excel files(*.xls)|*.xls";
if(openFileDialog.ShowDialog()==DialogResult.OK)
{
FileInfo fileInfo = new FileInfo(openFileDialog.FileName);
string filePath = fileInfo.FullName;
string connExcel = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties=Excel 8.0";
try
{
OleDbConnection oleDbConnection = new OleDbConnection(connExcel);
oleDbConnection.Open();
//»ñÈ¡excel±í
DataTable dataTable = oleDbConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
//»ñÈ¡sheetÃû£¬ÆäÖÐ[0][1]...[N]: °´Ãû³ÆÅÅÁÐµÄ±íµ¥ÔªËØ
string tableName = dataTable.Rows[0][2].ToString().Trim();
tableName = "[" + tableName.Replace("'","") + "]";
//ÀûÓÃSQLÓï¾ä´ÓExcelÎļþÀï»ñÈ¡Êý¾Ý
//string query = "SELECT classDate,classPlace,classTeacher,classTitle,classID from " + tableName;
string query = "SELECT ÈÕÆÚ,¿ª¿Î³ÇÊÐ,½²Ê¦,¿Î³ÌÃû³Æ,³ÖÐøʱ¼ä from " + tableName;
dataSet = new DataSet();
//OleDbCommand oleCommand = new OleDbCommand(query, oleDbConnection);
//OleDbDataAdapter oleAdapter = new OleDbDataAdapter(oleCommand);
Ïà¹ØÎĵµ£º
SQL ÃüÁî
Õⲿ·Ö°üº¬ÄÇЩ PostgreSQL Ö§³ÖµÄ SQL ÃüÁîµÄÐÅÏ¢£®ÕâÀïµÄ "SQL" ¾ÍÊǸÃÓïÑÔͨ³£µÄº¬Ò壻 ÿÌõÃüÁîµÄÓë±ê×¼ÓйصļæÈÝÐÔµÄÐÅÏ¢¿ÉÒÔÔÚÏà¹ØµÄ²Î¿¼Ò³ÖÐÕÒµ½£®
Table of Contents
ABORT -- Í˳öµ±Ç°ÊÂÎñ
ALTER GROUP -- Ïò×éÖÐÔö¼ÓÓû§»ò´Ó×éÖÐɾ³ýÓû§
ALTER USER -- ¸Ä±äÊý¾ ......
ÔÚSQL ServerÀï²é¿´µ±Ç°Á¬½ÓµÄÔÚÏßÓû§Êý
use master
select loginame,count(0) from sysprocesses
group by loginame
order by count(0) desc
select nt_username,count(0) from sysprocesses
group by nt_username
order by count(0) desc
Èç¹ûij¸öSQL ServerÓû§ÃûtestÁ¬½Ó±È½Ï¶à,²é¿´ËüÀ´×ÔµÄÖ÷»úÃû:
......
ÏÖÒªÇó²éѯ½çÃ棺²»ÂÛ15λ»òÕß18λÉí·ÝÖ¤ºÅ¶¼Äܲéѯ³öÊý¾Ý¿âÖÐËùÓе±Ç°Óû§ÐÅÏ¢¡£
·½°¸1£º
create or replace function CONVERT_ID_15 (/*ת»»Éí·ÝÖ¤ºÅΪ15λ*/
p_id2 in varchar2
) return varchar2
is
p_id varchar2(20);
id varchar2(15);
begin
p_id:=ltrim(p_id2);
p_id ......
×î½üÒ»Ö±ÔÚѧϰSQL serverµÄÄÚÈÝ¡£×òÌ쿼ÁËÒ»ÏÂÊÔ¡£¸Ð¾õÕæµÄÊDz»ÈÝÒ×°¡¡£ÌرðÊÇһЩ¸´ÔӵIJéѯ¡£¸ãµÃÎÒÍ·»èÄÔÕ͵ġ£²»¹ýÒ²ÊÇÓÉÓÚ×Ô¼ºµÄ֪ʶÕÆÎյĻ¹²»¹»Ôúʵ°¡¡£ËùÒÔ½ñÌ츴ϰÁËÒ»ÏÂT-SQlÓï¾äµÄÔöɾ¸Ä²é¡£·¢ÏÖµÄÈ·ÊÇÓкܶ඼Íü¼ÇÁË¡£ÏÖÔڰѽá¹ûд³öÀ´¡£ÒÔºó¿É²»ÒªÍüÁËѽ¡£
--SQLÓï¾ä¸´Ï° --Ò»,²åÈëinsertÓï¾ä --1,ins ......
1¡¢¹«Óñí±í´ïʽ (CTE) ¿ÉÒÔÈÏΪÊÇÔÚµ¥¸ö SELECT¡¢INSERT¡¢UPDATE¡¢DELETE »ò CREATE VIEW Óï¾äµÄÖ´Ðз¶Î§ÄÚ¶¨ÒåµÄÁÙʱ½á¹û¼¯¡£CTE ÓëÅÉÉú±íÀàËÆ£¬¾ßÌå±íÏÖÔÚ²»´æ´¢Îª¶ÔÏ󣬲¢ÇÒÖ»ÔÚ²éѯÆÚ¼äÓÐЧ¡£ÓëÅÉÉú±íµÄ²»Í¬Ö®´¦ÔÚÓÚ£¬CTE ¿É×ÔÒýÓ㬻¹¿ÉÔÚͬһ²éѯÖÐÒýÓöà´Î¡£
¡¡¡¡CTE ¿ÉÓÃÓÚ£º
¡¡¡¡´´½¨µÝ¹é²éѯ¡£ÓйØÏêϸР......