Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

C# ÓÃSQLн¨Êý¾Ý¿â

1. ³ÌÐòÈçÏ£º
         string str = "Create Database " + "DBname";
         string con = "Data Source=10.0.0.249\\sql2005;Initial Catalog=master;Persist Security Info=True;User ID=sa;Password=sa";
            SqlConnection myConn = new SqlConnection(con);
            SqlCommand myCommand = new SqlCommand(str, myConn);
            try
            {
                myConn.Open();
                myCommand.ExecuteNonQuery();
                Console.WriteLine("SQL Óï¾äÖ´ÐÐÍê³É¡£", "MyProgram");
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.ToString(), "MyProgram");
            }
            finally
            {
                if (myConn.State == ConnectionState.Open)
                {
                    myConn.Close();
   


Ïà¹ØÎĵµ£º

sqlÓï¾äÓÅ»¯

SQLÓï¾äµÄÓÅ»¯¾ÍÊǽ«ÐÔÄܽϵ͵ÄSQLÓï¾äת»»´ï³ÉͬÑùÄ¿µÄÐÔÄÜÓÅÒìµÄSQLÓï¾ä
ÏÂÃæÎÒÃÇÒ»ÆðÀ´¿´¿´Ò»Ð©¿ÉÒÔÓÅ»¯SQLµÄ·½·¨£¬Ï£Íû´ó¼Ò¶àÌá³öÒâ¼ûÎÒÃǹ²Í¬Ñ§Ï°»òÕßÊÇ´ó¼ÒÓÐʲôºÃµÄÓÅ»¯·½·¨¿ÉÒÔÌá³öÀ´¹²Ïíһϡ£
µÚÒ»ÖÖÓÅ»¯£¨Ê¹ÓÃÖ¸¶¨ÁдúÌæ”*”£©
       ʹÓÓ*”¿ÉÒÔ½µµÍ±àдSQLÓï ......

³£ÓÃSQLÓï¾äÊÕ¼¯

1.ɾ³ý±í
  select 'drop table ' || table_name || ' purge;'
  from user_tables
  where length(table_name) <= 4;
    ɾ³ý´øÔ¼ÊøµÄ±í
    Drop table ±íÃû cascade  constraints;
2.²éѯview&ͬÒå´Ê
   --˵Ã÷£º¿ÉÒÔ¸ù¾ÝÊÓͼµÄtext_length ......

Xml×Ö·û´®ÓëC#¶ÔÏóÖ®¼äÏ໥ת»»

ÎÒÃdz£³£ÐèÒª¶ÁÈ¡xmlÎļþ£¬°ÑÀïÃæµÄÐÅϢת»¯ÎªÎÒÃÇ×Ô¶¨ÒåµÄÀàÐÍ£¬»òÔò°É×Ô¶¨ÒåÀàÐÍת»¯ÎªXml×Ö·û´®¡£ÔÚÕâÀï½éÉÜÒ»¸ö±È½Ï¼òµ¥µÄ¶ÔÏóת»¯·½·¨¡£ÔÚÎÒ×Ô¼ºµÄFramworkÀïÃæÒ²¶à´ÎÓõ½¡£ÀïÃæÉæ¼°µ½½Úµã¡¢ÊôÐÔ¡¢¼¯ºÏ¡£
ʾÀýÒ» ¸ÃxmlÎļþÉæ¼°µ½ÊôÐÔ¡¢½Úµã¼¯ºÏ²»Éæ¼°¸ö½Úµã£º
<?xml version="1.0" encoding="utf-8"?>
<da ......

SQL²éѯÊý¾Ý¿âÖÐÿÕűíµÄ¼Ç¼Êý

±¾ÎÄÀ´×Ô£ºhttp://hi.baidu.com/darkroot/blog/item/7b74be2cf06d76e78b139903.html
declare   @tbName     nvarchar(500)
declare   @ct      int  
declare   @csql   nvarchar(500)  
declare &n ......

sql ²éѯ±íµÄÁÐÃû row_number()

select upper(name) from syscolumns
where id =any
(
select Id from sysobjects where name='tb_city'
)
lower
select row_number() over(order by firmid) from dbo.tb_BuildingMaterial
Éú³É  ×ÔÔö  123
select rank() over(order by firmid) from dbo.tb_BuildingMaterial
Éú³É×ÔÔö123  ¸ù¾ÝÅ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ