²âÊÔµÄʱºò±È½ÏÖØÒª£¬ÎÒÃÇ¿ÉÒÔÖªµÀµ±Ç°½»Ò×Ó°ÏìÁËÄÄЩ±í
--ÓÃÓڼǼÓû§ÔÚµ±Ç°±íÉÏʲôʱºò¡¢×öµÄʲô²Ù×÷£ºupdate¡¢insert¡¢delete
create table TriggerRecord
(
operdt datetime, --´¥·¢Ê±¼ä
opertp varchar(10), --²Ù×÷ÀàÐÍ£ºupdate¡¢insert¡¢delete
opertb varchar(50) --±íÃû
)
--Õâ¸ö±íÓÚÓñ£´æÉú³ÉµÄ´¥·¢Æ÷Óï¾ä£¬ÔÚ¹ý³ÌÖÐÑ»·Ö´ÐÐ
--ÒòΪSqlserver²»ÔÊÐíÔÚÒ»¸öÅú´ÎͬʱִÐжàÌõcreate triggerÓï¾ä
create table T(sqlTrigger varchar(500))
--Ñ»·Ö´ÐдæÓÚ±íÖд¥·¢Æ÷µÄ´æ´¢¹ý³Ì
create proc loopExecTrigger
as
begin
declare @sql varchar(500)
declare cur cursor for select sqlTrigger from T
open cur
fetch cur into @sql
while @@fetch_status=0
begin
execute(@sql)
fetch cur into @sql
end
close cur
deallocate cur
delete T
end
--ÓÃÓÚÉú³É²åÈëÓï¾äµÄ´¥·¢Æ÷£¬²¢½«´¥·¢Æ÷Óï¾ä±£´æµ½±íÖÐ
select 'insert into T values(''create trigger T_'+name+' on '+name+' for insert as insert into TriggerRe ......
ÕâÁ½ÌìÓиöÐèÇó£¬ÐèÒªÔÚÊý¾Ý¿âÖÐÅжÏ×Ö·û´®µÄ¸ñʽ£¬ÓÚÊÇ´ÓÍøÉÏËѼ¯ÁËһЩ×ÊÁÏ£¬ÕûÀíÁËһϡ£
ÏÂÃæÕâ¸öÊÇÒ»¸ö×Ô¶¨Ò庯Êý£¬Óû§¿ÉÒÔµ÷ÓÃÕâ¸öº¯ÊýÅжÏÖ¸¶¨µÄ×Ö·û´®ÊÇ·ñ·ûºÏÕýÔò±í´ïʽµÄ¹æÔò.
CREATE FUNCTION dbo.find_regular_expression
(
@source varchar(5000), --ÐèҪƥÅäµÄÔ´×Ö·û´®
@regexp varchar(1000), --ÕýÔò±í´ïʽ
@ignorecase bit = 0 --ÊÇ·ñÇø·Ö´óСд£¬Ä¬ÈÏΪfalse
)
RETURNS bit --·µ»Ø½á¹û0-false£¬1-true
AS
BEGIN
--0£¨³É¹¦£©»ò·ÇÁãÊý×Ö£¨Ê§°Ü£©£¬ÊÇÓÉ OLE ×Ô¶¯»¯¶ÔÏó·µ»ØµÄ HRESULT µÄÕûÊýÖµ¡£
DECLARE @hr integer
--ÓÃÓÚ±£´æ·µ»ØµÄ¶ÔÏóÁîÅÆ£¬ÒÔ±ãÖ®ºó¶Ô¸Ã¶ÔÏó½øÐвÙ×÷
DECLARE @objRegExp integer DECLARE @objMatches integer
--±£´æ½á¹û
DECLARE @results bit
/*
´´½¨ OLE ¶ÔÏóʵÀý,Ö»ÓÐ sysadmin ¹Ì¶¨·þÎñÆ÷½ÇÉ«µÄ³ÉÔ±²ÅÄÜÖ´ÐÐ sp_OACreate,²¢È·¶¨»úÆ÷ÖÐÓÐVBScript.RegExpÀà¿â
*/
EXEC @hr = sp_OACreate 'VBScript.RegExp', @objRegExp OUTPUT ......
»¨ÁË´ó°ëÌìµÄʱ¼äÖÕÓÚ½â¾öÁËÎÊÌ⣬ÏÂÃæ·ÖÏíÒ»ÏÂÎҵĹý³Ì£º
ÎÒµÄϵͳ°²×°µÄÊÇjdk6,netbeansºÍMycrosoft SqlServer 2005£¬javaÁ¬½ÓÊý¾Ý¿âÒ»°ãÒª·ÖÁù²¿×ß
1.×¢²áÇý¶¯
2.ÓÃÇý¶¯¹ÜÀíÀà´´½¨Á¬½Ó
3.´´½¨Óï¾ästatement·â×°sql½Å±¾Óï¾ä
4.Ö´ÐÐ
5.´¦Àí·µ»ØµÄ½á¹û
6.¹Ø±ÕÏà¹ØÁ¬½Ó
ÔÚÕâÀïÁ¬½ÓµÄÊÇSqlServer2005£¬ÊôÓÚµÚÈý·½Çý¶¯£¬Ê×ÏȵôÓÍøÉÏÏÂÔظÃÇý¶¯£¬¿ÉÒÔµ½Î¢Èí¹Ù·½ÍøÕ¾ÉÏÏÂÔØ×îа汾µÄJDBC 1.2£¬
È»ºó½«ÏÂÔصÄsqljdbc_1.2.2828.100_chs(¼´Microsoft SQL Server 2005 JDBC Driver 1.2ÖÐÎÄ°æ)½âѹËõµ½C:\Program Files\Microsoft SQL Server 2005 JDBC Driver£¬ÔÚclasspathºóÃæ¼ÓÉÏÒ»ÏîC:\Program Files\sqljdbc_1.2\chs\sqljdbc.jar
½Ó×ÅÒªÆôÓÃsqlserverµÄtcp/ipÐÒ飬·½·¨£º
¿ªÊ¼-ËùÓгÌÐò-Microsoft SQL Server 2005-ÅäÖù¤¾ß-SQL Server Configrution Manager¡£
´ò¿ªºóÕÒµ½SQL Server 2005ÍøÂçÅäÖÃÏÂÃæµÄSQLEXPRESSÐÒ飬ÔÚÓұߵĴ°¿Ú»á¿´¼ûTCP/IP£¬ÓÒ ¼ü µã»÷£¬Ñ¡ÔñÆôÓã¬ÔÙË«»÷TCP/IP£¬ÔÚÐÒéÏÂÈ«²¿ÕìÌýÑ¡ÊÇ£¬ÆôÓÃÑ¡ÊÇ¡£ÔÚpµØÖ·À¸£¬Ñ¡Ôñippall½«tcp¶Ë¿ÚÉèÖÃΪ1433£¬È·¶¨Ö®ºó£¬ÔÚ·þÎñÀォSQL Server (MSSQLSERVER)ºÍSQL Server (SQLEXPRESS)ÖØÐÂÆô¶¯Ò»Ï¡£
½Ó×ÅÒª¶ ......
»¨ÁË´ó°ëÌìµÄʱ¼äÖÕÓÚ½â¾öÁËÎÊÌ⣬ÏÂÃæ·ÖÏíÒ»ÏÂÎҵĹý³Ì£º
ÎÒµÄϵͳ°²×°µÄÊÇjdk6,netbeansºÍMycrosoft SqlServer 2005£¬javaÁ¬½ÓÊý¾Ý¿âÒ»°ãÒª·ÖÁù²¿×ß
1.×¢²áÇý¶¯
2.ÓÃÇý¶¯¹ÜÀíÀà´´½¨Á¬½Ó
3.´´½¨Óï¾ästatement·â×°sql½Å±¾Óï¾ä
4.Ö´ÐÐ
5.´¦Àí·µ»ØµÄ½á¹û
6.¹Ø±ÕÏà¹ØÁ¬½Ó
ÔÚÕâÀïÁ¬½ÓµÄÊÇSqlServer2005£¬ÊôÓÚµÚÈý·½Çý¶¯£¬Ê×ÏȵôÓÍøÉÏÏÂÔظÃÇý¶¯£¬¿ÉÒÔµ½Î¢Èí¹Ù·½ÍøÕ¾ÉÏÏÂÔØ×îа汾µÄJDBC 1.2£¬
È»ºó½«ÏÂÔصÄsqljdbc_1.2.2828.100_chs(¼´Microsoft SQL Server 2005 JDBC Driver 1.2ÖÐÎÄ°æ)½âѹËõµ½C:\Program Files\Microsoft SQL Server 2005 JDBC Driver£¬ÔÚclasspathºóÃæ¼ÓÉÏÒ»ÏîC:\Program Files\sqljdbc_1.2\chs\sqljdbc.jar
½Ó×ÅÒªÆôÓÃsqlserverµÄtcp/ipÐÒ飬·½·¨£º
¿ªÊ¼-ËùÓгÌÐò-Microsoft SQL Server 2005-ÅäÖù¤¾ß-SQL Server Configrution Manager¡£
´ò¿ªºóÕÒµ½SQL Server 2005ÍøÂçÅäÖÃÏÂÃæµÄSQLEXPRESSÐÒ飬ÔÚÓұߵĴ°¿Ú»á¿´¼ûTCP/IP£¬ÓÒ ¼ü µã»÷£¬Ñ¡ÔñÆôÓã¬ÔÙË«»÷TCP/IP£¬ÔÚÐÒéÏÂÈ«²¿ÕìÌýÑ¡ÊÇ£¬ÆôÓÃÑ¡ÊÇ¡£ÔÚpµØÖ·À¸£¬Ñ¡Ôñippall½«tcp¶Ë¿ÚÉèÖÃΪ1433£¬È·¶¨Ö®ºó£¬ÔÚ·þÎñÀォSQL Server (MSSQLSERVER)ºÍSQL Server (SQLEXPRESS)ÖØÐÂÆô¶¯Ò»Ï¡£
½Ó×ÅÒª¶ ......
SELECT convert(char,ÈÕÆÚ×Ö¶Î,120) as date2 from table
mssqlĬÈÏÒÔϵͳʱ¼ä¸ñʽÊä³ö£¬Äã¿ÉÒÔµ÷ÕûϵͳµÄʱ¼ä¸ñʽÀ´½â¾ö
µ±È»ÊÇÔÚ³ÌÐòÀï½â¾ö±È½ÏÁé»î£¬convert(char,date,N)Êä³öµÄ¸÷ÖÖÑùʽ
N ÈÕÆÚÑùʽ
0 04 2 2005 9:06AM
1 04/02/05
2 05.04.02
3 02/04/05
4 02.04.05
5 02-04-05
6 02 04 05
7 04 02, 05
8 09:06:18
9 04 2 2005 9:06:18:857AM
10 04-02-05
11 05/04/02
12 050402
13 02 04 2005 09:06:18:857
14 ......
Ïà¹ØÎÄÕÂ:
mysqlÊý¾Ý¿âËø
ORACLEÀXÖÖËøģʽ
ÍƼöȦ×Ó: Pipboy
¸ü¶àÏà¹ØÍƼö
new Draggable("related_topics");
¶ÔËø»úÖƵÄÑо¿Òª¾ß±¸Á½¸öÌõ¼þ£º
1£®Êý¾ÝÁ¿´ó
2£®¶à¸öÓû§Í¬Ê±²¢·¢
Èç¹ûȱÉÙÕâÁ½¸öÌõ¼þ£¬Êý¾Ý¿â²»ÈÝÒײúÉúËÀËøÎÊÌâ¡£Ñо¿ÆðÀ´¿ÉÄÜ»áʱ¶¹¦°ë¡£Èç¹ûÕâÁ½¸öÌõ¼þ¶¼ÓУ¬µ«Ä㻹ÊÇ°´Êý¾Ý¿âȱʡÉèÖÃÀ´´¦ÀíÊý¾Ý£¬Ôò»á´øÀ´ºÜ¶àµÄÎÊÌ⣬±ÈÈ磺
1£©¶ªÊ§¸üÐÂ
A,BÁ½¸öÓû§¶ÁͬһÊý¾Ý²¢½øÐÐÐÞ¸Ä,ÆäÖÐÒ»¸öÓû§µÄÐ޸Ľá¹ûÆÆ»µÁËÁíÒ»¸öÐ޸ĵĽá¹û
2£©Ôà¶Á
AÓû§ÐÞ¸ÄÁËÊý¾Ýʱ,BÓû§Ò²ÔÚ¶Á¸ÃÊý¾Ý,µ«AÓû§ÒòΪijЩÔÒòÈ¡ÏûÁ˶ÔÊý¾ÝµÄÐÞ¸Ä,Êý¾Ý»Ö¸´ÔÖµ,´ËʱBµÃµ½µÄÊý¾Ý¾ÍÓëÊý¾Ý¿âÄÚµÄÊý¾Ý²úÉúÁ˲»Ò»ÖÂ
3£©²»¿ÉÖظ´¶Á
BÓû§¶Á³ö¸ÃÊý¾Ý²¢ÐÞ¸Ä,ͬʱ£¬AÓû§Ò²ÔÚ¶ÁÈ¡Êý¾Ý£¬´ËʱAÓû§ÔÙ¶ÁÈ¡Êý¾Ýʱ·¢ÏÖÇ°ºóÁ½´ÎµÄÖµ²»Ò»ÖÂ
SQL SERVER ×÷Ϊ¶àÓû§Êý¾Ý¿âϵͳ£¬ÒÔÊÂÎñΪµ¥Î»£¬Ê¹ÓÃËøÀ´ÊµÏÖ²¢·¢¿ØÖÆ¡£SQLSERVERʹÓá°Ëø¡±È·±£ÊÂÎñÍêÕûÐÔºÍÊý¾ÝÒ»ÖÂÐÔ¡£
Ò»¡¢ËøµÄ¸ÅÄî
Ëø£¨LOCKING£©ÊÇ×î³£ÓõIJ¢·¢¿ØÖÆ»ú¹¹¡£ÊÇ·ÀÖ¹ÆäËûÊÂÎñ·ÃÎÊÖ¸¶¨µÄ×ÊÔ´¿ØÖÆ¡¢ÊµÏÖ²¢·¢¿ØÖƵÄÒ»ÖÖÖ÷ÒªÊֶΡ£ËøÊÇÊÂÎñ ......
1.SQLServerµÄ´´½¨½Å±¾ÈçÏ£º
USE [master]
GO
/****** Object: Database [test] Script Date: 10/29/2009 17:43:10 ******/
CREATE DATABASE [test] ON PRIMARY
( NAME = N'test', FILENAME = N'D:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\test.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'test_log', FILENAME = N'D:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\test_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [test] SET COMPATIBILITY_LEVEL = 100
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [test].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [test] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [test] SET ANSI_NULLS OFF
GO
ALTER DATABASE [test] SET ANSI_PADDING OFF
GO
ALTER DATABASE [test] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [test] SET ARITHABORT OFF
GO
ALTER DATA ......