C#ÖÐÓÃÓÚÁ¬½ÓSQLÊý¾Ý¿âµÄSQLHelperÀà
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient; //ÒýÓÃÃüÃû¿Õ¼ä
namespace DAL
{
/*******************************************************************************
* Name: SQLHelper
* File: SQLHelper.cs
* Description: ÓÃÓÚÍê³É¶ÔÊý¾Ý¿âµÄÏà¹Ø²Ù×÷
* Author: Ñ©ÀÇ
* DateTime: 2010Äê05ÔÂ13ÈÕ
*******************************************************************************/
public class SQLHelper
{
//ÉèÖÃÁ¬½Ó×Ö·û´® —— SQL ServerÑé֤ģʽµÄÁ¬½Ó×Ö·û´®
//public static string strConn = @"server = PANLING;database = StudentMIS;uid = sa;pwd = sa";
//ÉèÖÃÁ¬½Ó×Ö·û´® —— WindowsÑé֤ģʽµÄÁ¬½Ó×Ö·û´®
public static string strConn = @"server = T403-004\HB_SQLSERVER;database = DB_LibraryManage;Integrated Security = SSPI";
/// <summary>
/// ¹¦ÄÜÃèÊö£ºÖ´ÐÐADO.NETÔö¡¢É¾¡¢¸Ä²Ù×÷
/// </summary>
/// <param name="strText">ÊäÈë²ÎÊý —— ÒªÖ´ÐеÄSQLÓï¾ä(ÃüÁîÎı¾)</param>
/// <param name="cmdType">ÊäÈë²ÎÊý —— ÒªÖ´ÐеÄSQLÃüÁîÀàÐÍ</param>
/// <param name="SqlParams">ÊäÈë²ÎÊý —— ÒªÖ´ÐеÄSQLÓï¾äÖеIJÎÊýÁбí(ÃüÁî²ÎÊýÁбí)</param>
/// <returns>·µ»ØÖ´ÐÐÓ°ÏìµÄÐÐÊý</returns>
public static int MyExecu
Ïà¹ØÎĵµ£º
1.ɾ³ý±í
select 'drop table ' || table_name || ' purge;'
from user_tables
where length(table_name) <= 4;
ɾ³ý´øÔ¼ÊøµÄ±í
Drop table ±íÃû cascade constraints;
2.²éѯview&ͬÒå´Ê
--˵Ã÷£º¿ÉÒÔ¸ù¾ÝÊÓͼµÄtext_length ......
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 ¸ù¾ÝÅ ......
1.×Ö·û´®º¯Êý
³¤¶ÈÓë·ÖÎöÓÃ
datalength(Char_expr) ·µ»Ø×Ö·û´®°üº¬×Ö·ûÊý,µ«²»°üº¬ºóÃæµÄ¿Õ¸ñ
substring(expression,start,length) ²»¶à˵ÁË,È¡×Ó´®
right(char_expr,int_expr) ·µ»Ø×Ö·û´®ÓÒ±ßint_expr¸ö×Ö·û
×Ö·û²Ù×÷Àà
upper(char_expr) תΪ´óÐ ......