SQL SERVERÖÐһЩÌرðµØ·½µÄÌرð½â·¨
SQL code
/*----------------------------------------------------------------
-- Author :feixianxxx(poofly)
-- Date :2010-04-20 20:10:41
-- Version:
-- Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (Intel X86)
Mar 29 2009 10:27:29
Copyright (c) 1988-2008 Microsoft Corporation
Enterprise Evaluation Edition on Windows NT 6.1 <X86> (Build 7600: )
-- CONTENT£ºSQL SERVERÖÐһЩÌرðµØ·½µÄÌرð½â·¨2
----------------------------------------------------------------*/
--1.¹ØÓÚwhereɸѡÆ÷ÖгöÏÖÖ¸¶¨ÐÇÆÚ¼¸µÄÇó½â
SQL code
--»·¾³
create table test_1
(
id int,
value varchar(10),
t_time datetime
)
insert test_1
select 1,'a','2009-04-19' union
select 2,'b','2009-04-20' union
select 3,'c','2009-04-21' union
select 4,'d','2009-04-22' union
select 5,'e','2009-04-23' union
select 6,'f','2009-04-24' union
select 7,'g','2009-04-25'
go
ÎÒÃÇÒ»°ãͨ¹ý datepart(weekday )½øÐÐÇó½â£¬±ÈÈçÇó½âÐÇÆÚ2µÄ¼Ç¼
select * from test_1
where DATEPART(WEEKDAY,t_time+@@DATEFIRST-1)=2
/*
id value t_time
----------- ---------- -----------------------
3 c 2009-04-21 00:00:00.000
*/
ÕâÀïÉæ¼°µ½ @@datefirst Õâ¸öϵͳ±äÁ¿£¬Ò»°ãÎÒÃÇÓÃÀ´µ÷½Ú²»Í¬µØ·½µÄÈÕÆÚÏ°¹ß¡£
Èç¹ûÄã¾õµÃ¹ØÓÚÕâ¸ö±äÁ¿ºÜÄÑÒ²ÀÁµÃÈ¥ÒÀÀµËüµ÷½Ú£¬ÕâÀﻹÓÐÒ»ÖÖ·½·¨
Äã¿ÉÒÔʹÓÃÒ»¸ö²ÎÕÕÈÕÆÚ,ͨ¹ýÏàͬÐÇÆÚÊý³É7µÄ±¶ÊýµÄÔÀí½øÐвéѯ
select * from test_1
where DATEDIFF(DAY,'1900-01-02',t_time)%7=0
/*
id value t_time
----------- ---------- -----------------------
3 c 2009-04-21 00:00:00.000
*/
--2.¹ØÓÚÔÚwhereɸѡÆ÷ÖÐÖ¸¶¨´óСд²éÕÒµÄË÷ÒýÒýÓÃÎÊÌâ
SQL code
--»·¾³
--drop table test_2
create table test_2
(
id int identity(1,1),
value varchar(10)
)
insert test_2 select
'abc' union all select
'Abc' union all select
'ABC' union all select
'aBc'
go
create clustered index in_value on test_2(value)
--ÎÒÏÈÒª²éÕÒ ÖµÎª'ABC'µÄ¼Ç¼ ÒªÇø·Ö´óСдµÄ
select * from test_2
where value COLL
Ïà¹ØÎĵµ£º
--3.3.1 ʹÓÃÓα귨½øÐÐ×Ö·û´®ºÏ²¢´¦ÀíµÄʾÀý¡£
--´¦ÀíµÄÊý¾Ý
CREATE TABLE tb(col1 varchar(10),col2 int)
INSERT tb SELECT 'a',1
UNION ALL SELECT 'a',2
UNION ALL SELECT 'b',1
UNION ALL SELECT 'b',2
UNION ALL SELECT 'b',3
--ºÏ²¢´¦Àí
--¶¨Òå½á¹û¼¯±í±äÁ¿
DECLARE @t TABLE(col1 varchar(10),col2 varch ......
Use DatabaseName
--DB shrink
--»ñÈ¡database ¿ÕÓà¿Õ¼ä£¬¡¡¾ö¶¨ÊÇ·ñ×÷shrinkDB
exec [DBNAME].dbo.sp_spaceused
DBCC ShrinkDB(DBNAME)
--Log file shrink
Use DatabaseName
GO
Alter Database DatabaseName Set Recovery Simple
GO
Alter Database DatabaseName Set Recovery Full
GO
DBCC SHRINKFILE ('Log ......
Êý¾Ý¿âÃæÊÔ³£ÓòâÊÔÌâ(SQL Server)
ÌâÄ¿1
¡¡¡¡ÎÊÌâÃèÊö:
¡¡¡¡Îª¹ÜÀí¸ÚλҵÎñÅàѵÐÅÏ¢£¬½¨Á¢3¸ö±í:
¡¡¡¡S (S#,SN,SD,SA) S#,SN,SD,SA ·Ö±ð´ú±íѧºÅ¡¢Ñ§Ô±ÐÕÃû¡¢ËùÊôµ¥Î»¡¢Ñ§Ô±ÄêÁä
¡¡¡¡C (C#,CN ) C#,CN ·Ö±ð´ú±í¿Î³Ì±àºÅ¡¢¿Î³ÌÃû³Æ
¡¡¡¡SC ( S#,C#,G ) S#,C#,G ·Ö±ð´ú±íѧºÅ¡¢ËùÑ¡Ð޵Ŀγ̱àºÅ¡¢Ñ§Ï°³É¼¨
¡¡¡¡1. Ê¹Ó ......
º¯ÊýÈçÏÂ
CREATE FUNCTION StockBalance_AmountIn(@SortID int)
RETURNS numeric(18,4)
AS
BEGIN
Declare @dblReturn numeric(18,4)
Select @dblReturn = SUM(AmountCurrentMonthIn) from AT_Materiel_StockBalance Where SortID = @SortID
Return (@dblReturn)
END
......
1¡¢°²×°Sql Server2005 Mobile Edition£»
2¡¢¾ßÌåÔÚ´´½¨Ò»¸ö¹¤³ÌÒÔºó£¬ÏëʹÓÃSqlServerCe±ØÐëÔÚ×Ô¼º¹¤³ÌµÄÒýÓÃÀïÃæÌí¼ÓÒ»¸ödll²ÅÐУ»
ÆäĿ¼ÔÚ£ºC:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\System.Data.SqlServerCe.dll
Ìí¼ÓÁËÒÔºó¾Í¿ÉÒÔʹÓÃMobileµÄһЩÊý¾Ý¿â²Ù×÷µÄÀà¿âÁË¡£ ......