java±¸·Ýsql serverÊý¾Ý¿â ´æ´¢¹ý³Ì
½ñÌì¸ø´ó¼Ò·ÖÏíÒ»ÏÂÈçºÎ±¸·ÝºÍ»Ø¸´sql server Êý¾Ý£¬
Ê×ÏÈÈ·±£Äã¾ßÓÐDBµÄ×î¸ßȨÏÞ
ÔÚJAVA´úÂëÖÐ Äã¿ÉÒÔÕâÑùдpublic class Opp extends TestCase{
public void test1()
{
try
{
Connection con = DBUtils.getConn();
String sql="backup database tdzl to disk='d:\\tdzl.bak'";
Statement st = con.createStatement();
st=con.createStatement();
st.execute(sql);
}catch(Exception e)
{
e.printStackTrace();
}
}
}
ÔÚMASTERÊý¾Ý¿âÖд´½¨Á½¸ö´æ´¢¹ý³Ì
p1
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[killspid] (@dbname varchar(20))
as
begin
declare @sql nvarchar(500)
declare @spid int
set @sql='declare getspid cursor for select spid from sysprocesses where dbid=db_id('''+@dbname+''')'
exec (@sql)
open getspid
fetch next from getspid into @spid
while @@fetch_status <> -1
begin
exec('kill '+@spid)
fetch next from getspid into @spid
end
close getspid
deallocate getspid
end
p2
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[restore_database]
-- Add the parameters for the stored procedure here
@db_name varchar(30),
@db_path varchar(80)
AS
BEGIN
execute killspid @db_name
restore database @db_name from disk=@db_path with replace
END
»Ø¸´Ê±µ÷ÓÃÉÏÊö´æ´¢¹ý³Ì¾ÍµÃÒÔʵÏÖ
ÏÂһƪ½«½âÊÍÈçºÎͨ¹ýJAVAµ÷Óøô洢¹ý³Ì
Ïà¹ØÎĵµ£º
Ò» sqlÓï¾äµÄÖ´Ðв½Öè
1£©Óï·¨·ÖÎö£¬·ÖÎöÓï¾äµÄÓï·¨ÊÇ·ñ·ûºÏ¹æ·¶£¬ºâÁ¿Óï¾äÖи÷±í´ïʽµÄÒâÒå¡£
2£© ÓïÒå·ÖÎö£¬¼ì²éÓï¾äÖÐÉæ¼°µÄËùÓÐÊý¾Ý¿â¶ÔÏóÊÇ·ñ´æÔÚ£¬ÇÒÓû§ÓÐÏàÓ¦µÄȨÏÞ¡£
3£©ÊÓͼת»»£¬½«Éæ¼°ÊÓͼµÄ²éѯÓï¾äת»»ÎªÏàÓ¦µÄ¶Ô»ù±í²éѯÓï¾ä¡£
4£©±í´ïʽת»»£¬ ½«¸´Ô SQL ±í´ïʽת»»Îª½Ï¼òµ¥µÄµÈЧÁ¬½Ó±í´ïʽ¡ ......
/*=================== µ¼Èë/µ¼³ö Excel µÄ»ù±¾·½·¨ ===================*/
¡¡¡¡
¡¡¡¡´ÓExcelÎļþÖÐ,µ¼ÈëÊý¾Ýµ½SQLÊý¾Ý¿âÖÐ,ºÜ¼òµ¥,Ö±½ÓÓÃÏÂÃæµÄÓï¾ä:
¡¡¡¡
¡¡¡¡/*===================================================================*/
¡¡¡¡--Èç¹û½ÓÊÜÊý¾Ýµ¼ÈëµÄ±íÒѾ´æÔÚ
¡¡¡¡insert into ±í select * from
¡¡ ......
/*
ʹÓÃÊÂÎñÈÕÖ¾»Ö¸´Êý¾ÝµÄʵÑé
*/
--1.´´½¨²âÊÔÊý¾Ý¿â
CREATE DATABASE Db_test
ON
( NAME = Db_test_DATA,
FILENAME = 'c:\Db_test.mdf' )
LOG ON
( NAME = Db_test_LOG,
FILENAME = 'c:\Db_test.ldf')
GO
--2.¹ÊÕÏ»¹ÔÄ£ÐÍÉèÖÃΪfullÄ£ÐÍ,ĬÈϵļòµ¥Ä£Ðͱ¸·Ý ......
½ñÌìÎÒÃÇ¿ªÊ¼SQL SERVER BIµÄÁíÍâÒ»¸öÖØÒªµÄ²¿·Ö --Reporting Service£¬Ïà¶ÔÓÚIntegration ServiceºÍAnalysis Service£¬Reporing ServiceÔÚ¹úÄÚµÄʹÓÃÕßÓ¦¸Ã¶àºÜ¶à.Ò»·½ÃæÓÉÓÚReporing Service·ÑÓñȽϵͣ¬Ö±½Ó¸½ÊôÔÚSQL SERVERÖУ¬ÁíÍâÒ»·½ÃæÆäʵSSRSÔںܴó³Ì¶ÈÉÏ»¹ÊÇÂú×ãÎÒÃǵı¨±íÐèÇóµÄ¡£ ÔÚSQL Server 2008ÖУ¬ ......