Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : sqlserver

»ñÈ¡sqlserverÖÐÊý¾Ý¿âµ±Ç°Á¬½ÓÊý

ÈçºÎ²é¿´SQL SERVERÊý¾Ý¿âµ±Ç°Á¬½ÓÊý
1.ͨ¹ý¹ÜÀí¹¤¾ß
¿ªÊ¼->¹ÜÀí¹¤¾ß->ÐÔÄÜ£¨»òÕßÊÇÔËÐÐÀïÃæÊäÈë mmc£©È»ºóͨ¹ýÌí¼Ó¼ÆÊýÆ÷Ìí¼Ó SQL µÄ³£ÓÃͳ¼Æ È»ºóÔÚÏÂÃæÁгöµÄÏîÄ¿ÀïÃæÑ¡ÔñÓû§Á¬½Ó¾Í¿ÉÒÔʱʱ²éѯµ½Êý¾Ý¿âµÄÁ¬½ÓÊýÁË¡£²»¹ý´Ë·½·¨µÄ»°ÐèÒªÓзÃÎÊÄÇ̨¼ÆËã»úµÄȨÏÞ£¬¾ÍÊÇҪͨ¹ýWindowsÕË»§µÇ½½øÈ¥²Å¿ÉÒÔÌí¼Ó´Ë¼ÆÊýÆ÷¡£
2.ͨ¹ýϵͳ±í²éѯ
 
SELECT * from
[Master].[dbo].[SYSPROCESSES] WHERE [DBID] IN ( SELECT
[DBID]
from
[Master].[dbo].[SYSDATABASES]
WHERE
NAME='DBName'
)
DBName ÊÇÐèÒª²é¿´µÄÊý¾Ý¿â£¬È»ºó²éѯ³öÀ´µÄÐÐÊý£¬¾ÍÊǵ±Ç°µÄÁ¬½ÓÊý¡£²»¹ýÀïÃ滹ÓÐһЩ±ðµÄ״̬¿ÉÒÔ×ö²Î¿¼Óá£
ÀýÈ磺Á¬µ½masterÕâ¸öÊý¾Ý¿âдÈçÏÂÓï¾ä
select * from sysprocesses where dbid in (select dbid from sysdatabases where name='MyDatabase')
½«ËùÓÐÁ¬½ÓMyDatabaseÕâ¸öÊý¾Ý¿âµÄÁ¬½Ó¼Ç¼¶¼Çó³öÀ´¡£
sysprocessesÕâ¸ö±í¼Ç¼ËùÒÔÁ¬½Óµ½SQL SERVERÊý¾Ý¿âµÄÁ¬½Ó¡£
3.ͨ¹ýϵͳµÄ´æ´¢¹ý³ÌÀ´²éÕÒ
 
SP_WHO 'UserName'
UserName Êǵ±È»µÇ½SqlµÄÓû§Ãû£¬Ò»°ã³ÌÐòÀïÃ涼»áʹÓÃÒ»¸öUserNameÀ´µÇ½SQLÕâÑùͨ¹ýÕâ¸öÓû§Ãû¾ÍÄܲ鿴µ½´ ......

SQLServer´óÊý¾ÝÁ¿²åÈëBULK INSERT


SQLSERVER ´óÊý¾ÝÁ¿²åÈëÃüÁ
BULK INSERTÊÇSQLSERVERÖÐÌṩµÄÒ»Ìõ´óÊý¾ÝÁ¿µ¼ÈëµÄÃüÁËüÔËÓÃDTS(SSIS)µ¼ÈëÔ­Àí£¬¿ÉÒÔ´Ó±¾µØ»òÔ¶³Ì·þÎñÆ÷ÉÏÅúÁ¿µ¼ÈëÊý¾Ý¿â»òÎļþÊý¾Ý¡£ÅúÁ¿²åÈëÊÇÒ»¸ö¶ÀÁ¢µÄ²Ù×÷£¬ÓŵãÊÇЧÂʷdz£¸ß¡£È±µãÊdzöÏÖÎÊÌâºó²»¿ÉÒԻعö¡£
¡¡¡¡BULK INSERTÊÇÓÃÀ´½«ÍⲿÎļþÒÔÒ»ÖÖÌض¨µÄ¸ñʽ¼ÓÔص½Êý¾Ý¿â±íµÄT-SQLÃüÁî¡£¸ÃÃüÁîʹ¿ª·¢ÈËÔ±Äܹ»Ö±½Ó½«Êý¾Ý¼ÓÔص½Êý¾Ý¿â±íÖУ¬¶ø²»ÐèҪʹÓÃÀàËÆÓÚIntegration ServicesÕâÑùµÄÍⲿ³ÌÐò¡£ËäÈ»BULK INSERT²»ÔÊÐí°üº¬Èκθ´ÔÓµÄÂß¼­»òת»»£¬µ«Äܹ»ÌṩÓë¸ñʽ»¯Ïà¹ØµÄÑ¡Ï²¢¸æËßÎÒÃǵ¼ÈëÊÇÈçºÎʵÏֵġ£BULK INSERTÓÐÒ»¸öʹÓÃÏÞÖÆ£¬¾ÍÊÇÖ»Äܽ«Êý¾Ýµ¼ÈëSQL Server¡£
²åÈëÊý¾ÝÏÂÃæµÄÀý×ÓÄÜÈÃÎÒÃǸüºÃµÄÀí½âÈçºÎʹÓÃBULK INSERTÃüÁî¡£Ê×ÏÈ£¬ÎÒÃÇÀ´´´½¨Ò»¸öÃûΪSalesµÄ±í£¬ÎÒÃǽ«Òª°ÑÀ´×ÔÎı¾ÎļþµÄÊý¾Ý²åÈëµ½Õâ¸ö±íÖС£
±¾µØÊý¾Ý²Ù×÷£º
 µ±ÎÒÃÇʹÓÃBULK INSERTÃüÁîÀ´²åÈëÊý¾Ýʱ£¬´´½¨µÄ±íÓÐÎÞ´¥·¢Æ÷ÐèÒª²»Í¬µÄÅäÖã¬ÎÒÃÇ·Ö±ð¾ÙÀýÀ´¿´£º
¡¾AûÓд¥·¢Æ÷µÄ±í¡¿
¡¡¡¡CREATE TABLE [dbo].[Sales] 
¡¡¡¡( 
¡¡¡¡ [SaleID] [int], 
¡¡¡¡ [Pr ......

Sqlserver È¡ºº×ֵĵÚÒ»¸ö×Öĸ£¬·½±ãÄ£ºý²éѯ

 create function comm_getpy
(
    @str nvarchar(4000)
)
returns nvarchar(4000)
as
begin
declare @word nchar(1),@PY nvarchar(4000)
set @PY=''
while len(@str)>0
begin
    set @word=left(@str,1)
    --Èç¹û·Çºº×Ö×Ö·û£¬·µ»ØÔ­×Ö·û
    set @PY=@PY+(case when unicode(@word) between 19968 and 19968+20901
               then (
                            select top 1 PY
from
                            (
                      &nb ......

Sqlserver ´æ´¢¹ý³Ì´ó¼¯ºÏ

 =================·ÖÒ³==========================
/*·ÖÒ³²éÕÒÊý¾Ý*/
CREATE PROCEDURE [dbo].[GetRecordSet] 
@strSql varchar(8000),--²éѯsql,Èçselect  * from [user]
@PageIndex int,--²éѯµ±Ò³ºÅ
@PageSize int--ÿҳÏÔʾ¼Ç¼
AS
set nocount on
declare @p1 int
declare @currentPage int
set @currentPage = 0
declare @RowCount int
set @RowCount = 0
declare @PageCount int
set @PageCount = 0
  exec sp_cursoropen @p1 output,@strSql,@scrollopt=1,@ccopt=1,@rowcount=@rowCount output --µÃµ½×ܼǼÊý
select @PageCount=ceiling(1.0*@rowCount/@pagesize)  --µÃµ½×ÜÒ³Êý
,@currentPage=(@PageIndex-1)*@PageSize+1
select @RowCount,@PageCount
exec sp_cursorfetch @p1,16,@currentPage,@PageSize
exec sp_cursorclose @p1
set nocount off
GO
=========================Óû§×¢²á============================
/*
Óû§×¢²á£¬Ò²ËãÊÇÌí¼Ó°É
*/
Create proc [dbo].[UserAdd]
(
@loginID nvarchar(50), ¡¡¡¡¡¡¡¡--µÇ¼ÕʺÅ
@password nvarchar(50), --ÃÜÂë
@email nv ......

java µ÷ÓÃͨÓô洢¹ý³Ì£¨Sqlserver£©


package com.wfy.system.dao;   
  
import java.sql.CallableStatement;   
import java.sql.Connection;   
import java.sql.ResultSet;   
import java.sql.SQLException;   
import java.sql.Types;   
import java.text.DateFormat;   
import java.text.SimpleDateFormat;   
import java.util.ArrayList;   
import java.util.HashMap;   
import java.util.List;   
import java.util.Map;   
  
import org.springframework.dao.DataAccessException;   
import org.springframework.jdbc.core.ConnectionCallback;   
import org.springframework.jdbc.core.JdbcTemplate;   
  
import com.wfy.util.JDOM;   
  
/**  
*   
* ´æ´¢¹ý³Ìͨ¹ý´ËÀàµ÷Óà  
*   
* @author ½ðöÎ  
*&nbs ......

java µ÷ÓÃͨÓô洢¹ý³Ì£¨Sqlserver£©


package com.wfy.system.dao;   
  
import java.sql.CallableStatement;   
import java.sql.Connection;   
import java.sql.ResultSet;   
import java.sql.SQLException;   
import java.sql.Types;   
import java.text.DateFormat;   
import java.text.SimpleDateFormat;   
import java.util.ArrayList;   
import java.util.HashMap;   
import java.util.List;   
import java.util.Map;   
  
import org.springframework.dao.DataAccessException;   
import org.springframework.jdbc.core.ConnectionCallback;   
import org.springframework.jdbc.core.JdbcTemplate;   
  
import com.wfy.util.JDOM;   
  
/**  
*   
* ´æ´¢¹ý³Ìͨ¹ý´ËÀàµ÷Óà  
*   
* @author ½ðöÎ  
*&nbs ......

SQLServer µ¼Èëµ¼³ö

·         ±¾ÎÄÌÖÂÛÁËÈçºÎͨ¹ýTransact-SQLÒÔ¼°ÏµÍ³º¯ÊýOPENDATASOURCEºÍOPENROWSETÔÚͬ¹¹ºÍÒì¹¹Êý¾Ý¿âÖ®¼ä½øÐÐÊý¾ÝµÄµ¼Èëµ¼³ö£¬²¢¸ø³öÁËÏêϸµÄÀý×ÓÒÔ¹©²Î¿¼¡£
 
1. ÔÚSQL ServerÊý¾Ý¿âÖ®¼ä½øÐÐÊý¾Ýµ¼Èëµ¼³ö
(1).ʹÓÃSELECT INTOµ¼³öÊý¾Ý 
    ÔÚSQL ServerÖÐʹÓÃ×î¹ã·ºµÄ¾ÍÊÇͨ¹ýSELECT INTOÓï¾äµ¼³öÊý¾Ý£¬SELECT INTOÓï¾äͬʱ¾ß±¸Á½¸ö¹¦ÄÜ£º¸ù¾ÝSELECTºó¸úµÄ×Ö¶ÎÒÔ¼°INTOºóÃæ¸úµÄ±íÃû½¨Á¢¿Õ±í£¨Èç¹ûSELECTºóÊÇ*, ¿Õ±íµÄ½á¹¹ºÍfromËùÖ¸µÄ±íµÄ½á¹¹Ïàͬ£©£»½«SELECT²é³öµÄÊý¾Ý²åÈëµ½Õâ¸ö¿Õ±íÖС£ÔÚʹÓÃSELECT INTOÓï¾äʱ£¬INTOºó¸úµÄ±í±ØÐëÔÚÊý¾Ý¿â²»´æÔÚ£¬·ñÔò³ö´í£¬ÏÂÃæÊÇÒ»¸öʹÓÃSELECT INTOµÄÀý×Ó¡£
    ¼ÙÉèÓÐÒ»¸ö±ítable1£¬×Ö¶ÎΪf1(int)¡¢f2(varchar(50))¡£
    SELECT * INTO table2 from table1
    ÕâÌõSQLÓïµÄÔÚ½¨Á¢table2±íºó£¬½«table1µÄÊý¾ÝÈ«²¿²åÈëµ½table1Öеģ¬»¹¿ÉÒÔ½«*¸ÄΪf1»òf2ÒÔ±ãÏòÊʵ±µÄ×Ö¶ÎÖвåÈëÊý¾Ý¡£
    SELECT INTO²»½ö¿ÉÒÔÔÚͬһ¸öÊý¾ÝÖн¨Á¢±í£¬Ò²¿ÉÒÔÔÚ²»Í¬µÄSQL ServerÊý¾Ý¿âÖн¨Á¢±í¡£
&n ......
×ܼǼÊý:341; ×ÜÒ³Êý:57; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [48] [49] [50] [51] [52] 53 [54] [55] [56] [57]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ