asp.netÁ¬½ÓsqlÓõÄSqlHelper
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Collections;
using System.Data.SqlClient;
namespace DAL
{
/// <summary>
/// Êý¾Ý¿âµÄͨÓ÷ÃÎÊ´úÂë
/// ´ËÀàΪ³éÏóÀ࣬²»ÔÊÐíʵÀý»¯£¬ÔÚÓ¦ÓÃʱֱ½Óµ÷Óü´¿É
/// </summary>
public class SqlHelper
{
//»ñÈ¡Êý¾Ý¿âÁ¬½Ó×Ö·û´®£¬ÆäÊôÓÚ¾²Ì¬±äÁ¿ÇÒÖ»¶Á£¬ÏîÄ¿ÖÐËùÓÐÎĵµ¿ÉÒÔÖ±½ÓʹÓ㬵«²»ÄÜÐÞ¸Ä
public static readonly string Getcon = ConfigurationManager.ConnectionStrings["con"].ConnectionString;
// ¹þÏ£±íÓÃÀ´´æ´¢»º´æµÄ²ÎÊýÐÅÏ¢£¬¹þÏ£±í¿ÉÒÔ´æ´¢ÈÎÒâÀàÐ͵IJÎÊý¡£
private static Hashtable parmCache = Hashtable.Synchronized(new Hashtable());
/// <summary>
///Ö´ÐÐÒ»¸ö²»ÐèÒª·µ»ØÖµµÄSqlCommandÃüÁͨ¹ýÖ¸¶¨×¨ÓõÄÁ¬½Ó×Ö·û´®¡£
/// ʹÓòÎÊýÊý×éÐÎʽÌṩ²ÎÊýÁбí
/// </summary>
/// <remarks>
/// ʹÓÃʾÀý£º
/// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="connectionString">Ò»¸öÓÐЧµÄÊý¾Ý¿âÁ¬½Ó×Ö·û´®</param>
/// <param name="commandType">SqlCommandÃüÁîÀàÐÍ (´æ´¢¹ý³Ì£¬ T-SQLÓï¾ä£¬ µÈµÈ¡£)</param>
/// <param name="commandText">´æ´¢¹ý³ÌµÄÃû×Ö»òÕß T-SQL Óï¾ä</param>
&
Ïà¹ØÎĵµ£º
SQLÓï¾äµÄÌí¼Ó¡¢É¾³ý¡¢ÐÞ¸ÄËäÈ»ÓÐÈçϺܶàÖÖ·½·¨£¬µ«ÔÚʹÓùý³ÌÖл¹ÊDz»¹»Ó㬲»ÖªÊÇ·ñÓиßÊְѸü¶àÁé»îµÄʹÓ÷½·¨¹±Ï׳öÀ´£¿
Ìí¼Ó¡¢É¾³ý¡¢ÐÞ¸ÄʹÓÃdb.Execute(Sql)ÃüÁîÖ´ÐвÙ×÷
╔----------------╗
¡î Êý¾Ý¼Ç¼ɸѡ ¡î
╚----------------╝
×¢Ò⣺µ¥Ë«ÒýºÅµÄÓ÷¨¿ÉÄÜÓÐÎó(ûÓвâʽ)
Sql = "S ......
CUBE ºÍ ROLLUP Ö®¼äµÄÇø±ðÔÚÓÚ£º
CUBE Éú³ÉµÄ½á¹û¼¯ÏÔʾÁËËùÑ¡ÁÐÖÐÖµµÄËùÓÐ×éºÏµÄ¾ÛºÏ¡£
ROLLUP Éú³ÉµÄ½á¹û¼¯ÏÔʾÁËËùÑ¡ÁÐÖÐÖµµÄijһ²ã´Î½á¹¹µÄ¾ÛºÏ¡£
Àý×Ó£º
if object_id('a') is not null
drop table a
create table a
(
bm varchar(20), --±àÂë
ck varchar(2), &n ......
< type="text/javascript">
< type="text/javascript">
Èç×ªÔØ£¬Çë×¢Ã÷³ö´¦£ºhttp://blog.csdn.net/robinson_0612/archive/2009/11/07/4783702.aspx
Ëæ×ŵ±½ñÊý¾Ý¿âµÄÈÝÁ¿Ô½À´Ô½¿ìµÄ³¯×ÅÔÚ´óÐÍÊý¾Ý¿â»ò³¬´óÐÍÊý¾Ý¿âµÄ·¢Õ¹£¬¶ÔÓÚÊý¾Ý¿âÖеĴóÐͱíÒÔ¼°¾ßÓи÷ÖÖ·ÃÎÊģʽµÄ±íµÄ¿ÉÉìËõÐ ......
1:replace º¯Êý
µÚÒ»¸ö²ÎÊýÄãµÄ×Ö·û´®£¬µÚ¶þ¸ö²ÎÊýÄãÏëÌæ»»µÄ²¿·Ö£¬µÚÈý¸ö²ÎÊýÄãÒªÌæ»»³Éʲô
select replace('lihan','a','b')
&nb ......
ÔÚSQL*PlusÖÐĬÈϵÄ"&"±íÊ¾Ìæ´ú±äÁ¿£¬SQL*PlusÈÏΪ&·ûºóÃæµÄ×Ö·û´®Îª±äÁ¿£»Ö»ÒªÔÚÃüÁîÖгöÏָ÷ûºÅ£¬SQL*Plus¾Í»áÒªÄãÊäÈëÌæ´úÖµ¡£Õâ¾ÍÒâζ×ÅÄãÎÞ·¨½«Ò»¸öº¬Óи÷ûºÅµÄ×Ö·û´®²åÈë»ò¸üе½Êý¾Ý¿â
set define off ¹Ø±ÕÌæ´ú±äÁ¿¹¦ÄÜ£¬“&”½«×÷ΪÆÕͨ×Ö·û
set def ......