Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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Óï¾äÊÕ¼¯

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

Flat hierarchyid in SQL Server 2008

ÔÚSQL Server 2008ÖÐÒýÈëÁËhierarchyidÀ´´¦ÀíÊ÷×´½á¹¹¡£ÏÂÃæ¼òµ¥¾ÍÒÔAdventureWorks(ÎÞhierarchyid)ºÍAdventureWorks2008(ÓÐhierarchyid)ÀïµÄHumanResources.EmployeeΪÀý£¬À´ËµÃ÷Ò»ÏÂÔÚеÄhierarchyidÖÐÈçºÎ½øÐÐflat»¯µÄdimension³éÈ¡¡£
AdventureWorksÊÇ΢ÈíΪSQL ServerÌṩµÄÊý¾Ý¿âÐéÄâ°¸Àý¡£
AdventureWorksÖÐËùÒªµ ......

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

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

SQL Ìõ¼þÓï¾ä

µÚÒ»ÖÖ£º
SELECT
CASE

     WHEN
price IS NULL THEN
'Not yet priced'
     WHEN
price < 10 THEN
'Very Reasonable Title'
     WHEN
price >= 10 AND
price < 20 THEN
'Coffee Table Title'
     EL ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ