¼ÆËãÄê×ʵÄSQLÓï¾ä
1.bzscs(ɳ³æ ÎÒ°®Ð¡ÃÀ)Óú¯數µÄºÃ辦·¨:
CREATE function [dbo].[calc_date](@time smalldatetime,@now smalldatetime)
returns nvarchar(10)
as
begin
declare @year int,@month int,@day int
select @year = datediff(yy,@time,@now)
if (month(@now)=month(@time)) and (day(@now)<day(@time)) or (month(@now)<month(@time))
set @year = @year-1
select @month = datediff(month,@time,@now)-12*@year
if(day(@now)<day(@time))
set @month = @month-1
select @day = datediff(dd,dateadd(month,(12*@year+@month),@time),@now)
return cast(@year as varchar) + 'Äê'+ cast(@month as varchar)+'個ÔÂ'+cast(@day as varchar)+'Ìì'
end
GO
-------------------------------------------------------------------------------------
--調Óú¯數 :
--1.ijһ¾ß體ÈÕÆÚ
declare @kk nvarchar(10)
select @kk = [dbo].[calc_date]('2001-11-28',getdate())
print @kk
--2.數據±íµÄ'Èë職ÈÕÆÚ'×Ö¶Î
select empno,indate,[dbo].[calc_date](indate,getdate()) from employee
Ïà¹ØÎĵµ£º
Ò»¡¢SQL SERVER ºÍACCESSµÄÊý¾Ýµ¼Èëµ¼³ö
³£¹æµÄÊý¾Ýµ¼Èëµ¼³ö£º
ʹÓÃDTSÏòµ¼Ç¨ÒÆÄãµÄAccessÊý¾Ýµ½SQL Server£¬Äã¿ÉÒÔʹÓÃÕâЩ²½Öè:
¡¡¡¡¡ð1ÔÚSQL SERVERÆóÒµ¹ÜÀíÆ÷ÖеÄTools£¨¹¤¾ß£©²Ëµ¥ÉÏ£¬Ñ¡ÔñData Transformation
¡¡¡¡¡ð2Services£¨Êý¾Ýת»»·þÎñ£©£¬È»ºóÑ¡Ôñ czdImport Dat ......
import java.sql.*;
/*
* JAVAÁ¬½ÓACCESS£¬SQL Server,MySQL,OracleÊý¾Ý¿â
*
* */
public class JDBC {
public static void main(String[] args)throws Exception {
Connection conn=null;
//====Á¬½ÓACCESSÊý¾Ý¿â ......
±ístuinfo£¬ÓÐÈý¸ö×Ö¶Îrecno(×ÔÔö),stuid,stuname
½¨¸Ã±íµÄSqlÓï¾äÈçÏ£º
CREATE TABLE [StuInfo] (
[recno] [int] IDENTITY (1, 1) NOT NULL ,
[stuid] [varchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[stuname] [varchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL
) ON [PRIMARY]
GO
1.--²éijһÁ ......
/// <summary>
/// ·µ»Ø·ÖÒ³SQLÓï¾ä
/// </summary>
/// <param name="selectSql">²éѯSQLÓï¾ä</param>
/// ......
×òÌì¿´µ½ÍøÉÏÓÐÒ»¸ö¹ØÓÚSQL SERVER ¿Î¼þ£¬±ãËæÊÖÏÂÔØÁËÏÂÀ´¿´¿´Ö÷Òª½²ÁËЩʲôÄÚÈÝ£¬ÓÚÊÇ¿´µ½ÁËÏÂÃæÁ½¸öPPTÒ³Ãæ
ÓÉÓÚµÚÒ»ÕÅPPTÉϵÄÄÚÈݲ»Ì«×¼È·£¨ÈÕÖ¾ÎļþÖÐûÓГÈÕÖ¾Ò³”µÄ¸ÅÄֻÓÐVLFµÄ¸ÅÄ¿ÉÄÜÊÇÎÒÃǶԓÊý¾ÝÒ³”µÄ¸ÅÄîÌ«Éî¿ÌÁË£¬Òò´ËŪÁËÒÔ&ldq ......