블로그 이미지
LifeisSimple

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Notice

2012. 1. 29. 16:49 Brain Trainning/Server
윈도우 2003/2008 버전의 에디션간 차이점입니다. 
여기에 SQL Server버전간의 차이점을 더하면 놀라운... 일관성없음이 보입니다. (흠..)

두 팀은 서로 이야기를 좀 해야할듯...



Compare the Editions of Windows Server 2008



Compare the Editions of Windows Server 2003

Compare the features of the Windows Server 2003 family using this set of tables, which is organized by function.

Features

Key = Feature included  = Feature partially supported  = Feature not included

Feature Standard Edition Enterprise Edition Datacenter Edition Web Edition
Hardware Specifications
64-bit Support for Intel® Itanium™-Based Computers1
Hot add memory2,3
Non-Uniform Memory Access (NUMA)3
Datacenter Program
2 GB RAM Maximum
4 GB RAM Maximum
32 GB RAM Maximum
64 GB RAM Maximum4
512 GB RAM Maximum5
2-way SMP
4-way SMP
8-way SMP
32-way SMP
64-way SMP
Directory Services
Active Directory
Metadirectory Services (MMS) Support
Security Services
Internet Connection Firewall2
Public Key Infrastructure, Certificate Services, and Smart Cards
Terminal Services
Remote Desktop for Administration
Terminal Server
Terminal Server Session Directory
Clustering Technologies
Network Load Balancing
Cluster Service
Communications & Networking Services
Virtual Private Network (VPN) Support
Internet Authentication Service (IAS)
Network Bridge2
Internet Connection Sharing (ICS)2
IPv6
File & Print Services
Distributed File System (DFS)
Encrypting File System (EFS)
Shadow Copies of Shared Folders
Removable Storage
Remote Storage
Fax Service
Services for Macintosh
Management Services
IntelliMirror
Group Policy Results
Windows Management Instrumentation (WMI) Command Line
Remote OS Installation
Remote Installation Services (RIS)
Windows System Resource Manager (WSRM)
.NET Application Services
.NET Framework2
Internet Information Services (IIS) 6.0
ASP.NET2
Enterprise UDDI Services
Multimedia Services
Windows Media™ Services2
1 Applies to 64-bit versions only.
2 Not supported in 64-bit versions of Windows Server 2003.
3 May be limited by lack of support by OEM hardware.

4 Both the 32-bit version of Datacenter Edition and the 64-bit version of Enterprise Edition support up to 64 GB RAM.
5 The 64-bit version of Datacenter Edition supports up to 512 GB RAM.
posted by LifeisSimple
2012. 1. 28. 23:01 Brain Trainning/DataBase
출처 :  http://technet.microsoft.com/en-us/library/cc966534.aspx 

Storage Top 10 Best Practices
Published: October 17, 2006

Proper configuration of IO subsystems is critical to the optimal performance and operation of SQL Server systems. Below are some of the most common best practices that the SQL Server team recommends with respect to storage configuration for SQL Server.

1 Understand the IO characteristics of SQL Server and the specific IO requirements / characteristics of your application.

In order to be successful in designing and deploying storage for your SQL Server application, you need to have an understanding of your application’s IO characteristics and a basic understanding of SQL Server IO patterns. Performance monitor is the best place to capture this information for an existing application. Some of the questions you should ask yourself here are:

  • What is the read vs. write ratio of the application?

  • What are the typical IO rates (IO per second, MB/s & size of the IOs)? Monitor the perfmon counters:

    1. Average read bytes/sec, average write bytes/sec

    2. Reads/sec, writes/sec

    3. Disk read bytes/sec, disk write bytes/sec

    4. Average disk sec/read, average disk sec/write

    5. Average disk queue length

  • How much IO is sequential in nature, and how much IO is random in nature? Is this primarily an OLTP application or a Relational Data Warehouse application?

To understand the core characteristics of SQL Server IO, refer to SQL Server 2000 I/O Basics.

2 More / faster spindles are better for performance

  • Ensure that you have an adequate number of spindles to support your IO requirements with an acceptable latency.

  • Use filegroups for administration requirements such as backup / restore, partial database availability, etc.

  • Use data files to “stripe” the database across your specific IO configuration (physical disks, LUNs, etc.).

3 Try not to “over” optimize the design of the storage; simpler designs generally offer good performance and more flexibility.

  • Unless you understand the application very well avoid trying to over optimize the IO by selectively placing objects on separate spindles.

  • Make sure to give thought to the growth strategy up front. As your data size grows, how will you manage growth of data files / LUNs / RAID groups? It is much better to design for this up front than to rebalance data files or LUN(s) later in a production deployment.

4 Validate configurations prior to deployment

  • Do basic throughput testing of the IO subsystem prior to deploying SQL Server. Make sure these tests are able to achieve your IO requirements with an acceptable latency. SQLIO is one such tool which can be used for this. A document is included with the tool with basics of testing an IO subsystem. Download the SQLIO Disk Subsystem Benchmark Tool.

  • Understand that the of purpose running the SQLIO tests is not to simulate SQL Server’s exact IO characteristics but rather to test maximum throughput achievable by the IO subsystem for common SQL Server IO types.

  • IOMETER can be used as an alternative to SQLIO.

5 Always place log files on RAID 1+0 (or RAID 1) disks. This provides:

  • better protection from hardware failure, and

  • better write performance. 

    Note: In general RAID 1+0 will provide better throughput for write-intensive applications. The amount of performance gained will vary based on the HW vendor’s RAID implementations. Most common alternative to RAID 1+0 is RAID 5. Generally, RAID 1+0 provides better write performance than any other RAID level providing data protection, including RAID 5.

6 Isolate log from data at the physical disk level

  • When this is not possible (e.g., consolidated SQL environments) consider I/O characteristics and group similar I/O characteristics (i.e. all logs) on common spindles.

  • Combining heterogeneous workloads (workloads with very different IO and latency characteristics) can have negative effects on overall performance (e.g., placing Exchange and SQL data on the same physical spindles).

7 Consider configuration of TEMPDB database

  • Make sure to move TEMPDB to adequate storage and pre-size after installing SQL Server.

  • Performance may benefit if TEMPDB is placed on RAID 1+0 (dependent on TEMPDB usage).

  • For the TEMPDB database, create 1 data file per CPU, as described in #8 below.

8 Lining up the number of data files with CPU’s has scalability advantages for allocation intensive workloads.

  • It is recommended to have .25 to 1 data files (per filegroup) for each CPU on the host server.

  • This is especially true for TEMPDB where the recommendation is 1 data file per CPU.

  • Dual core counts as 2 CPUs; logical procs (hyperthreading) do not.

9 Don’t overlook some of SQL Server basics

  • Data files should be of equal size – SQL Server uses a proportional fill algorithm that favors allocations in files with more free space.

  • Pre-size data and log files.

  • Do not rely on AUTOGROW, instead manage the growth of these files manually. You may leave AUTOGROW ON for safety reasons, but you should proactively manage the growth of the data files.

10 Don’t overlook storage configuration bases

  • Use up-to-date HBA drivers recommended by the storage vendor

  • Utilize storage vendor specific drivers from the HBA manufactures website

  • Tune HBA driver settings as needed for your IO volumes. In general driver specific settings should come from the storage vendor. However we have found that Queue Depth defaults are usually not deep enough to support SQL Server IO volumes.

  • Ensure that the storage array firmware is up to the latest recommended level.

  • Use multipath software to achieve balancing across HBA’s and LUN’s and ensure this is functioning properly

  • Simplifies configuration & offers advantages for availability

  • Microsoft Multipath I/O (MPIO): Vendors build Device Specific Modules (DSM) on top of Driver Development Kit provided by Microsoft.

posted by LifeisSimple
2012. 1. 25. 22:07 Brain Trainning/PRG Language
아주 가끔씩 필요한 경우가 있었는데 책에 정리가 잘 되어 있군요... 



웹을지탱하는기술HTTPURIHTML그리고REST
카테고리 컴퓨터/IT > 웹사이트
지은이 야마모토 요헤이 (멘토르, 2011년)
상세보기

스테이터스 코드
구분 코드 요약 설명
1xx 100 Continue 클라이언트는 헤더를 보내고 대기합니다. 서버는 이 요청을 처리할 수 있다고 판한한 경우, 100 Continue를 반환합니다.
101 Switching Protocol 이용할 프로토콜을 HTTP 1.1 에서 업그레이드 할 때 사용합니다. 
2xx 200 OK 요청이 성공했다는 것을 나타냅니다.
201 Created 요청이 성공해서 새로운 리소스를 작성했다는 것을 나타냅니다.
202 Accepted 클라이언트로부터 요청은 받아들였지만, 서버 측에서 처리가 완료되지 않았음을 나타냅니다.
203 Non-Authoritative Information 응답 헤더가 오리지널 서버로부터 제공된 것이 아님을 나타냅니다.
204 No Content 요청이 성공했지만, 클라이언트에게 돌려보낼 콘텐츠가 없다는 것을 나타냅니다. (보통 Delete 에 대한 응답)
205 Reset Content 요청이 성공하여 브라우저 화면을 리셋하고, 다음 입력 동작으로 옮겨간다는 의미 (재입력 상태로 변경 등)
206 Partial Content GET할 때 Range 헤더에 리소스의 범위를 바이트로 지정하면, 리소스의 일부만을 얻을 수 있습니다. Partial GET의 성공
207 Multi-Status WebDAV에 있어서, 일괄처리와 같이 처리결과의 스테이터스가 여러 개 존재할 경우. 각각의 결과에 대한 성공은 바디의 XML을 확인해야 함.
3xx 300 Multiple Choices 지정한 URI에 대해서 콘텐트 네고시에이션을 수행한 결과 (복수의 링크에 대한 반환을 하기 위해 사용)
301 Moved Permanently 지정한 리소스가 새로운 URI로 이동했다는 것을 나타냄. 이동할 곳의 URI는 location 헤더로 나타냄
302 Found 스펙상은 요청한 URI가 존재하지 않았기 때문에 클라이언트는 location 헤더가 나타내는 별도의 URI로 메서드를 바꾸지 않은 채 요청을 재송신할 필요가 있음을 나타냄
303 See Other 요청에 대한 처리결과를 location헤더에서 표시되는 URI에서 GET으로 취득할 수 있다는 것을 나타냄
304 Not Modified 조건부 GET일때, 리소스가 갱신되지 않았다는 것을 보여줌
305 Use Proxy 이 리소스에 액세스하기 위해서는 지정된 프록시를 통할 필요가 있다는 것을 나타냅니다.
307 Temporary Redirected 요청한 URI가 존재하지 않기 때문에, 클라이언트는 location 헤더가 가리키는 새로운 URI로 메서드를 변경하지 않고 요청을 재송신할 필요가 있음을 나타냄.
4xx 400 Bad Request 요청의 구문이 잘못되었다는 것을 나타냅니다. 또한, 다른 4xx 계열 에러코드에 적합하지 않은 에러일 경우에도 이용합니다.
401 Unauthorized 적절한 인증정보 없이 리소스에 엑세스하려고 했다는 것을 나타냅니다.
402 Payment Required 이 리소스를 조작하기 위해서는 요금이 필요하다는 것을 나타냅니다. (실제 이용 안됨)
403 Forbidden 401 Unauthorized 는 클라이언트가 적절한 인증정보를 제시하지 않았다는 것을 나타내지만 403은 그 밖의 이유로 리소스를 조작할 수 없음을 나타냄 (특정 IP어드레스만 접근할 수 없는 경우 등)
404 Not Found 지정한 리소스를 찾을 수 없다는 것을 나타냅니다.
405 Method Not Allowed 요청한 URI가 지정한 메서드를 지원하지 않는다는 것을 나타냅니다.
406 Not Acceptable 클라이언트가 Accept 헤더에서 지정한 표현을 반환할 수 없다는 것을 나타냅니다.
407 Proxy Authentication Required 프록시 인증이 필요하다는 것을 나타냅니다.
408 Request Timeout 클라이언트가 요청을 아무리 기다려도 다 송신하지 못했기 때문에 서버 쪽에서 타임아웃했다는 것을 나타냅니다.
409 Conflict 요청이 요구한 리소스에 대한 조작이 리소스의 현재 상태와 모순된다는 것을 나타냅니다. (충돌)
410 Gone 이 리소스가 이전에 존재했지만, 현재는 존재하지 않는다는 것을 나타냅니다.
411 Length Required 클라이언트가 Content-Length 헤더를 송신해야만 한다는 것을 나타냅니다.
412 Precondition Failed 조건부 요청에서 클라이언트가 지정한 사전조건이 서버 쪽에서 맞지않았다는 것을 나타냅니다. (낙관적 잠금에서 이용)
413 Request Entity Too Large 서버가 처리할 수 없을 만큼 요청 메시지가 크다는 것을 나타냅니다. 서버는 클라이언트 접속을 끊습니다. 
414 Request-URI Too Long 서버가 처라힐 수 없을 만큼 요청한 URI가 너무 길다는 것을 나타냅니다.
415 Unsupported Media Type 클라이언트가 지정한 미디어 타입을 서버가 지원하지 않는다는 것을 나타냅니다.
416 Requested Range Not Satisfiable 클라이언트가 Range 헤더에서 지정한 범위가 리소스의 사이즈와 맞지 않음을 나타냅니다.
417 Expectation Failed 클라이언트가 지정한 Expect 헤더를 서버가 이해할 수 없다는 것을 나타냅니다. 클라이언트가 요청의 Expect 헤더에서 100-Continue를 지정했음에도 불구하고 서버가 다룰 수 없는 경우
422 Unprocessable Entity WebDAV에 있어서 클라이언트가 송신한 XML이 구문으로서는 바르지만, 의미상에 오류가 있다는 것을 나타냅니다.
423 Locked WebDAV에서 잠겨 있는 리소스를 조작하려고 했다는 것을 나타냄
424 Failed Dependency WebDAV에서 클라이언트가 요구한 메서드가 의존하는 다른 메서드의 실패로 인해, 원래의 요청도 실패했다는 것을 나타냅니다.
5xx 500 Internal Server Error 서버 측에서 에러가 발생했다는 것을 나타냅니다. 또한, 다른 5xx 계열 에러코드에 적합하지 않은 에러인 경우에도 이용합니다.
501 Not Implemented 요청된 메서드를 이 URI에서 서버가 구현하고 있지 않다는 것을 나타냅니다.
502 Bad Gateway 프록시가 상류 서버에 요청을 보냈지만, 처리가 정상적으로 종료하지 않았음을 나타냅니다.
503 Service Unavailable 서버 점검 등에서 서비스를 제공할 수 없다는 것을 나타냅니다. 응담 Retry-After 헤더에 재개 시기를 통지할 수도 있습니다.
504 Gateway Timeout 프록시가 상류 서버에 요청을 보냈지만 접속할 수 없다는 것을 나타냅니다.
505 HTTP Version Not Supported 클라이언트가 송신한 요청의 HTTP 버전을 서버가 지원하지 않음을 나타냅니다.

'Brain Trainning > PRG Language' 카테고리의 다른 글

[C#] SqlBulkCopy & SqlBulkCopyOptions 사용 방법...  (0) 2012.01.18
[C#] Bulk Insert into SQL Server  (0) 2012.01.17
[C#] Import Excel to GridView  (0) 2011.12.30
[C#] MVC Tutorials  (0) 2011.11.27
[GeoIP] .NET API 테스트 결과  (0) 2011.06.13
posted by LifeisSimple
2012. 1. 24. 15:55 Brain Trainning/DataBase
단순히 Netsh 명령이나 Registry 편집 이외에도 네트웍 카드 고급옵션에서도 설정을 해줘야 합니다.

그래야 확실한 문제 해결이 됩니다.

http://blogs.technet.com/b/networking/archive/2008/11/14/the-effect-of-tcp-chimney-offload-on-viewing-network-traffic.aspx 


The effect of TCP Chimney offload on viewing network traffic

Have you ever run in to a problem where you are attempting to troubleshoot a network connectivity issue with a network capture utility and seen only the 3 way handshake? This will happen if you are using Netmon 2.x, Netmon 3.x, Wireshark, Ethereal and most other network capture utilities.

It is relatively common knowledge that this will happen when TCP Chimney offload is enabled but disabling it via the registry or netsh sometimes doesn’t always resolve the problem. TCP Chimney offload enables TCP/IP processing to be offloaded to network adapters that can handle the TCP/IP processing in hardware. The use of TCP Chimney offload causes traffic to be delivered at a lower layer of the TCP/IP stack than we listen on with most network capture utilities.

The initial troubleshooting for this type of issue is to turn off TCP Chimney Offload via Netsh as follows. The benefit of this is that it does not require a reboot.

To turn off TCP Chimney by using the Netsh.exe tool, follow these steps:

  1. Click Start, click Run, type cmd, and then click OK.
  2. At the command prompt, type Netsh int ip set chimney DISABLED and then press ENTER.

However, if this does not change what is shown in a network capture, you should then move forward with disabling all of the features of the Scalable Network Pack as documented in Knowledge Base article 948496 – “An update to turn off default SNP features is available for Windows Server 2003-based and Small Business Server 2003-based computers”.

To manually disable RSS, NetDMA and TCP Offload, follow these steps:

  1. Click Start , click Run , type regedit , and then click OK .
  2. Locate the following registry subkey: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
  3. Right-click EnableTCPChimney , and then click Modify.
  4. In the Value data box, type 0, and then click OK.
  5. Right-click EnableRSS, and then click Modify.
  6. In the Value data box, type 0, and then click OK.
  7. Right-click EnableTCPA, and then click Modify.
  8. In the Value data box, type 0, and then click OK.
  9. Exit Registry Editor, and then restart the computer.

Disabling Chimney with netsh and changed the registry values above will allow you to see all the traffic in most cases but not always. You may also need to look at the features related to TCP Chimney offload available on the Network card. To access these options, choose the configure button on the general tab of the adapters properties. This will bring up a Window similar to what is displayed below. The Advanced tab is where the changes will be made.

image

The configurable options available vary depending on how the vendor implements the driver for Windows. Many network cards have features including Receive Side Scaling, TCP Checksum Offload and TCP Large Send Offload. Disabling the offload features of the network card will allow you to view all of the traffic in many cases where disabling the scalable network pack features in the OS doesn’t work. You should refer to the vendor’s documentation for specific steps on how to disable these features.

As a last resort you may have to disable chimney from a hardware perspective. Refer to the vendor’s documentation for specific information on how to disable offload features. Possible ways to do this vary, and may include settings on the NIC, jumpers on the motherboard, and/or configuration in System BIOS.

- Michael Vargo

posted by LifeisSimple
2012. 1. 24. 15:40 Brain Trainning/DataBase

fatal error occurred while reading the input stream from the network. The session will be terminated (input error: 121, output error: 0).

위와 같은 오류가 2003 버전에서 발생했을 경우 ... 
윈도우 2008 과는 약간 다른듯 합니다. 일단... 레지스트리에 편집해야하는 해당 항목이 없습니다. 만들어 넣어야 할지... 아래는 2008 입니다.

저희는 문제가 발생해서 아래의 조치를 취했는데도 이런 문제가 발생했군요... 그래서... 다음과 같이 네떡카드에서도 설정을 해 줘야 합니다. ㅡㅡ;;

http://blogs.technet.com/b/networking/archive/2008/11/14/the-effect-of-tcp-chimney-offload-on-viewing-network-traffic.aspx 




iSCSI 장비에서 이런일이 많이 발생한다고 합니다. ... 쩝.



응용 프로그램이 Windows Server 2003을 실행하는 서버에서 SQL Server에 연결할 때 오류 메시지: "일반 네트워크 오류", "통신 연결 실패" 또는 "전송 수준 오류"

이 페이지에서

현상

영문자와 숫자가 조합된 PIN 코드가 설정된 Bluetooth 장치가 있다면. 서버를 Windows Server 2003 및 Microsoft SQL Server 실행 중입니다. TCP/IP를 사용하여 SQL Server에 연결하는 응용 프로그램이 있습니다. 응용 프로그램이 SQL Server에 연결할 때 이 시나리오에서는 사용자가 일시적으로 다음과 같은 오류 메시지 중 하나가 나타날 수 있습니다.
오류 메시지 1
[Microsoft][ODBC SQL Server 드라이버][DBNETLIB] 일반 네트워크 오류가 발생했습니다. 네트워크 설명서를 참조하십시오
오류 메시지 2
오류 [08S01] [Microsoft] [SQL Native Client] 통신 연결 오류입니다.
오류 메시지 3
System.Data.SqlClient.SqlException: 서버에 요청을 보낼 때 A 전송 수준 오류가 발생했습니다. (공급자: TCP 공급자 오류: 0 - 있는 기존 연결이 강제로 원격 호스트에서 닫혔습니다.)
SQL Server 네트워크 로드가 높은 때 이러한 오류 메시지 중 하나가 나타날 수 있습니다. 예를 들어, SQL Server 에서 데이터베이스를 복제할 때 이러한 오류 메시지 중 하나가 나타날 수 있습니다. 또는 SQL Server 에서 데이터베이스를 다중 사용자 응용 프로그램에 액세스할 때 이러한 오류 메시지 중 하나가 나타날 수 있습니다.

원인

서버에서 TCP Chimney 기능이 설정되어 있기 때문에 이 문제가 발생합니다. Windows Server 2003 확장 가능한 네트워킹 팩이에 의해 TCP Chimney 기능을 사용할 수 있습니다.

일반적으로 이 문제는 Broadcom 5708 칩세트 네트워크 어댑터를 사용하는 경우 발생합니다. 예를 들어, Broadcom 5708 칩세트를 다음 네트워크 어댑터를 사용합니다.
  • Broadcom NetXtreme 2세
  • Hewlett-Packard NC373i 다기능 기가비트 서버 어댑터
네트워크 어댑터가 다른 칩셋을 사용하는 경우에도 이 문제가 발생할 수 있습니다.

해결 방법

이 문제를 해결하려면 하드웨어 공급업체에 다음 업데이트가 있는지 하드웨어 공급업체에 문의하십시오.
  • 최신 기본 입/출력 시스템 (BIOS) 서버에 대해 업데이트
  • 네트워크 어댑터에 대한 최신 펌웨어 업데이트
  • 네트워크 어댑터의 최신 드라이버 업데이트
하드웨어 공급업체에 업데이트가 있는 경우 이 문제를 해결하려면 "해결 과정" 절을 참조하십시오.

해결 과정

중요한 이 섹션에서는, 메서드 또는 작업이 레지스트리 수정 방법을 알려 주는 단계가 포함되어 있습니다. 그러나 레지스트리를 잘못 수정하면 심각한 문제가 발생할 수 있습니다. 따라서 다음 이 단계를 주의 깊게 따라야 합니다. 추가 보호 기능을 수정하기 전에 레지스트리를 백업해야. 그런 다음 문제가 발생할 경우 레지스트리를 복원할 수 있습니다. 백업 및 복원하는 방법에 대한 자세한 내용은 Microsoft 기술 자료의 다음 문서를 참조하십시오.
322756  백업 및 Windows 에서 레지스트리를 복원하는 방법


이 문제를 해결하려면 TCP Chimney 기능을 해제하십시오. 이렇게 하려면 다음과 같이 하십시오.
  1. 시작 을 누르고 실행 을 cmd 를 입력한 다음 Enter 키를 누릅니다.
  2. 명령 프롬프트에서 다음 명령을 입력한 다음 Enter 키를 누릅니다.
    Netsh int IP DISABLED chimney 설정합니다.
    참고 이 명령을 실행한 후 서버를 다시 시작할 필요가 없습니다.
TCP Chimney 기능을 해제한 후 Windows Server 2003 성능이 저하되면 추가 단계를 수행하십시오.
  1. 시작 을 누르고, 실행 을, Regedit 를 입력한 다음 확인 을 누릅니다.
  2. 다음 레지스트리 하위 키를 찾습니다.
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
  3. EnableTCPChimney 레지스트리 항목을 두 번 클릭하십시오.
  4. DWORD 값 편집 대화 상자에서 값 데이터 상자에 0 입력한 다음 확인 을 누릅니다.
  5. EnableRSS 레지스트리 항목을 두 번 클릭하십시오.
  6. DWORD 값 편집 대화 상자에서 값 데이터 상자에 0 입력한 다음 확인 을 누릅니다.
  7. EnableTCPA 레지스트리 항목을 두 번 클릭하십시오.
  8. DWORD 값 편집 대화 상자에서 값 데이터 상자에 0 입력한 다음 확인 을 누릅니다.
  9. 서버를 다시 시작하십시오.

현재 상태

Microsoft는 "본 문서의 정보는 다음의 제품에 적용됩니다." 절에 나열된 Microsoft 제품에서 이 문제를 확인했습니다.

추가 정보

Windows Server 2003 확장 가능한 네트워킹 팩이 같은 기능을 제공합니다.
  • TCP Chimney 오프로드
  • 받는 쪽 (RSS) 확장
  • 네트워크에 직접 메모리 액세스 (NetDMA)
Windows Server 2003 네트워크 트래픽을 처리할 때 이러한 기능을 Windows Server 2003 성능을 최적화합니다.

Windows Server 2003 확장 가능한 네트워킹 팩을 얻으려면 Windows Server 2003 서비스 팩 2 (SP2)를 설치해야 합니다. 또는 Microsoft 기술 자료 문서 912222 설명하는 업데이트를 설치해야 합니다. 추가 정보는 다음 문서 번호를 클릭하여 Microsoft 기술 자료에서 확인하십시오:
912222  Microsoft Windows Server 2003 확장 가능한 네트워킹 팩을 릴리스
TCP Chimney 기능을 사용하려면 서버에서 지원하는 기술을 오프로드 네트워크 어댑터가 있어야 합니다.

네트워크 추적을 사용하여 TCP Chimney 기능을 사용할 수 있는지 여부를 확인하는 방법

TCP Chimney 기능을 사용하는 경우 직접 서버의 네트워크 추적을 캡처하면 네트워크 추적 3방향 핸드셰이크는 TCP 및 UDP 트래픽을 포함합니다. TCP/IP 스택이 해당 특정 부분을 무시할 네트워크 트래픽을 TCP Chimney 기능을 수 있기 때문에 네트워크 추적을 다른 트래픽이 포함되어 있지 않습니다. 패킷을 캡처하는 드라이버를 TCP/IP 스택의 해당 특정 부분에 위치합니다.

Microsoft의 현재 보기를 게시 날짜를 기준으로 이 문제에 대한 정보와 이 문서 솔루션에서 나타냅니다. 이 솔루션은 Microsoft 또는 타사 공급자를 통해 사용할 수 있습니다. Microsoft에서는 타사 공급자 또는 이 문서에서는 타사 솔루션을 특별히 권장하지 않습니다. 또한 있을 다른 타사 공급자나 타사 솔루션이 이 문서에서는 설명하지 않습니다. Microsoft는 변화하는 시장 환경에 대처해야 하므로 이 정보는 사용하여 약정 수 있도록 Microsoft에서 해석해서는 안. Microsoft 보장할 수 또는 모든 정보 또는 Microsoft 또는 언급한 타사 공급자에 의해 제시된 솔루션의 정확도를 보호인 수 없습니다. 

Microsoft는 어떠한 수 있으며 모든 표현, 보증 및 조건을 명시적, 묵시적 또는 법정 여부를 제외합니다. 이러한 포함되어 있지만 표현, 보증, 또는 제목, 권리 비침해를, 만족스러운 조건, 상품성, 및 모든 서비스, 솔루션, 제품, 또는 기타 자료를 또는 정보를 관련하여 특정 목적에의 적합성에 대한 조건이 제한되지 않습니다. 어떠한 경우에도 Microsoft이 이 문서에서는 포함되지는 몇 가지 설명합니다 타사 솔루션을 지지 것입니다.
posted by LifeisSimple
2012. 1. 24. 15:34 Brain Trainning/DataBase

다음과 같은 에러가 발생하는 경우가 있습니다. 

A fatal error occurred while reading the input stream from the network. The session will be terminated (input error: 121, output error: 0).

TCP Chimney Offload 기능을 활성화 했을 경우 Network 카드가 CPU에서 처리해야할 일부 기능을 분담해 시스템 부하를 줄여주는 역할을 하는데 일정이상의 네트웍부하가 있을 경우 이로 인해 네트웍에 문제가 생기는 경우가 있습니다. 때문에 DB 같이 중요한 시스템에서는 이 기능으로 인한 오류를 방지하기 위해 OFF 해야 합니다. 

참고 : 

TCP Chimney 오프로드는 네트워크를 통한 데이터 이동 관련 작업을 호스트 컴퓨터의 CPU에서 네트워크 어댑터로 오프로드할 수 있게 해주는 네트워킹 기술입니다. 이 기술을 사용하면 관리 효율성이나 보안에 손실을 주거나 추가 프로그램 사용하지 않고도 컴퓨터 또는 서버의 네트워크 데이터 처리 작업을 향상시킬 수 있습니다. 현재 네트워크 처리 오버헤드로 제한을 받는 프로그램도 TCP Chimney 오프로드와 함께 사용할 경우 일반적으로 더 잘 조정됩니다.

Microsoft 제품에 포함되어 있는 TCP 오프로드 기술 부분은 Alacritech와의 사용권 계약에 따라 사용되고 있으며 6,226,680, 6,247,060, 6,334,153, 6,389,479, 6,393,487, 6,427,171, 6,427,173, 6,434,620, 6,591,302, 6,658,480, 6,697,868, 6,751,665, 또는 6,757,746 등의 미국 특허 중 하나 이상에서 다룰 수 있습니다. Microsoft는 Alacritech의 특허에 의한 사용권을 갖고 있지 않아 하드웨어 부분에 오프로딩 기능을 구현할 수 없습니다. 이는 Alacritech의 특허 기술을 사용하기 위해 특별히 고안된 하드웨어에서 TCP 오프로드 기술을 사용하거나 판매하기 위한 사용권을 Alacritech 특허에서 허가받지 못했음을 명시적으로나 암시적으로 동의하고 인지한 것입니다.

자세한 정보는 Microsoft 웹 사이트의 TCP Chimney 라이선싱을 참조하십시오.


따라서, 아래와 같이 조치합니다.

Windows Server 2008 TCP Chimney 오프로드, 수신측 배율 및 네트워크 직접 메모리 액세스 기능에 대한 정보

이 페이지에서

소개

이 문서에서는 Windows Server 2008에서 TCP/IP 프로토콜에 대해 사용할 수 있는 TCP Chimney 오프로드, RSS(수신측 배율) 및 NetDMA(네트워크 직접 메모리 액세스) 기능에 대해 설명합니다.

추가 정보

TCP Chimney 오프로드 개요

TCP Chimney 오프로드는 네트워크 데이터 전송 동안 CPU의 작업을 네트워크 어댑터로 전송하는 데 도움을 주는 네트워킹 기술입니다. Windows Server 2008에서 TCP Chimney 오프로드는 Windows 네트워킹 하위 시스템이 TCP/IP 연결 처리를 특수한 TCP/IP 오프로드 처리를 지원하는 네트워크 어댑터로 오프로드할 수 있도록 합니다.

TCP Chimney 오프로드는 모든 버전의 Windows Server 2008 및 Windows Vista에서 사용할 수 있습니다. 네트워크 어댑터에서 해당 기능을 지원하기만 하면 TCP/IPv4 연결과 TCP/IPv6 연결 모두 오프로드될 수 있습니다.

Windows Server 2008에서 TCP Chimney 오프로드를 사용하거나 사용하지 않도록 설정하는 방법

TCP Chimney 오프로드는 다음 두 위치에서 사용하거나 사용하지 않도록 설정할 수 있습니다.
  • 운영 체제
  • 네트워크 어댑터의 고급 속성 페이지
TCP Chimney 오프로드는 두 위치에서 모두 사용하도록 설정되어야만 작동합니다. 기본적으로 TCP Chimney 오프로드는 이 두 위치에서 사용하지 않도록 설정되어 있습니다. 그러나 OEM 설치는 운영 체제, 네트워크 어댑터 또는 운영 체제와 네트워크 어댑터 모두에서 TCP Chimney 오프로드를 사용하도록 설정할 수 있습니다.

운영 체제에서 TCP Chimney 오프로드를 구성하는 방법

  • TCP Chimney 오프로드를 사용하도록 설정하려면 다음과 같이 하십시오.
    1. 관리 자격 증명을 사용해서 명령 프롬프트를 엽니다.
    2. 명령 프롬프트에서 다음 명령을 입력한 후 Enter 키를 누릅니다.
      netsh int tcp set global chimney=enabled
  • TCP Chimney 오프로드를 사용하지 않도록 설정하려면 다음과 같이 하십시오.
    1. 관리 자격 증명을 사용해서 명령 프롬프트를 엽니다.
    2. 명령 프롬프트에서 다음 명령을 입력한 후 Enter 키를 누릅니다.
      netsh int tcp set global chimney=disabled
  • TCP Chimney 오프로드의 현재 상태를 확인하려면 다음과 같이 하십시오.
    1. 관리 자격 증명을 사용해서 명령 프롬프트를 엽니다.
    2. 명령 프롬프트에서 다음 명령을 입력한 후 Enter 키를 누릅니다.
      netsh int tcp show global

네트워크 어댑터에서 TCP Chimney 오프로드를 구성하는 방법

  • TCP Chimney 오프로드를 사용하거나 사용하지 않도록 설정하려면 다음과 같이 하십시오.
    1. 장치 관리자를 엽니다.
    2. 네트워크 어댑터에서 원하는 네트워크 어댑터를 두 번 클릭합니다.
    3. 고급 탭에서 TCP 오프로드 항목 옆에 있는 사용 또는 사용 안 함 확인란을 클릭합니다. 

      참고 제조업체마다 다른 용어를 사용해서 네트워크 어댑터의 고급 속성 페이지에서 TCP Chimney 오프로드를 기술할 수 있습니다.

TCP Chimney 오프로드가 다른 프로그램 및 서비스와 공존하는 방식

TCP Chimney 오프로드 기술은 지정된 TCP 연결에 대한 TCP/IP 처리를 전용 네트워크 어댑터로 오프로드할 때 네트워킹 하위 시스템의 하위 계층 서비스에 의존하는 다른 프로그램이나 서비스와 공존해야 합니다. 다음 표에는 TCP Chimney 오프로드가 다른 프로그램 및 서비스와 공존하는 방식이 나와 있습니다.
프로그램 또는 서비스TCP Chimney 오프로드에서 작동하는 방법해당 서비스와 TCP Chimney 오프로드가 둘 다 사용하도록 설정되어 있을 때 예상되는 동작
Windows 방화벽 방화벽이 지정된 TCP 연결에 사용되도록 구성되면 TCP/IP 스택은 해당 TCP 연결을 네트워크 어댑터로 오프로드합니다.
타사 방화벽 구현별 일부 방화벽 공급업체는 방화벽 서비스가 실행되는 동안 TCP Chimney 오프로드가 사용될 수 있는 방식으로 제품을 구현하기로 결정했습니다. 방화벽 설명서에서 사용 중인 제품이 TCP Chimney 오프로드를 지원하는지 여부를 확인하십시오.
IPsec(인터넷 프로토콜 보안) 정책 아니오 시스템에 IPsec 정책이 적용된 경우 TCP/IP 스택은 TCP 연결을 오프로드하려고 하지 않습니다. 따라서 IPsec 계층은 모든 패킷을 검사하여 원하는 보안을 제공할 수 있습니다.
네트워크 어댑터 팀 서비스(이 서비스를 부하 분산 및 장애 조치 서비스라고도 합니다. 이 서비스는 일반적을 OEM에서 제공합니다.) 구현별 일부 OEM에서는 TCP Chimney 오프로드와 공존할 수 있도록 네트워크 어댑터 팀 솔루션을 구현하기로 결정했습니다. TCP Chimney 오프로드를 네트워크 어댑터 팀 서비스와 함께 사용할 수 있는지 확인하려면 이 서비스 설명서를 참조하십시오.
Windows 가상화(Hyper-V 기술) 아니오 Microsoft Hyper-V 기술을 사용해서 가상 시스템을 실행하는 경우 운영 체제에서 TCP Chimney 오프로드를 활용하지 못합니다.
네트워크 모니터링 도구(예: 네트워크 모니터 및 Wireshark) 구현별 일부 네트워크 모니터링 도구는 TCP Chimney와 공존할 수 있지만 오프로드된 연결을 모니터링하지 못할 수 있습니다.
NLB(네트워크 부하 분산) 서비스 아니오 서버에서 NLB 서비스를 구성하는 경우 TCP/IP 스택은 TCP 연결을 오프로드하지 않습니다.
클러스터 서비스 그러나 Network 내결함성 드라이버(NetFT.sys)를 사용하는 TCP 연결은 오프로드되지 않습니다. NetFT는 내결함성 노드 간 클러스터 통신에 사용됩니다.
NAT(네트워크 주소 변환) 서비스(인터넷 연결 공유 서비스라도고 함) 아니오 이 서비스가 설치 및 실행되고 있는 경우 TCP/IP 스택은 연결을 오프로드하지 않습니다.

TCP Chimney 오프로드가 작동하는 방식을 확인하는 방법

운영 체제 및 네트워크 어댑터에서 TCP Chimney 오프로드가 사용 가능하게 설정되면 TCP/IP 스택은 적절한 TCP 연결을 네트워크 어댑터로 오프로드하려고 합니다. 시스템에서 현재 설정되어 있는 TCP 연결 중에서 오프로드된 연결을 확인하려면 다음과 같이 하십시오.
  1. 관리 자격 증명을 사용해서 명령 프롬프트를 엽니다.
  2. 다음 명령을 입력하고 Enter 키를 누릅니다.
    netstat –t
    다음과 비슷한 결과가 표시됩니다.
    Active Connections
    
      Proto  Local Address          Foreign Address        State           Offload State
    
      TCP    127.0.0.1:52613        computer_name:52614       ESTABLISHED     InHost TCP    192.168.1.103:52614        computer_name:52613       ESTABLISHED     Offloaded
    이 출력에서는 두 번째 연결이 오프로드되었습니다.
Windows Server 2003의 TCP Chimney 오프로드에 대한 자세한 내용은 다음 문서 번호를 클릭하여 Microsoft 기술 자료 문서를 참조하십시오.
912222  Microsoft Windows Server 2003 Scalable Networking Pack 릴리스

Windows Server 2008에서 RSS를 사용하거나 사용하지 않도록 설정하는 방법

RSS를 사용하도록 설정하려면 다음과 같이 하십시오.
  1. 관리 자격 증명을 사용해서 명령 프롬프트를 엽니다.
  2. 명령 프롬프트에서 다음 명령을 입력한 후 Enter 키를 누릅니다.
    netsh int tcp set global rss=enabled
RSS를 사용하지 않도록 설정하려면 다음과 같이 하십시오.
  1. 관리 자격 증명을 사용해서 명령 프롬프트를 엽니다.
  2. 명령 프롬프트에서 다음 명령을 입력한 후 Enter 키를 누릅니다.
    netsh int tcp set global rss=disabled
RSS의 현재 상태를 확인하려면 다음과 같이 하십시오.
  1. 관리 자격 증명을 사용해서 명령 프롬프트를 엽니다.
  2. 명령 프롬프트에서 다음 명령을 입력한 다음 Enter 키를 누릅니다.
    netsh int tcp show global
명령을 사용하여 RSS를 사용하도록 설정할 경우 다음 메시지가 표시됩니다.
TCP Global Parameters ---------------------------------------------- Receive-Side Scaling State : enabled
참고 기본적으로 RSS는 사용하도록 설정되어 있습니다.

Windows Server 2008에서 NetDMA를 사용하거나 사용하지 않도록 설정하는 방법

저희가 NetDMA를 사용하거나 사용하지 않게 설정하도록 하려면 "해결 지원" 절로 이동하십시오. NetDMA를 사용하거나 사용하지 않도록 직접 설정하려면 "직접 해결" 절로 이동하십시오.

해결 지원



이 문제를 자동으로 해결하려면 Fix it 단추나 링크를 클릭합니다. 파일 다운로드 대화 상자에서실행을 클릭하고 Fix it 마법사의 단계를 따릅니다.


NetDMA 사용 
Microsoft Fix it 50610
NetDMA 사용 안 함 
Microsoft Fix it 50611


참고
  • NetDMA 사용 패키지가 작동하는지 확인하려면 NetDMA 기능을 상요하도록 설정해야 합니다. NetDMA 사용에 대한 자세한 내용을 보려면 다음 링크를 클릭하십시오.
  • 이 마법사는 영어로만 제공될 수 있습니다. 그러나 다른 언어 버전의 Windows에서도 자동 해결 기능을 사용할 수 있습니다.
  • 현재 문제가 있는 컴퓨터에서 작업하고 있지 않은 경우 Fix it 솔루션을 플래시 드라이브 또는 CD에 저장한 후 문제가 있는 컴퓨터에서 실행하십시오.

그런 다음 "문제가 해결되었습니까?" 절로 이동하십시오.



직접 해결

NetDMA를 사용하거나 사용하지 않도록 설정하려면 다음과 같이 하십시오.
  1. 시작실행을 차례로 클릭하고 regedit를 입력한 다음 확인을 클릭합니다.
  2. 다음 레지스트리 하위 키를 찾아 클릭합니다.
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
  3. EnableTCPA 레지스트리 항목을 두 번 클릭합니다.
    참고 이 레지스트리 항목이 없으면 매개 변수를 마우스 오른쪽 단추로 클릭하고 새로 만들기를 가리킨 후 DWORD 값을 클릭하고 EnableTCPA를 입력한 후 Enter 키를 누릅니다.
  4. NetDMA를 사용하도록 설정하려면 값 데이터 상자에 1을 입력한 후 확인을 클릭합니다.
  5. NetDMA를 사용하지 않도록 설정하려면 값 데이터 상자에 0을 입력한 후 확인을 클릭합니다.
  6. EnableTCPA 레지스트리 항목이 없는 경우 NetDMA 기능을 사용하도록 설정해야 합니다.

문제가 해결되었습니까?

  • 문제가 해결되었는지 확인합니다. 문제가 해결되었다면 이 절에서 설명한 작업이 끝난 것이지만 문제가 해결되지 않은 경우에는 기술 지원 서비스에 문의할 수 있습니다.
  • 의견을 보내 주셔서 감사합니다. 의견을 보내거나 이 해결 방법에 대한 문제점을 보고하려면 "Fix it for me" 블로그에 의견을 남겨 주시거나 전자 메일 메시지를 보내 주십시오.
이 문서에 나와 있는 타사 제품은 Microsoft와 무관한 회사에서 제조한 것입니다. Microsoft는 이들 제품의 성능이나 신뢰성에 관하여 명시적이든 묵시적이든 어떠한 보증도 하지 않습니다.

본 문서의 정보는 다음의 제품에 적용됩니다.
키워드: 
kbenable kbnetworkmon kbnlb kbnetworkcard kbnetworkconnectivity kbexpertiseadvanced kbinfo kbhowto kbfixme kbmsifixme KB951037
posted by LifeisSimple
2012. 1. 19. 14:55 Brain Trainning/DataBase

링크  http://www.microsoft.com/sqlserver/en/us/product-info/compare.aspx 

Compare Microsoft SQL Server Editions

Share this page

Compare Database Solutions

Provide your organization with the foundation for a comprehensive information platform that helps you get the most value out of your database environment by using Microsoft SQL Server 2008 R2. Plus, you get a range of editions with new features to choose from to meet the needs of organizations both large and small, including new premium editions for large-scale data centers and data warehouses. SQL Server 2008 R2 further enhances your scalability potential by supporting up to 256 logical processors.

Compare SQL Server 2008 R2 with competitive database solutions. You can also compare different editions of SQL Server 2008 R2 by capability or learn more about all editions.

posted by LifeisSimple
2012. 1. 19. 13:22 Brain Trainning/DataBase

SQL Server 자동화 Script 입니다.

아래의 링크에서 파일을 다운받아서 실행하면 됩니다. 아직 검증은 하지 않았지만 아무래도 유용하지 않을까 합니다.


SQL Server Automation Scripts

Snap up some of the DBA automation scripts that Microsoft uses
SQL Server Pro
InstantDoc ID #96463

Executive Summary:
Microsoft's internal Database Operations team makes SQL Server automation scripts available to database administrators (DBAs). SQL Server automation scripts make up a suite of SQL Server maintenance jobs. SQL Server maintenance jobs provide DBAs with automated tasks that they can run on their servers on a regular basis.

Microsoft makes a lot of its internal IT operations open to the public so that people can see how this world-class company runs its IT business. At Tech-Ed 2007, Mark Pohto, who heads Microsoft's internal Database Operations team, showed me some new SQL Server DBA automation scripts his team uses. Together, these scripts constitute a suite of SQL Server Agent maintenance jobs the team uses to perform backups, automate database maintenance, improve performance, mitigate risk, and improve the disaster-recovery process. But the coolest thing about these scripts is that they're free for you to download and use.

The scripts automate tasks that almost everyone using SQL Server should regularly perform on their servers. Because these are SQL Server Agent jobs, you can easily install them by running a T-SQL script. Each job runs a related stored procedure that's installed when the job is created.

After you install the package, you'll have the following scripts:

  • SQLBackupAll performs a full backup of all databases except those you specifically exclude. You can specify the desired backup location, whether to do a third-party backup or a native backup, whether to exclude system or read-only databases, which backup threads to use, and job priority.
  • SQLBackupDiffAll performs a differential backup of all unexcluded databases by using either the built-in backup utility or Quest Software's LiteSpeed for SQL Server. This job is disabled by default because some environments don't use differential backups.
  • SQLBackupTranAll backs up transaction logs for all unexcluded databases. The job includes parameters to dynamically define the desired backup location and specify whether to use native backup or a third-party backup tool.
  • SQLBackupChecker looks for databases that haven't been backed up within a specified number of hours and alerts you if it finds any.
  • SQLDBCCAll performs a battery of database consistency checks on all system and user databases.
  • SQLIndexDefragAll defragments indexes on all unexcluded SQL Server databases. You can also use this job to defragment indexes within a specific SQL Server instance, database, or table. This job is disabled by default.
  • SQLUpdateStatistics updates the statistics for the tables in all unexcluded databases. You can also use this job to update index statistics within a specific SQL Server instance, database, or table. This job is disabled by default.
  • SQLCleanupMsdbBackupHistory cleans up the backup-history information in the msdb database.
  • SQLCycleErrorLog periodically cycles the SQL Server error log to keep it at a size that's manageable for viewing through the native tools.

The download for these scripts includes a Word document that explains the parameters and options for each script and provides examples of how to use it. For example, to defragment all the indexes in all databases, you can type the following at the query prompt in SQL Query Analyzer or SQL Server Management Studio:

EXEC msdb.. SQLIndexDefragAll:

Parameters let you specify the database, the table, and the percent fill factor; the sample command above uses the default values (null, null, and 10.0, respectively).

Installing the automation scripts is easy. First, make sure that your SQL Server 2005 or SQL Server 2000 server has SQL Server Agent running on it. Then run the command

C:\> Jobsinstall.cmd servername

where servername is the name of your server. To uninstall the jobs, use the command

C:\> Jobsuninstall.cmd servername

You can download the automation scripts at http://download.microsoft.com/download/4/0/C/40CBAD9A-D990-450B-8785-F288CEBFB448/AITScripts.zip

SQL SERVER AUTOMATION SCRIPTS
BENEFITS: Microsoft's internal Database Operations team's SQL Server automation scripts automate tasks you'd normally have to manually perform on your servers on a regular basis.
SYSTEM REQUIREMENTS AND NOTES: SQL Server 2005, SQL Server 2000, SQL Server Agent
HOW TO GET IT: 
You can download SQL Server automation scripts fromhttp://download.microsoft.com/download/4/0/C/40CBAD9A-D990-450B-8785-F288CEBFB448/AITScripts.zip

posted by LifeisSimple
2012. 1. 18. 22:59 Brain Trainning/PRG Language

이제 이런저런 이유로 코드도 필요하고 그렇군요 흠... 벌크 insert할때 사용할 수 있는 방법입니다만... 문제는... 
Datatable 을 만들어줘야 하는 것이고... 기존 Data를 Update하는 부분은 없군요... 삭제라도 할 수 있어야 하는데...  


 


SqlBulkCopy 클래스

.NET Framework 4
이 항목은 아직 평가되지 않았습니다.이 항목 평가

데이터가 있는 SQL Server 테이블을 다른 소스에서 대량으로 로드하는 작업을 효율적으로 수행할 수 있습니다.

System.Object 
  System.Data.SqlClient.SqlBulkCopy

네임스페이스:  System.Data.SqlClient
어셈블리:  System.Data(System.Data.dll)
public sealed class SqlBulkCopy : IDisposable

SqlBulkCopy 형식에서는 다음과 같은 멤버를 노출합니다.

 이름설명
Public 메서드 SqlBulkCopy(SqlConnection) 지정된 SqlConnection의 열려 있는 인스턴스를 사용하여 SqlBulkCopy 클래스의 새 인스턴스를 초기화합니다.
Public 메서드 SqlBulkCopy(String) 제공된 connectionString을 기반으로 하는 SqlConnection의 새 인스턴스를 초기화하고 엽니다. 이 생성자는 SqlConnection을 사용하여SqlBulkCopy 클래스의 새 인스턴스를 초기화합니다.
Public 메서드 SqlBulkCopy(String, SqlBulkCopyOptions) 제공된 connectionString을 기반으로 하는 SqlConnection의 새 인스턴스를 초기화하고 엽니다. 이 생성자는 SqlConnection을 사용하여SqlBulkCopy 클래스의 새 인스턴스를 초기화합니다. SqlConnection 인스턴스는 copyOptions 매개 변수에 제공된 옵션에 따라 작동합니다.
Public 메서드 SqlBulkCopy(SqlConnection, SqlBulkCopyOptions, SqlTransaction) 제공된 SqlConnection의 이미 열려 있는 인스턴스를 사용하여 SqlBulkCopy 클래스의 새 인스턴스를 초기화합니다. SqlBulkCopy 인스턴스는 copyOptions 매개 변수에 제공된 옵션에 따라 작동합니다. 제공된 SqlTransaction이 null이 아니면 복사 작업이 해당 트랜잭션 내에서 수행됩니다.
위쪽
 이름설명
Public 속성 BatchSize 각 일괄 작업에 포함된 행의 수입니다. 각 일괄 작업이 끝나면 해당 일괄 작업에 포함된 행이 서버로 전송됩니다.
Public 속성 BulkCopyTimeout 제한 시간에 도달하기 전까지 작업을 완료해야 하는 시간(초)입니다.
Public 속성 ColumnMappings SqlBulkCopyColumnMapping 항목의 컬렉션을 반환합니다. 열 매핑은 데이터 소스 열과 대상 열 사이의 관계를 정의합니다.
Public 속성 DestinationTableName 서버에 있는 대상 테이블의 이름입니다.
Public 속성 NotifyAfter 알림 이벤트를 생성하기 전에 처리할 행의 수를 정의합니다.
위쪽
 이름설명
Public 메서드 Close SqlBulkCopy 인스턴스를 닫습니다.
Public 메서드 Equals(Object) 지정한 Object가 현재 Object와 같은지 여부를 확인합니다. (Object에서 상속됨)
Protected 메서드 Finalize 가비지 수집에서 회수하기 전에 개체에서 리소스를 해제하고 다른 정리 작업을 수행할 수 있게 합니다. (Object에서 상속됨)
Public 메서드 GetHashCode 특정 형식에 대한 해시 함수 역할을 합니다. (Object에서 상속됨)
Public 메서드 GetType 현재 인스턴스의 Type을 가져옵니다. (Object에서 상속됨)
Protected 메서드 MemberwiseClone 현재 Object의 단순 복사본을 만듭니다. (Object에서 상속됨)
Public 메서드 ToString 현재 개체를 나타내는 문자열을 반환합니다. (Object에서 상속됨)
Public 메서드 WriteToServer(DataRow()) 제공된 DataRow 배열의 모든 행을 SqlBulkCopy 개체의 DestinationTableName 속성에 지정된 대상 테이블로 복사합니다.
Public 메서드 WriteToServer(DataTable) 제공된 DataTable의 모든 행을 SqlBulkCopy 개체의 DestinationTableName 속성에 지정된 대상 테이블로 복사합니다.
Public 메서드 WriteToServer(IDataReader) 제공된 IDataReader의 모든 행을 SqlBulkCopy 개체의 DestinationTableName 속성에 지정된 대상 테이블로 복사합니다.
Public 메서드 WriteToServer(DataTable, DataRowState) 제공된 DataTable에서 제공된 행 상태와 일치하는 행만을 SqlBulkCopy 개체의 DestinationTableName 속성에 지정된 대상 테이블로 복사합니다.
위쪽
 이름설명
Public 이벤트 SqlRowsCopied NotifyAfter 속성에 지정된 개수의 행이 처리될 때마다 발생합니다.
위쪽
 이름설명
명시적 인터페이스 구현 Private 메서드 IDisposable.Dispose SqlBulkCopy 클래스의 현재 인스턴스에서 사용하는 모든 리소스를 해제합니다.
위쪽

Microsoft SQL Server에는 단일 서버에서 또는 여러 서버 간에 테이블의 데이터를 다른 테이블로 이동할 때 많이 사용하는 bcp라는 명령 프롬프트 유틸리티가 포함되어 있습니다.SqlBulkCopy 클래스를 사용하면 비슷한 기능을 제공하는 관리되는 코드 솔루션을 작성할 수 있습니다. 또한 INSERT 문 등을 사용하여 SQL Server 테이블로 데이터를 로드하는 방법도 있지만 SqlBulkCopy를 사용하면 다른 방법에 비해 성능이 향상됩니다.

SqlBulkCopy 클래스는 SQL Server 테이블에 데이터를 쓸 때에만 사용됩니다. 그러나 데이터를 DataTable 인스턴스에 로드하거나 IDataReader 인스턴스로 데이터를 읽을 수 있는 경우 SQL Server를 포함한 모든 데이터 소스를 사용할 수 있습니다.

SqlDateTime 형식의 DataTable 열을 SQL Server 2008에 추가된 날짜/시간 형식 중 하나의 형식을 가진 SQL Server 열에 대량 로드할 경우 SqlBulkCopy가 실패합니다.

다음 콘솔 응용 프로그램에서는 SqlBulkCopy 클래스를 사용하여 데이터를 로드하는 방법을 보여 줍니다. 이 예제에서는 SqlDataReader를 사용하여 SQL Server 2005 AdventureWorks 데이터베이스에 있는 Production.Product 테이블의 데이터를 같은 데이터베이스의 비슷한 테이블로 복사합니다.

중요 중요

대량 복사 예제 설정(ADO.NET)에서 설명하는 대로 작업 테이블을 만들지 않으면 이 샘플이 실행되지 않습니다. 이 코드는 SqlBulkCopy를 사용하는 구문을 보여 주기 위해서만 제공됩니다. 소스 및 대상 테이블이 같은 SQL Server 인스턴스에 있으면 Transact-SQL INSERT … SELECT 문을 사용하여 데이터를 더욱 빠르고 쉽게 복사할 수 있습니다.

using System.Data.SqlClient;

class Program
{
    static void Main()
    {
        string connectionString = GetConnectionString();
        // Open a sourceConnection to the AdventureWorks database.
        using (SqlConnection sourceConnection =
                   new SqlConnection(connectionString))
        {
            sourceConnection.Open();

            // Perform an initial count on the destination table.
            SqlCommand commandRowCount = new SqlCommand(
                "SELECT COUNT(*) FROM " +
                "dbo.BulkCopyDemoMatchingColumns;",
                sourceConnection);
            long countStart = System.Convert.ToInt32(
                commandRowCount.ExecuteScalar());
            Console.WriteLine("Starting row count = {0}", countStart);

            // Get data from the source table as a SqlDataReader.
            SqlCommand commandSourceData = new SqlCommand(
                "SELECT ProductID, Name, " +
                "ProductNumber " +
                "FROM Production.Product;", sourceConnection);
            SqlDataReader reader =
                commandSourceData.ExecuteReader();

            // Open the destination connection. In the real world you would 
            // not use SqlBulkCopy to move data from one table to the other 
            // in the same database. This is for demonstration purposes only.
            using (SqlConnection destinationConnection =
                       new SqlConnection(connectionString))
            {
                destinationConnection.Open();

                // Set up the bulk copy object. 
                // Note that the column positions in the source
                // data reader match the column positions in 
                // the destination table so there is no need to
                // map columns.
                using (SqlBulkCopy bulkCopy =
                           new SqlBulkCopy(destinationConnection))
                {
                    bulkCopy.DestinationTableName =
                        "dbo.BulkCopyDemoMatchingColumns";

                    try
                    {
                        // Write from the source to the destination.
                        bulkCopy.WriteToServer(reader);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    finally
                    {
                        // Close the SqlDataReader. The SqlBulkCopy
                        // object is automatically closed at the end
                        // of the using block.
                        reader.Close();
                    }
                }

                // Perform a final count on the destination 
                // table to see how many rows were added.
                long countEnd = System.Convert.ToInt32(
                    commandRowCount.ExecuteScalar());
                Console.WriteLine("Ending row count = {0}", countEnd);
                Console.WriteLine("{0} rows were added.", countEnd - countStart);
                Console.WriteLine("Press Enter to finish.");
                Console.ReadLine();
            }
        }
    }

    private static string GetConnectionString()
        // To avoid storing the sourceConnection string in your code, 
        // you can retrieve it from a configuration file. 
    {
        return "Data Source=(local); " +
            " Integrated Security=true;" +
            "Initial Catalog=AdventureWorks;";
    }
}


.NET Framework

4, 3.5, 3.0, 2.0에서 지원

.NET Framework Client Profile

4, 3.5 SP1에서 지원

Windows 7, Windows Vista SP1 이상, Windows XP SP3, Windows XP SP2 x64 버전, Windows Server 2008(Server Core는 지원되지 않음), Windows Server 2008 R2(Server Core는 SP1 이상에서 지원됨), Windows Server 2003 SP2

.NET Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.
이 형식의 모든 공용 static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.
SQL Server에서의 대량 복사 작업(ADO.NET)

 
 

SqlBulkCopyOptions 열거형

.NET Framework 3.5
이 항목은 아직 평가되지 않았습니다.이 항목 평가

업데이트: 2007년 11월

SqlBulkCopy의 인스턴스와 함께 사용할 하나 이상의 옵션을 지정하는 비트 플래그입니다.

이 열거형에는 멤버 값을 비트로 조합할 수 있는 FlagsAttribute 특성이 있습니다.

네임스페이스:  System.Data.SqlClient
어셈블리:  System.Data(System.Data.dll)

[FlagsAttribute]
public enum SqlBulkCopyOptions
/** @attribute FlagsAttribute */
public enum SqlBulkCopyOptions
public enum SqlBulkCopyOptions
멤버 이름설명
Default 모든 옵션에 대해 기본값을 사용합니다.
KeepIdentity 소스 ID 값을 유지합니다. 지정되지 않은 경우, 대상에서 ID 값을 할당합니다.
CheckConstraints 데이터가 삽입되는 동안 제약 조건을 검사합니다. 기본적으로 제약 조건은 검사되지 않습니다.
TableLock 대량 복사 작업 기간에 대한 대량 업데이트 잠금을 가져옵니다. 지정되지 않은 경우, 행 잠금이 사용됩니다.
KeepNulls 기본값 설정에 관계없이 대상 테이블에 null 값을 유지합니다. 지정되지 않은 경우, 기본값이 적용되는 경우 null 값은 기본값으로 대체됩니다.
FireTriggers 지정된 경우, 서버에서는 데이터베이스에 삽입되는 행에 대해 삽입 트리거를 발생시킵니다.
UseInternalTransaction 지정된 경우 대량 복사 작업의 각 일괄 작업은 한 트랜잭션 내에서 발생합니다. 이 옵션을 지정하고 SqlTransaction 개체를 생성자에게 제공하면 ArgumentException이 발생합니다.

SqlBulkCopy 인스턴스를 생성할 때 SqlBulkCopyOptions 열거형을 사용하여 해당 인스턴스에 대한 WriteToServer 메서드의 동작을 변경할 수 있습니다.

다음 콘솔 응용 프로그램에서는 각 행의 ID 열에 새 값을 생성하는 대신 대량 로드를 수행하여 소스 테이블의 ID 열에 있는 값을 대상 테이블의 해당 열로 복사하는 방법을 보여 줍니다.

옵션에 따라 대량 로드 작업이 작동하는 방식을 확인하려면 dbo.BulkCopyDemoMatchingColumns 테이블을 비운 채로 샘플을 실행합니다. 모든 행이 소스에서 로드됩니다. 그런 다음 테이블을 비우지 않은 채로 샘플을 다시 실행합니다. 그러면 예외가 throw되고, 코드는 기본 키 위반으로 인해 행이 추가되지 않았음을 알리는 메시지를 콘솔 창에 씁니다.

 중요:

대량 복사 예제 설정(ADO.NET) 에서 설명하는 대로 작업 테이블을 만들지 않으면 이 샘플이 실행되지 않습니다. 이 코드는 SqlBulkCopy를 사용하는 구문을 보여 주기 위해서만 제공됩니다. 소스 및 대상 테이블이 같은 SQL Server 인스턴스에 있으면 Transact-SQL INSERT … SELECT 문을 사용하여 데이터를 더욱 빠르고 쉽게 복사할 수 있습니다.

using System.Data.SqlClient;

class Program
{
    static void Main()
    {
        string connectionString = GetConnectionString();
        // Open a sourceConnection to the AdventureWorks database.
        using (SqlConnection sourceConnection =
                   new SqlConnection(connectionString))
        {
            sourceConnection.Open();

            // Perform an initial count on the destination table.
            SqlCommand commandRowCount = new SqlCommand(
                "SELECT COUNT(*) FROM " +
                "dbo.BulkCopyDemoMatchingColumns;",
                sourceConnection);
            long countStart = System.Convert.ToInt32(
                commandRowCount.ExecuteScalar());
            Console.WriteLine("Starting row count = {0}", countStart);

            // Get data from the source table as a SqlDataReader.
            SqlCommand commandSourceData = new SqlCommand(
                "SELECT ProductID, Name, " +
                "ProductNumber " +
                "FROM Production.Product;", sourceConnection);
            SqlDataReader reader =
                commandSourceData.ExecuteReader();

            // Create the SqlBulkCopy object using a connection string 
            // and the KeepIdentity option. 
            // In the real world you would not use SqlBulkCopy to move
            // data from one table to the other in the same database.
            using (SqlBulkCopy bulkCopy =
                new SqlBulkCopy(connectionString, SqlBulkCopyOptions.KeepIdentity))
            {
                bulkCopy.DestinationTableName =
                    "dbo.BulkCopyDemoMatchingColumns";

                try
                {
                    // Write from the source to the destination.
                    bulkCopy.WriteToServer(reader);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    // Close the SqlDataReader. The SqlBulkCopy
                    // object is automatically closed at the end
                    // of the using block.
                    reader.Close();
                }
            }

            // Perform a final count on the destination 
            // table to see how many rows were added.
            long countEnd = System.Convert.ToInt32(
                commandRowCount.ExecuteScalar());
            Console.WriteLine("Ending row count = {0}", countEnd);
            Console.WriteLine("{0} rows were added.", countEnd - countStart);
            Console.WriteLine("Press Enter to finish.");
            Console.ReadLine();
        }
    }

    private static string GetConnectionString()
        // To avoid storing the sourceConnection string in your code, 
        // you can retrieve it from a configuration file. 
    {
        return "Data Source=(local); " +
            " Integrated Security=true;" +
            "Initial Catalog=AdventureWorks;";
    }
}


Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

.NET Framework 및 .NET Compact Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.

.NET Framework

3.5, 3.0, 2.0에서 지원

'Brain Trainning > PRG Language' 카테고리의 다른 글

[WEB] Status Code (책펌)  (0) 2012.01.25
[C#] Bulk Insert into SQL Server  (0) 2012.01.17
[C#] Import Excel to GridView  (0) 2011.12.30
[C#] MVC Tutorials  (0) 2011.11.27
[GeoIP] .NET API 테스트 결과  (0) 2011.06.13
posted by LifeisSimple
2012. 1. 17. 23:40 Brain Trainning/PRG Language
건바이 건으로 집어 넣는데는 시간소요가 극심합니다. 
이럴때는 Bulk Insert를 하고 싶은데요.. 특히나 로컬DB에서 넣을때는 한방이면 되는데... 

C#에서는 어떻게 구현하는지 ... 

아래에 예가 잘 나와 있습니다. ^^ 
점점 소소한 프로그램에 재미를 느끼는 것 같습니다... DBA를 포기하고... 전향? ㅎㅎ

출처는 :  http://blogs.msdn.com/b/nikhilsi/archive/2008/06/11/bulk-insert-into-sql-from-c-app.aspx 

Bulk Insert into SQL from C# App

One of the common problems I have seen is to bulk upload data to a SQL Server database. If you have the flexibility to directly run your code in SQL, you have a ton of options. But let's say that you have to massage the data before you throw it in to the database, then you have to really know your SQL (well to do it in SQL).

Let's say you have to read data from an RSS feed, parse it and then load it into SQL. Let's assume further that this feed updates every 2 hours. It would be a trivial task to write a C# app that reads and parses the feed. One crude way to upload this data would be to do a single row insert for each data element. This would be terribly inefficient. The other option would be to use .Net framework's SqlBulkCopy class.

The basic template would be something like

private void WriteToDatabase()
{
    // get your connection string
    string connString = "";
    // connect to SQL
    using (SqlConnection connection = 
            new SqlConnection(connString))
    {
        // make sure to enable triggers
        // more on triggers in next post
        SqlBulkCopy bulkCopy = 
            new SqlBulkCopy
            (
            connection, 
            SqlBulkCopyOptions.TableLock | 
            SqlBulkCopyOptions.FireTriggers | 
            SqlBulkCopyOptions.UseInternalTransaction,
            null
            );

        // set the destination table name
        bulkCopy.DestinationTableName = this.tableName;
        connection.Open();

        // write the data in the "dataTable"
        bulkCopy.WriteToServer(dataTable);
        connection.Close();
    }
    // reset
    this.dataTable.Clear();
    this.recordCount = 0;
}

The above code snippet shows you the API usage. But before you actually do that, you need to follow a couple of steps to setup your data table.

First, let's look at a simple record structure (as reflected in C# class):

using System;
using System.Data;
using System.Configuration;

/// <summary>
/// Summary description for MyRecord
/// </summary>
public class MyRecord
{
    public int TestInt;
    public string TestString;

	public MyRecord()
	{
	}

    public MyRecord(int myInt, string myString)
    {
        this.TestInt = myInt;
        this.TestString = myString;
    }
}

Now, let's start dissecting the class that we will use to upload the data:

using System;
using System.Data;
using System.Collections.Generic;

using System.Data.SqlClient;
using System.Configuration;
using System.IO;

namespace SqlExamples.FileLoader
{
/// <summary>
/// Summary description for BulkUploadToSql
/// </summary>
public class BulkUploadToSql
{
    private List<MyRecord> internalStore;

    protected string tableName;
    protected DataTable dataTable = new DataTable();
    protected int recordCount;
    protected int commitBatchSize;

Note that we have an internal List data structure as well as the DataTable. This is redundant and you can avoid using the internalStore if your application does not need to massage the data before it's sent to SQL.

I then define 2 private constructors. The reason is that we want to use the factory pattern to return our object to the caller.

    private BulkUploadToSql(
        string tableName, 
        int commitBatchSize)
    {
        internalStore = new List<MyRecord>();

        this.tableName = tableName;
        this.dataTable = new DataTable(tableName);
        this.recordCount = 0;
        this.commitBatchSize = commitBatchSize;

        // add columns to this data table
        InitializeStructures();
    }

    private BulkUploadToSql() : 
        this("MyTableName", 1000) {}

Note that we set the commit batch size. This is a very important factor that needs to be fine tuned for your database. What this defines is the number of records that we would send in one shot to the database.

The next step is to Initialize the data table with columns that reflect the actual table structure.

private void InitializeStructures()
{
    this.dataTable.Columns.Add("TI", typeof(Int32));
    this.dataTable.Columns.Add("TS", typeof(string));
}

I then provided a factory method to load data into my internal structure from a data source. In the example code below, I use a Stream, but this can be any data source from where you wish to populate your data.

public static BulkUploadToSql Load(Stream dataSource)
{
    // create a new object to return
    BulkUploadToSql o = new BulkUploadToSql();
    
    // replace the code below
    // with your custom logic 
    for (int cnt = 0; cnt < 10000; cnt++)
    {
        MyRecord rec = 
            new MyRecord
            (
            cnt, 
            string.Format("string{0}", cnt)
            );
        o.internalStore.Add(rec);
    }

    return o;
}

This would make sure that our class is properly initialized and loaded with data. Once the caller has a valid object, they can now "Flush" the data as shown below:

public void Flush()
{
    // transfer data to the datatable
    foreach (MyRecord rec in this.internalStore)
    {
        this.PopulateDataTable(rec);
        if (this.recordCount >= this.commitBatchSize)
            this.WriteToDatabase();
    }
    // write remaining records to the DB
    if (this.recordCount > 0)
        this.WriteToDatabase();
}

private void PopulateDataTable(MyRecord record)
{
    DataRow row;
    // populate the values
    // using your custom logic
    row = this.dataTable.NewRow();

    row[0] = record.TestInt;
    row[1] = record.TestString;

    // add it to the base for final addition to the DB
    this.dataTable.Rows.Add(row);
    this.recordCount++;
}

In the example above, the call to Flush() actually massages the data (and at the same time loads it into the actual data table). As I mentioned before, you can actually skip this step if your application does not require massaging.

As a example of an app that uses this class:

using System;
using System.Collections.Generic;
using System.Text;
using SqlExamples.FileLoader;
using System.IO;

namespace DemoApp
{
class Program
{
    static void Main(string[] args)
    {
        using (Stream s = 
            new StreamReader(@"C:\TestData.txt"))
        {
            BulkUploadToSql myData = 
                BulkUploadToSql.Load(s);
            myData.Flush();
        }
    }
}
}

As always, this is JUST demo code to explain a concept. This is NOT production quality code and please make sure to follow the coding guidelines in your team.

Happy coding....

'Brain Trainning > PRG Language' 카테고리의 다른 글

[WEB] Status Code (책펌)  (0) 2012.01.25
[C#] SqlBulkCopy & SqlBulkCopyOptions 사용 방법...  (0) 2012.01.18
[C#] Import Excel to GridView  (0) 2011.12.30
[C#] MVC Tutorials  (0) 2011.11.27
[GeoIP] .NET API 테스트 결과  (0) 2011.06.13
posted by LifeisSimple