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

sql ѧϰ

Ò»¡¢ÈçºÎ´ÓselectµÄ²éѯ½á¹ûÖÐÔÙ´ÎÔËË㣿
µÚÒ»²½£º
´Ö²éѯ¡£Ê×ÏÈÐèÒª½«µÚÒ»²ã²éѯŪ¶Ô£¬¹ØϵŪÇå³þ¡£
select sum(quantity) total ,price_water,price_pollute from pay_water where time_pay >='2010-02-01 00:00:00.000' and time_pay <'2010-02-28 23:59:59.000'
group by price_water,price_pollute
µÚ¶þ²½£º
¶þ´Î²éѯ¡£ÔÚÒ»´Î²éѯµÄ»ù´¡ÉϽøÐÐÔËËã¡£
select total*price_water a ,total*price_pollute b  from (
select sum(quantity) total ,price_water,price_pollute from pay_water where time_pay >='2010-02-01 00:00:00.000' and time_pay <'2010-02-28 23:59:59.000'
group by price_water,price_pollute
) as test
as testÊDZØÐëÓеģ¬Ã»Óоͻᱨ´í¡£
µÚÈý²½£º
ѹËõ£º
select sum(total*price_water) a ,sum(total*price_pollute) b  from (
select sum(quantity) total ,price_water,price_pollute from pay_water where time_pay >='2010-02-01 00:00:00.000' and time_pay <'2010-02-28 23:59:59.000'
group by price_water,price_pollute
) as test
sum()º¯Êý¿ÉÒÔ½«ÉÏÏÂѹËõ£¬Çó³ö¸ÃÁеÄ×ܺ͡£
¶þ¡¢group by Óï¾ä¡£
selectÖеÄ×Ö¶ÎÖ»ÄÜÊÇgroup byÖеÄ×ֶλòÕ߾ۺϺ¯Êý¡£


Ïà¹ØÎĵµ£º

SQL Óï¾äÓÅ»¯ hust ei

JOINÓÅ»¯
MySQLÖÐjoinµÄʵÏÖ²ÉÓõÄÊÇNested Loop JoinËã·¨¡£Í¨¹ýÇý¶¯±íµÄ½á¹û¼¯×÷Ϊѭ»·»ù´¡Êý¾Ý£¬È»ºó½«¸Ã½á¹û¼¯ÖеÄÊý¾Ý×÷Ϊ¹ýÂË
Ìõ¼þÒ»ÌõÌõµÄµ½ÏÂÒ»¸ö±íÖвéѯÊý¾Ý£¬×îºóºÏ²¢½á¹û£¬Èç¹û´æÔÚºóÐø±í£¬¹ý³ÌÒ²Èç´Ë¡£
¾¡Á¿¼õÉÙjoinÓï¾äÖÐnested loopÑ­»·µÄ´ÎÊý¡£×îÓÐЧµÄ·½·¨ÊÇÈÃÇý¶¯±íµÄ½á¹û¼¯¾¡¿ÉÄܵÄС
ÓÅÏÈÓÅ»¯nested ......

asp.netÖ´ÐÐsql½Å±¾£¬µ¼³öÊý¾Ý¿âÎļþµ½±¾µØ

protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn= new SqlConnection("server=(local);database=colorring;uid=sa;pwd=;");
conn.Open();
string sqlstr = "exec master..xp_cmdshell 'bcp \"select top 100 * from master..aps\" queryout c:\\aa ......

.netÁ¬½ÓÊý¾Ý¿â£¬Ö´ÐÐsql½Å±¾

1¡¢¶¨ÒåÖ¸Á£ºusing System.Data.SqlClient;
2¡¢¶¨ÒåsqlÁ¬½Ó£º SqlConnection conn= new SqlConnection("server=(local);database=colorring;uid=sa;pwd=;");
3¡¢´ò¿ªsqlÁ¬½Ó£º conn.Open();
4¡¢¶¨ÒåsqlÓï¾ä£ºstring sqlstr = "insert into test values (123321)";
5¡¢×é×°sqlÓï¾äºÍÁ¬½Ó£ºSqlCommand cmd = new SqlCo ......

SqlÓï¾äµÄ³£Ó÷½·¨

1.ÈçºÎ½«Ò»¸öSQL Server±íµÄ½á¹¹¸´ÖƵ½ÁíÒ»¸öн¨µÄ±íÖÐ
    select * into бí from ¾É±í where 0 = 1
2.ÐÞ¸Ä×Ö¶ÎĬÈÏÖµ
    alter table ±íÃû add default ĬÈÏÖµ for ×Ö¶ÎÃû
3. È¡µÃÊý¾Ý¿â½á¹¹
    SELECT name from sysdatabases
4.Ôö¼ÓÁÐ
  ......

SQL Server×Ô´ø±¸·ÝÕû¸öÊý¾Ý¿â½Å±¾¹¤¾ß scptxfr.exe


Ê×ÏÈÔÚsqlserverµÄ°²×°Â·¾¶Ï£¬È磺D:\Program Files\Microsoft SQL
Server\MSSQL\£¬ÕÒµ½ÎļþÃûÊÇscptxfr.exeµÄÎļþ,ÀûÓÃÃüÁîÐй¤¾ß£º¾ßÌåÓ÷¨ÈçÏ£º
D:\PROGRA~1\MICROS~2\MSSQL\>scptxfr/?
ÃüÁîÐÐÓï·¨:
SCPTXFR /s
<·þÎñÆ÷> /d <Êý¾Ý¿â> {[/I] | [/P <ÃÜÂë>]}
    &n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ