-- XML 의 exist 메소드를 활용 사례
--  : XML 문서에서 어떤 속성의 특정값이 존재하는지를 검사
-- (only SQL Server 2005)
DECLARE @v_xml XML
SELECT @v_xml = N'<rows><row id="1" tag="1"/><row id="1" tag="0"/></rows>'

--rows/row/@tag속성의 값이 1인 엘리멘트가 존재하지를 반환
SELECT @v_xml.exist('rows/row[@tag="1"]')   result
---존재함
---result = 1  

SELECT @v_xml.exist('rows/row[@tag="2"]')   result
---존재하지 않음
---result = 0

출처 : 직접 작성.

이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 좐군

2010/02/11 23:16 2010/02/11 23:16
, , , ,
Response
No Trackback , No Comment
RSS :
http://John.tobe30.com/tc/rss/response/297

Trackback URL : http://John.tobe30.com/tc/trackback/297

Leave a comment
[로그인][오픈아이디란?]

This step-by-step article describes how to install a certificate on a computer that is running Microsoft SQL Server 2000 or Microsoft SQL Server 2005 by using Microsoft Management Console (MMC) and describes how to enable SSL Encryption at the server, or for specific clients.

Note You cannot use this method to put a certificate on a SQL Server clustered server.

If your company has implemented an Enterprise Certificate Authority, you can request certificates for a SQL Server stand-alone server, and then use the certificate for Secure Sockets Layer (SSL) encryption.

You can enable the
Force Protocol Encryption option on the server, or on the client.

Note Do not enable the Force Protocol Encryption option on both the client and the server. To enable Force Protocol Encryption on the server, use the Server Network Utility. To enable Force Protocol Encryption on the client, use the Client Network Utility.

Important If you enable SSL encryption by using the Client Network Utility, then all connections from that client will request SSL encryption to any SQL Server to which that client connects.

Warning If you enable Force Protocol Encryption on the client computer, you cannot connect to previous versions of SQL Server from that specific client. Previous versions of SQL Server do not recognize SSL encryption.

If you enable
Force Protocol Encryption on the server, you must install a certificate on the server.

If you want to enable
Force Protocol Encryption on the client, you must have a certificate on the server and the client must have the Trusted Root Authority updated to trust the server certificate.

Note If you are using SQL Server 2005 to enable encrypted connections for an instance of SQL Server 2005, you can set the value of the ForceEncryption option to Yes. For more information, see the "How to: Enable Encryption Connections to the Database Engine (SQL Server Configuration Manager)" topic in SQL Server 2005.

[Install a certificate on a server with Microsoft Management Console (MMC)]

To use SSL encryption, you must install a certificate on the server. Follow these steps to install the certificate by using the Microsoft Management Console (MMC) snap-in.

How to Configure the MMC Snap-in
  1. To open the Certificates snap-in, follow these steps:
    1. To open the MMC console, click Start, and then click Run. In the Run dialog box type:

      MMC
    2. On the Console menu, click Add/Remove Snap-in....
    3. Click Add, and then click Certificates. Click Add again.
    4. You are prompted to open the snap-in for the current user account, the service account, or for the computer account. Select the Computer Account.
    5. Select Local computer, and then click Finish.
    6. Click Close in the Add Standalone Snap-in dialog box.
    7. Click OK in the Add/Remove Snap-in dialog box. Your installed certificates are located in the Certificates folder in the Personal container.
  2. Use the MMC snap-in to install the certificate on the server:
    1. Click to select the Personal folder in the left-hand pane.
    2. Right-click in the right-hand pane, point to All Tasks, and then click Request New Certificate....
    3. The Certificate Request Wizard dialog box opens. Click Next. Select Certificate type is "computer".
    4. In the Friendly Name text box you can type a friendly name for the certificate or leave the text box blank, and then complete the wizard. After the wizard finishes, you will see the certificate in the folder with the fully qualified computer domain name.

    5. If you want to enable encryption for a specific client or clients, skip this step and proceed to the Enable encryption for a specific client section of this article.

      If you want to enable encryption at the server, open the Server Network Utility on the server where the certificate is installed, and then click to select the
      Force protocol encryption check box. Restart the MSSQLServer (SQL Server) service for the encryption to take effect. Your server is now ready to use SSL encryption.

[Enable encryption for a specific client]

For the client to request the SSL encryption, the client computer must trust the server certificate and the certificate must already exist on the server. You have to use the MMC snap-in to export the Trusted Root Certification Authority used by the server certificate:
  1. To export the server certificate's Trusted Root Certificate Authority (CA), follow these steps:
    1. Open MMC, and then locate your certificate in the Personal folder.
    2. Right-click the certificate name, and then click Open.
    3. Review the Certification Path tab. Note the top most item.
    4. Navigate to the Trusted Root Certification Authorities folder, and then locate the Certificate Authority noted in step c..
    5. Right-click CA, point to All Tasks, and then click Export.
    6. Select all the defaults, and then save the exported file to your disk where the client computer can access the file.
  2. Follow these steps to import the certificate on the client computer:
    1. Navigate to the client computer by using the MMC snap-in, and then browse to the Trusted Root Certification Authorities folder.
    2. Right-click the Trusted Root Certification Authorities folder, point to All Tasks, and then click Import.
    3. Browse, and then select the certificate (.cer file) that you generated in step 1. Select the defaults to complete the remaining part of the wizard.
    4. Use the SQL Server Client Network Utility.
    5. Click to select the Force Protocol encryption option. Your client is now ready to use SSL encryption.

[How to test your client connection]

To test your client connection you can either:
  • Use the Query Analyzer Tool.

    -or-

  • Use any ODBC application where you can change the connection string.
Query Analyzer Tool

To use the Query Analyzer Tool, follow these steps:
  1. Use the SQL Server Client Network Utility.
  2. Click to select the Force protocol encryption option.
  3. Connect to the server that is running SQL Server 2000 by using Query Analyzer.
  4. Monitor the communication by using Microsoft Network Monitor or a Network Sniffer.
ODBC or OLEDB Application Sample Connection Strings

If you use ODBC or OLEDB connection strings, follow these steps:
  1. Modify the ODBC or OLEDB connection string. For example:

    ODBC
    Driver=SQLServer;Server=ServerNameHere;UID=UserIdHere;PWD=PasswordHere;Network=DBNETLIB.DLL;Encrypt=YES
    OLEDB
    Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=dbNameHere;Data Source=ServerNameHere;Use Encryption for Data=True
  2. Connect to the server that is running SQL Server 2000, and then monitor the communication by using Microsoft Network Monitor or a Network Sniffer.

[Troubleshooting]

After you successfully install the certificate, the certificate does not appear in the Certificate list on the Certificate tab.

Note The Certificate tab is in the Protocols for <InstanceName> Properties dialog box that is opened from SQL Server Configuration Manager.

This issue occurs because you may have installed an invalid certificate. If the certificate is invalid, it will not be listed on the
Certificate tab. To determine whether the certificate that you installed is valid, follow these steps:
  1. Open the Certificates snap-in. To do this, see step 1 in the "How to Configure the MMC Snap-in" section.
  2. In the Certificates snap-in, expand Personal, and then expand Certificates.
  3. In the right pane, locate the certificate that you installed.
  4. Determine whether the certificate meets the following requirements:
    • In the right pane, the value in the Intended Purpose column for this certificate must be Server Authentication.
    • In the right pane, the value in the Issued To column must be the server name.
  5. Double-click the certificate, and then determine whether the certificate meets the following requirements:
    • On the General tab, you receive the following message:
      You have a private key that corresponds to this certificate.
    • On the Details tab, the value for the Subject field must be server name.
    • The value for the Enhanced Key Usage field must be Server Authentication (<number>).
    • On the Certification Path tab, the server name must appear under Certification path.
If any one of these requirements is not met, the certificate is invalid.
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 좐군

2009/11/28 23:50 2009/11/28 23:50
,
Response
No Trackback , No Comment
RSS :
http://John.tobe30.com/tc/rss/response/241

Trackback URL : http://John.tobe30.com/tc/trackback/241

Leave a comment
[로그인][오픈아이디란?]

[펌]SQL Server 2005 connectivity error messages

One of the more visible changes we made in connectivity space for SQL Server 2005 was enhancing error messages reported to the user in case of connection failures.  I have seen several cases over the last several months, and in this post I would like to list some of them with the root cause that caused them.  The cause may not be the only one triggering a particular error message, and there may be other error messages of interest. 

This is a semi-random selection from real cases I investigated.  Likely I will post another batch some time in the future, and I would be happy to see replies with additional errors, particularly if the root cause is unclear. 

The examples are from various client stacks – ODBC or OLEDB from SQL Native Client or from managed SqlClient. 

The exact formatting of the messages will depend on the application you use.  Most of the examples below used OSQL, SQLCMD, or SQL Server Management Studio. 

  • Connecting to a server by the server’s name from SqlClient, the server name is aliased to TCP, the server is up and running but it does not listen on TCP (or is not running at all):

An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.) (Microsoft SQL Server, Error: 10061)

  • Local connection from SqlClient; server is not running:

(a) default instance:

An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 2)

(b) named instance:

An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Shared Memory Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 2)

  • Remote connection from ODBC, Windows Firewall is turned on on the server machine but there is an exception for File and Printer Sharing:

 [SQL Native Client]Unable to complete login process due to delay in opening server connection

  • A successful TCP connection from SqlClient to the server was broken due to a TCP keep-alive heartbeat failure (typically indicating problems with the underlying network infrastructure):

A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The specified network name is no longer available.)

Possibly:

A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)

  • OBDC connection attempt when server is not ready to process a new local connection, possibly due to overload: 

[SQL Native Client]Shared Memory Provider: Timeout error [258].
[SQL Native Client]Login timeout expired
[SQL Native Client]Unable to complete login process due to delay in prelogin response

[SQL Native Client]Shared Memory Provider: Could not open a connection to SQL Server [121].
[SQL Native Client]Login timeout expired
[SQL Native Client]An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.

  • There is a space after server name in the connection string:

osql -E -S "<serverName> ,1433"
Login failed for user ''. The user is not associated with a trusted SQL Server connection.

The server ERRORLOG/EventLog shows something similar to:

2005-08-11 12:46:04.29 Logon       Error: 17806, Severity: 20, State: 2.
2005-08-11 12:46:04.29 Logon       SSPI handshake failed with error code 0x8009030c while establishing a connection with integrated security; the connection has been closed. [CLIENT: <IP address>]
2005-08-11 12:46:04.29 Logon       Error: 18452, Severity: 14, State: 1.
2005-08-11 12:46:04.29 Logon       Login failed for user ''. The user is not associated with a trusted SQL Server connection. [CLIENT: <IP address>]

  • Remote OLEDB connection using TCP to a server that is blocked by Firewall

HResult 0x274C, Level 16, State 1
TCP Provider: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Error: Microsoft SQL Native Client : An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections..
Error: Microsoft SQL Native Client : Login timeout expired.

  • Remote OLEDB connection using TCP to a server that is either not running or does not have TCP/IP protocol enabled for incoming connections (but is not blocked by the Firewall on the server machine):

HResult 0x274D, Level 16, State 1
TCP Provider: No connection could be made because the target machine actively refused it.

Error: Microsoft SQL Native Client : An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections..
Error: Microsoft SQL Native Client : Login timeout expired.

출처 : http://blogs.msdn.com/sql_protocols/archive/2005/09/28/474698.aspx


이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 좐군

2009/11/28 23:19 2009/11/28 23:19
,
Response
No Trackback , No Comment
RSS :
http://John.tobe30.com/tc/rss/response/240

Trackback URL : http://John.tobe30.com/tc/trackback/240

Leave a comment
[로그인][오픈아이디란?]

SSMS 에 Add-in인 SSMS Tool Pack을 소개하려 한다.  SSMS2005 버전과 SSMS2008 버전이 별도로 존재하므로 알맞은 버전을 설치해야 한다.
다운로드 : http://www.ssmstoolspack.com/Download.aspx
SSMS Tool Pack 은 다음과 기능을 제공한다.
( 필자의 경우 테이블에 데이터를 INSERT-SQL로 생성해주는 기능을 아주 유용하게 사용하고 있다.)


Features
Source : http://www.ssmstoolspack.com/Features.aspx
With windows connection color indicator you always know to which server you're connected to. The color strip can be docked to any side of the window and it's color can be easily changed from either it's context menu or from server coloring options.
Coloring for each server can be added, removed or just disabled.
Window Connection Coloring Thumbnail



Query Execution History (Soft Source Control) and Current Window History
Every SQL statement that you run is logged in a file on your disk or in a table in a database you specify with a connection string. This way, if you're working on some script you can get the full history of every change you've made between check-out and check-in of your file.
SQL Statements are saved in a list that is written to a file and/or a database with a timer which you can set to a desired interval.

Older query history logs can be auto deleted. Time after the logs are deleted is user settable.
Query Execution History Thumbnail
Current window history is a dockable window that show queries executed in a currently active window. There is also a search box at the top that filters results as you type. Current History Window Thumbnail




Search Table or Database Data
Simple search for a search term through all non-binary columns in a single table or in every table of a database. You can search in four ways: Contains, Starts with, Ends with and Equals.
Search Table or Database Thumbnail


Uppercase/Lowercase keywords and proper case Database Object Names
Set all keywords to uppercase or lowercase letters. Custom keywords can be added.
Format all database objects to their proper case sensitive name.
Format text Thumbnail


Run one script on multiple databases
Run selected or full window text on selected databases on the currently connected server. A new window is opened that contains one script for all databases. Run one script on multiple databases Thumbnail


Copy execution plan bitmaps to clipboard
Copy selected or all execution plans to a bitmap that is saved on the clipboard. Large execution plans that don't fit in the window are also copied in full.
Width of a picture containing all execution plans is equal to the width of the widest execution plan.
Copy execution plan bitmaps to clipboard Thumbnail


Search Results in Grid Mode and Execution Plans
Find all occurrences of your search string in the execution plans or in the results in datagrid mode.
Search results and execution plans Thumbnail


Generate Insert statements for a single table, the whole database or current resultsets in grids
Insert statements for the whole database are generated by the order of PK-FK relationships. Top tables with no FK's are scripted first. Binary data is by default fully scripted. If you wish you can also set the scripting data limit between 0 and 10 Mb. Larger values then the limit are then scripted as NULL.

Insert statements for the data in result grids are scripted into a new temporary table for each grid. For example from 5 result grids insert statements for 5 temporary tables get created.
Generate insert statements Thumbnail


Text document Regions and Debug sections
Regions behave in the same way as in Visual Studio. You can collapse them and expand them. Debug sections are sections that get commented or deleted when you change your script to Release configuration. A debug section is also a collapsable region. If you deploy a script in debug mode with added debug sections it will fail when run from SSMS without SSMS Tools Pack installed. You can of course comment those sections yourself by simply searching for start and end text of the debug sections. Regions and Debug section Thumbnail


Running custom scripts from Object explorer's Context menu
You can specify a custom script text, its name and node on Object Explorer on which you want to run it from. Node name, current database, current connection string and current server can also be specified in the custom script with keywords that are replaced with their respective values at script runtime. Run custom script Thumbnail


CRUD (Create, Read, Update, Delete) stored procedure generation
CRUD stored procedure generation for tables based on fully customizable templates that you can change to suit your needs. CRUD Thumbnail


New query template
When opening a new query window you can specify a template that will be displayed. New query Template Thumbnail

이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 좐군

2009/10/20 00:21 2009/10/20 00:21
, ,
Response
No Trackback , No Comment
RSS :
http://John.tobe30.com/tc/rss/response/222

Trackback URL : http://John.tobe30.com/tc/trackback/222

Leave a comment
[로그인][오픈아이디란?]
DECLARE @old_datefirst INT
SELECT @old_datefirst = @@DATEFIRST

DECLARE @v_dayname_monday INT
SELECT @v_dayname_monday = 1
SET DATEFIRST @v_dayname_monday

DECLARE @v_date DATETIME
SELECT @v_date = '2009-08-01'    ---특정 날짜 지정.

SELECT @v_date date
, DATEPART(year, @v_date) [Year]
, DATEPART(week, @v_date) [Week of Year]
, DATEPART(dayofyear, @v_date) [Day of Year]
, CASE
WHEN DATEPART(weekday, @v_date) > 1 THEN DATEADD(day, (DATEPART(weekday, @v_date)-1) * -1 , @v_date)
ELSE @v_date END [First-day of Week]
, CASE
WHEN DATEPART(weekday, @v_date) < 7 THEN DATEADD(day, 7-DATEPART(weekday, @v_date), @v_date)
ELSE @v_date END [Last-day of Week]

SET DATEFIRST @old_datefirst

/*
실행결과
date                 Year Week of Year Day of Year First-day of Week   Last-day of Week
2009-08-01 2009 31                         213                 2009-07-27            2009-08-02
*/
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 좐군

2009/08/20 22:00 2009/08/20 22:00
, ,
Response
No Trackback , No Comment
RSS :
http://John.tobe30.com/tc/rss/response/189

Trackback URL : http://John.tobe30.com/tc/trackback/189

Leave a comment
[로그인][오픈아이디란?]

DECLARE @v_xml XML
, @v varchar(max)
SELECT @v_xml = '<row id=""/>'
, @v = 'xxxxx'
SET @v_xml.modify(' replace value of (/row/@id)[1] with sql:variable("@v") ');
SELECT @v_xml ;

--반환값
<row id="xxxxx" />

이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 좐군

2009/08/11 19:33 2009/08/11 19:33
,
Response
4 Trackbacks , No Comment
RSS :
http://John.tobe30.com/tc/rss/response/188

Trackback URL : http://John.tobe30.com/tc/trackback/188

Trackbacks List

  1. Vicodin.

    Tracked from Buy vicodin. 2010/06/25 01:49 Delete

    Vicodin. Buy vicodin online. How l ong does vicodin stay in your system.

  2. Purchase vicodin online.

    Tracked from Vicodin. 2010/07/15 01:58 Delete

    Buy vicodin online. Vicodin erowid. Vicodin. Vicodin overdose.

  3. How long is percocet in your system.

    Tracked from Percocet. 2010/07/15 06:16 Delete

    Percocet vs. lortabs. Percocet withdrawal symptoms.

  4. Heroin mixed with alprazolam.

    Tracked from Alprazolam. 2010/07/15 11:56 Delete

    Alprazolam synthesis. Alprazolam.

Leave a comment
[로그인][오픈아이디란?]

[SQL Server]SQL Server 2005 XML ASCII 문자(1~31) 사용시 오류 문제.


1. 오류 재현 코드

DECLARE @v_xml XML DECLARE @v_looper INT SELECT @v_looper = 1 WHILE (@v_looper<31) BEGIN SELECT @v_looper = @v_looper + 1 BEGIN TRY   SELECT @v_Xml = N'<rows>

<row attr="' + CHAR(@v_looper) + '" />

</rows>' PRINT 'Success! ASCII Code:' + CAST(@v_looper AS VARCHAR(10)) END TRY BEGIN CATCH PRINT 'Failure! ASCII Code:' + CAST(@v_looper AS VARCHAR(10)) --PRINT ERROR_NUMBER() --PRINT ERROR_MESSAGE() END CATCH END


실행결과

Error! ASCII Code:2

Error! ASCII Code:3 Error! ASCII Code:4 Error! ASCII Code:5 Error! ASCII Code:6 Error! ASCII Code:7 Error! ASCII Code:8 Success! ASCII Code:9 Success! ASCII Code:10 Error! ASCII Code:11 Error! ASCII Code:12 Success! ASCII Code:13 Error! ASCII Code:14 Error! ASCII Code:15 Error! ASCII Code:16 Error! ASCII Code:17 Error! ASCII Code:18 Error! ASCII Code:19 Error! ASCII Code:20 Error! ASCII Code:21 Error! ASCII Code:22 Error! ASCII Code:23 Error! ASCII Code:24 Error! ASCII Code:25 Error! ASCII Code:26 Error! ASCII Code:27 Error! ASCII Code:28 Error! ASCII Code:29 Error! ASCII Code:30 Error! ASCII Code:31

위 실행결과에서 확인할 수 있듯이 ASCII코드 1에서 31사이에 사용 가능한 Character는

9  (TAB : horizontal tab, XML #x9)
10 (LF : line feed, new line, XML #xA)
13 (CR : carriage  return, XML #xD)

이렇게 세가지 뿐이고, 나머지 Character는 다음과 모두 에러를 발생한다.

메시지 9420, 수준 16, 상태 1, 줄 9
XML parsing: line 1, character 18, illegal xml character
이 같은 문제에 대해 MS에서는 해당 문자들은 XML 스펙에서 사용을 금지하고 있으므로 사용하지 말라고 이야기 하고 있다.

PRB: Error Message When an XML Document Contains Low-Order ASCII Characters

원문 : http://support.microsoft.com/kb/315580

SYMPTOMS (증상)

When you attempt to use versions 3.0 or later of the MSXML parser to parse XML documents that contain certain low-order non-printable ASCII characters (that is, characters below ASCII 32), you may receive the following error message:
An Invalid character was found in text content.


CAUSE

Versions 3.0 and later of the MSXML parser strictly enforce the valid XML character ranges that are defined by the World Wide Web Consortium (W3C) XML language specification. XML documents that are parsed using versions 3.0 or later of MSXML cannot contain characters that fall outside the defined valid XML character ranges. The low-order non-printable ASCII characters in the ranges that are listed in the "More Information" section are not valid XML characters. An XML document that contains instances of these characters is not conformant with the W3C specifications and cannot be parsed successfully with versions 3.0 and later of MSXML.


RESOLUTION
To resolve this problem, either remove instances of the low-order non-printable ASCII characters, or replace the characters with an alternate valid character such as the space character (ASCII 32, hex #x20). This solution makes the XML document compliant with the W3C specifications. However, removing or replacing instances of these characters may affect other applications that use the data and to which the characters are significant. Such additional impact can only be identified by testing and will need to be addressed by implementing a fix or workaround that is appropriate for a specific situation.

STATUS
This behavior is by design.


MORE INFOMATION
Versions 2.6 and earlier of the MSXML parser permit XML documents to contain low-order non-printable ASCII characters that fall outside the W3C valid XML character ranges. However, the design of versions 3.0 and later of the MSXML parser has been changed to strictly enforce the valid XML character ranges that are defined in the W3C XML language specification. This design change is required to be able to identify non-conformant XML documents.
The following are the valid XML characters and character ranges (hex values) as defined by the W3C XML language specifications 1.0:
#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
The following are the character ranges for low-order non-printable ASCII characters that are rejected by MSXML versions 3.0 and later:
#x0 - #x8 (ASCII 0 - 8)
#xB - #xC (ASCII 11 - 12)
#xE - #x1F (ASCII 14 - 31)
This design change may affect the following users and applications:
  • Internet Explorer users: Users who have been using Internet Explorer versions 5.5 and earlier (and who did not install MSXML 3.0 in Replace mode) to browse and view XML documents that contain one or more instances of the specified low-order non-printable ASCII characters encounter the error message after upgrading to Internet Explorer 6.0 because Internet Explorer 6.0 installs MSXML 3.0 SP2 in Replace mode and uses it to parse XML documents.
  • MDAC and ADO users: Developers and users who load ADO-persisted XML documents that contain one or more instances of the specified low-order non-printable ASCII characters into ADO Recordset objects encounter the error message after upgrading to MDAC 2.7 because MDAC 2.7 installs MSXML 3.0 SP2, which is the version of the MSXML parser that the ADO 2.7 Recordset object uses.
  • Applications that use the MSXML Document Object Model (DOM): Applications that use version independent PROGIDs to instantiate MSXML DOM objects that are used to parse XML documents generate the specified error when MSXML 3.0 or one of its service packs is installed in Replace mode or when the code is modified to use the MSXML 3.0 or 4.0 version specific PROGIDs.


REFERENCES

For additional information on other known causes and workarounds for the error message that is specified in the 'Symptoms' section, click the article numbers below to view the articles in the Microsoft Knowledge Base:
238833  (http://support.microsoft.com/kb/238833/EN-US/ ) PRB: XML Parser: Invalid Character Was Found in Text Content
275883  (http://support.microsoft.com/kb/275883/EN-US/ ) INFO: XML Encoding and DOM Interface Methods

APPLIES TO
  • Microsoft XML Parser 3.0
  • Microsoft XML Parser 3.0 Service Pack 1
  • Microsoft XML Parser 3.0 Service Pack 2
  • Microsoft XML Core Services 4.0
  • Microsoft Data Access Components 2.8


이에 대해서 W3C의 Extensible Markup Language (XML) 1.0 (Fifth Edition) 에서 다음과 같이 정의하고 있다. ("2.2.Characters"에 대한 내용만 일부 복사.)

Extensible Markup Language (XML) 1.0 (Fifth Edition)
W3C Recommendation 26 November 2008
2.2. Characters
[Definition: A parsed entity contains text, a sequence of characters, which may represent markup or character data.] [Definition: A character is an atomic unit of text as specified by ISO/IEC 10646:2000 [ISO/IEC 10646]. Legal characters are tab, carriage return, line feed, and the legal characters of Unicode and ISO/IEC 10646. The versions of these standards cited in A.1 Normative References were current at the time this document was prepared. New characters may be added to these standards by amendments or new editions. Consequently, XML processors MUST accept any character in the range specified for Char. ]

Character Range
[2]    Char    ::=    #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
/* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. */

The mechanism for encoding character code points into bit patterns may vary from entity to entity. All XML processors MUST accept the UTF-8 and UTF-16 encodings of Unicode [Unicode]; the mechanisms for signaling which of the two is in use, or for bringing other encodings into play, are discussed later, in 4.3.3 Character Encoding in Entities.

Note:
Document authors are encouraged to avoid "compatibility characters", as defined in section 2.3 of [Unicode]. The characters defined in the following ranges are also discouraged. They are either control characters or permanently undefined Unicode characters:
[#x7F-#x84], [#x86-#x9F], [#xFDD0-#xFDEF],
[#x1FFFE-#x1FFFF], [#x2FFFE-#x2FFFF], [#x3FFFE-#x3FFFF],
[#x4FFFE-#x4FFFF], [#x5FFFE-#x5FFFF], [#x6FFFE-#x6FFFF],
[#x7FFFE-#x7FFFF], [#x8FFFE-#x8FFFF], [#x9FFFE-#x9FFFF],
[#xAFFFE-#xAFFFF], [#xBFFFE-#xBFFFF], [#xCFFFE-#xCFFFF],
[#xDFFFE-#xDFFFF], [#xEFFFE-#xEFFFF], [#xFFFFE-#xFFFFF],
[#x10FFFE-#x10FFFF].

나의 결론 : 지금까지 이런 문제에 대해 전혀 모르고 있었다. XML를 사용하면서 W3C의 XML 스펙 문서를 자세히 읽어 본 적도 없고,  XML관련 서적을 봤을 때 W3C의 XML 스펙에 대해 이야기하는 책도 접해보지 못했다. 새로운 기술을 사용할 때는 기본에 충실하고,  해당 표준 스펙에 대해 충분히 숙지 해야할 것이다. 그리고 또 다른 한가지는 모든 스펙문서가 영문으로 된 경우 많으므로 영어능력을 키우는 것도 중요하겠다. 여기서 다시 한번 모든 학문의 기초는 영어라는 이야기를 되새기면서... 이 씁쓸함은 머지?





이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 좐군

2009/06/07 00:47 2009/06/07 00:47

Trackback URL : http://John.tobe30.com/tc/trackback/165

Leave a comment
[로그인][오픈아이디란?]

[SQL Server]sp_reset_connection이 무엇을 하는가?

What does sp_reset_connection do?

Data access API's layers like ODBC, OLE-DB and SqlClient call the (internal) stored procedure sp_reset_connection when re-using a connection from a connection pool. It does this to reset the state of the connection before it gets re-used, however nowhere is documented what things get reset. This article tries to document the parts of the connection that get reset.

sp_reset_connection resets the following aspects of a connection:

  • It resets all error states and numbers (like @@error)
  • It stops all EC's (execution contexts) that are child threads of a parent EC executing a parallel query
  • It will wait for any outstanding I/O operations that is outstanding
  • It will free any held buffers on the server by the connection
  • It will unlock any buffer resources that are used by the connection
  • It will release all memory allocated owned by the connection
  • It will clear any work or temporary tables that are created by the connection
  • It will kill all global cursors owned by the connection
  • It will close any open SQL-XML handles that are open
  • It will delete any open SQL-XML related work tables
  • It will close all system tables
  • It will close all user tables
  • It will drop all temporary objects
  • It will abort open transactions
  • It will defect from a distributed transaction when enlisted
  • It will decrement the reference count for users in current database; which release shared database lock
  • It will free acquired locks
  • It will releases any handles that may have been acquired
  • It will reset all SET options to the default values
  • It will reset the @@rowcount value
  • It will reset the @@identity value
  • It will reset any session level trace options using dbcc traceon()

sp_reset_connection will NOT reset:
  • Security context, which is why connection pooling matches connections based on the exact connection string.
  • If you entered an application role using sp_setapprole, since application roles can not be reverted.

To learn more about connection pooling see Pooling in the Microsoft Data Access Components.


            
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 좐군

2009/05/12 12:59 2009/05/12 12:59
, , ,
Response
No Trackback , No Comment
RSS :
http://John.tobe30.com/tc/rss/response/139

Trackback URL : http://John.tobe30.com/tc/trackback/139

Leave a comment
[로그인][오픈아이디란?]

[SQL Server] DB Backup 백업 현황 점검

SQL Server에서 DB Backup 백업 현황 점검하는 SQL.

msdb에 backupset 시스템 테이블을 조회하면 백업현황을 조회해볼 수 있다.
msdb.dbo.backupset 테이블의 내용
열 이름 데이터 형식 설명
backup_set_id int 백업 세트를 식별하는 고유한 백업 세트 ID입니다. ID, 기본 키
backup_set_uuid uniqueidentifier 백업 세트를 식별하는 고유한 백업 세트 ID입니다.
media_set_id int 백업 세트를 포함한 미디어 세트를 식별하는 고유한 미디어 세트 ID입니다. backupmediaset(media_set_id)를 참조합니다.
first_family_number tinyint 백업 세트가 시작되는 미디어의 패밀리 번호입니다. NULL일 수 있습니다.
first_media_number smallint 백업 세트가 시작되는 미디어의 미디어 번호입니다. NULL일 수 있습니다.
last_family_number tinyint 백업 세트가 끝나는 미디어의 패밀리 번호입니다. NULL일 수 있습니다.
last_media_number smallint 백업 세트가 끝나는 미디어의 미디어 번호입니다. NULL일 수 있습니다.
catalog_family_?number tinyint 백업 세트 디렉터리의 시작을 포함한 미디어의 패밀리 번호입니다. NULL일 수 있습니다.
catalog_media_number smallint 백업 세트 디렉터리의 시작을 포함한 미디어의 미디어 번호입니다. NULL일 수 있습니다.
position int 적절한 백업 세트 및 파일의 위치를 찾기 위해 복원 작업에 사용되는 백업 세트 위치입니다. NULL일 수 있습니다. 자세한 내용은 BACKUP(Transact-SQL)에서 FILE을 참조하십시오.
expiration_date datetime 백업 세트가 만료되는 날짜 및 시간입니다. NULL일 수 있습니다.
software_vendor_id int 백업 미디어 헤더를 기록하는 소프트웨어 공급업체의 ID입니다. NULL일 수 있습니다.
name nvarchar(128) 백업 세트의 이름입니다. NULL일 수 있습니다.
description nvarchar(255) 백업 세트에 관한 설명입니다. NULL일 수 있습니다.
user_name nvarchar(128) 백업 작업을 수행하는 사용자의 이름입니다. NULL일 수 있습니다.
software_major_version tinyint Microsoft SQL Server 주 버전 번호입니다. NULL일 수 있습니다.
software_minor_version tinyint SQL Server 부 버전 번호입니다. NULL일 수 있습니다.
software_build_version smallint SQL Server 빌드 번호입니다. NULL일 수 있습니다.
time_zone smallint 15분 간격으로 백업 작업이 수행되는 현지 시간과 UCT 간의 차이입니다. 값은 -48에서 +48까지 사용할 수 있으며 각 값을 포함합니다. 값 127은 알 수 없음을 의미합니다. 예를 들어 -20은 EST(동부 표준시) 또는 UTC 이후 5시간을 의미합니다. NULL일 수 있습니다.
mtf_minor_version tinyint Microsoft Tape Format의 부 버전 번호입니다. NULL일 수 있습니다.
first_lsn numeric(25,0) 백업 세트에서 첫 번째 또는 가장 오래된 로그 레코드의 로그 시퀀스 번호입니다. NULL일 수 있습니다.
last_lsn numeric(25,0) 백업 세트 다음에 오는 로그 레코드의 로그 시퀀스 번호입니다. NULL일 수 있습니다.
checkpoint_lsn numeric(25,0) 다시 실행이 시작되어야 하는 로그 레코드의 로그 시퀀스 번호입니다. NULL일 수 있습니다.
database_backup_lsn numeric(25,0) 가장 최근 전체 데이터베이스 백업의 로그 시퀀스 번호입니다. NULL일 수 있습니다. database_backup_lsn은 백업이 시작될 때 트리거되는 "검사점의 시작"입니다. 데이터베이스가 유휴 상태이고 복제가 구성되지 않은 경우 백업이 수행되면 이 LSN은 first_lsn과 일치하게 됩니다.
database_creation_date datetime 데이터베이스가 원래 생성된 날짜와 시간입니다. NULL일 수 있습니다.
backup_start_date datetime 백업 작업이 시작된 날짜와 시간입니다. NULL일 수 있습니다.
backup_finish_date datetime 백업 작업이 완료된 날짜와 시간입니다. NULL일 수 있습니다.
type char(1) 백업 유형입니다. 다음 값이 될 수 있습니다.
D = 데이터베이스 I = 차등 데이터베이스 L = 로그 F = 파일 또는 파일 그룹 G =차등 파일 P = 부분 Q = 차등 부분 NULL일 수 있습니다.
sort_order smallint 백업 작업을 수행하는 서버의 정렬 순서입니다. NULL일 수 있습니다. 정렬 순서 및 데이터 정렬에 대한 자세한 내용은 데이터 정렬 작업을 참조하십시오.
code_page smallint 백업 작업을 수행하는 서버의 코드 페이지입니다. NULL일 수 있습니다. 코드 페이지에 대한 자세한 내용은 데이터 정렬 작업을 참조하십시오.
compatibility_level tinyint 데이터베이스에 대한 호환성 수준 설정입니다. 다음 값이 될 수 있습니다.
60 = SQL Server 6.0 65 = SQL Server 6.5 70 = SQL Server 7.0 80 = SQL Server 2000 90 = SQL Server 2005
NULL일 수 있습니다. 호환성 수준에 대한 자세한 내용은 sp_dbcmptlevel(Transact-SQL)을 참조하십시오.
database_version int 데이터베이스 버전 번호입니다. NULL일 수 있습니다.
backup_size numeric(20,0) 백업 세트의 크기(바이트)입니다. NULL일 수 있습니다.
database_name nvarchar(128) 백업 작업과 연관된 데이터베이스의 이름입니다. NULL일 수 있습니다.
server_name nvarchar(128) SQL Server 백업 작업을 실행하고 있는 서버의 이름입니다. NULL일 수 있습니다.
machine_name nvarchar(128) SQL Server를 실행 중인 컴퓨터의 이름입니다. NULL일 수 있습니다.
flags int Microsoft SQL Server 2005에서는 flags 열이 사용되지 않고 대신 다음과 같은 bit 열이 사용됩니다.
  • has_bulk_logged_data
  • is_snapshot
  • is_readonly
  • is_single_user
  • has_backup_checksums
  • is_damaged
  • begins_log_chain
  • has_incomplete_metadata
  • is_force_offline
  • is_copy_only
NULL일 수 있습니다.SQL Server 이전 버전의 백업 세트에서 플래그 비트는 다음과 같습니다. 1 = 백업이 최소 기록 데이터를 포함합니다. 2 = WITH SNAPSHOT이 사용되었습니다. 4 = 백업 시 데이터베이스가 읽기 전용이었습니다. 8 = 백업 시 데이터베이스가 단일 사용자 모드였습니다.
unicode_locale int 유니코드 로캘입니다. NULL일 수 있습니다.
unicode_compare_style int 유니코드 비교 스타일입니다. NULL일 수 있습니다.
collation_name nvarchar(128) 데이터 정렬 이름입니다. NULL일 수 있습니다.
Is_password_protected bit 백업 세트입니다. 다음과 같이 암호로 보호됩니다.
0 = 보호되지 않음
1 = 보호됨
recovery_model nvarchar(60) 데이터베이스의 복구 모델입니다. FULL BULK-LOGGED SIMPLE
has_bulk_logged_data bit 1 = 백업이 대량 로그 데이터를 포함합니다.
is_snapshot bit 1 = SNAPSHOT 옵션을 사용하여 백업이 수행되었습니다.
is_readonly bit 1 = 백업 시 데이터베이스가 읽기 전용이었습니다.
is_single_user bit 1 = 백업 시 데이터베이스가 단일 사용자 모드였습니다.
has_backup_checksums bit 1 = 백업이 백업 체크섬을 포함합니다.
is_damaged bit 1 = 이 백업이 생성될 때 데이터베이스 손상이 감지되었습니다. 오류와 관계없이 백업 작업을 계속하도록 요청했습니다.
begins_log_chain bit 1 = 연속되는 로그 백업 체인에서 첫 번째입니다. 로그 체인은 데이터베이스가 생성된 후 또는 단순 복구 모델에서 전체 또는 대량 로그 복구 모델로 전환될 때 수행된 첫 번째 로그 백업에서 시작됩니다.
has_incomplete_metadata bit 1 = 메타데이터가 완전하지 않은 비상 로그 백업입니다. 자세한 내용은 비상 로그 백업을 참조하십시오.
is_force_offline bit 1 = 백업이 수행될 때 NORECOVERY 옵션을 사용하여 데이터베이스가 오프라인 상태가 되었습니다.
is_copy_only bit 1 = 복사 전용 백업입니다. 자세한 내용은 복사 전용 백업을 참조하십시오.
first_recovery_fork_guid uniqueidentifier 복구 분기 시작 지점의 ID입니다. RESTORE HEADERONLY의 FirstRecoveryForkID에 해당됩니다. 데이터 백업의 경우 first_recovery_fork_guid는 last_recovery_fork_guid와 같습니다.
last_recovery_fork_guid uniqueidentifier 복구 분기 끝 지점의 ID입니다. RESTORE HEADERONLY의 RecoveryForkID에 해당됩니다. 데이터 백업의 경우 first_recovery_fork_guid는 last_recovery_fork_guid와 같습니다.
fork_point_lsn numeric(25,0) first_recovery_fork_guid가 last_recovery_fork_guid와 같지 않으면 분기 지점의 로그 시퀀스 번호입니다. 그렇지 않으면 값은 NULL입니다.
database_guid uniqueidentifier 데이터베이스에 대한 고유 ID입니다. RESTORE HEADERONLY의 BindingID에 해당됩니다. 데이터베이스를 복원하면 새 값이 할당됩니다.
family_guid uniqueidentifier 생성 시 원래 데이터베이스의 고유 ID입니다. 이 값은 데이터베이스가 다른 이름으로 복원되는 경우에도 동일하게 유지됩니다.
differential_base_lsn numeric(25,0) 차등 백업에 대한 기본 LSN입니다. 단일 백업을 기반으로 하는 차등 백업의 경우 differential_base_lsn보다 크거나 같도록 LSN을 변경하면 차등 백업에 포함됩니다. 여러 백업을 기반으로 하는 차등 백업의 경우 값은 NULL이며 기본 LSN은 파일 수준에서 결정해야 합니다. backupfile(Transact-SQL)을 참조하십시오. 비차등 백업 유형의 경우 값은 항상 NULL입니다.
differential_base_guid uniqueidentifier 단일 백업을 기준으로 하는 차등 백업의 경우 값은 차등 기반의 고유 식별자입니다. 여러 백업을 기반으로 하는 차등 백업의 경우 값은 NULL이며 기본 차등 백업은 파일 수준에서 결정해야 합니다. 비차등 백업 유형의 경우 값은 NULL입니다.


/******************************************************************************
 Name   : Retrieve backup-status
 Author  : CHOI JI WHAN
 Date  : 2009.05.09(SUN)
 Description
User : Backup 명령어를 실행한 사용자
Database : 데이터베이스 명 
Server : 서버명(인스턴스명)
Backup Started : 백업시작시간
Backup Finished : 백업종료시간
Total Time : 백업소요시간
*******************************************************************************/
DECLARE @dbname sysname
SET @dbname = NULL
SELECT bup.user_name AS [User]
, bup.database_name AS [Database]
, bup.server_name AS [Server]
, bup.backup_start_date AS [Backup Started]
, bup.backup_finish_date AS [Backup Finished]
, CAST((CAST(DATEDIFF(s, bup.backup_start_date, bup.backup_finish_date) AS int))/3600 AS varchar) + ' hours, ' 
 + CAST((CAST(DATEDIFF(s, bup.backup_start_date, bup.backup_finish_date) AS int))/60 AS varchar)+ ' minutes, '
 + CAST((CAST(DATEDIFF(s, bup.backup_start_date, bup.backup_finish_date) AS int))%60 AS varchar)+ ' seconds'
AS [Total Time]
FROM msdb.dbo.backupset bup
WHERE bup.backup_set_id IN
(
SELECT MAX(backup_set_id) 
FROM msdb.dbo.backupset
--if no dbname, then return all
WHERE database_name = ISNULL(@dbname, database_name) 
--only interested in the time of last full backup
AND type = 'D' 
GROUP BY database_name
AND bup.database_name IN (SELECT name FROM master.dbo.sysdatabases)
ORDER BY bup.database_name




/******************************************************************************
 Name : Retrieve backup-history
 Author : CHOI JI WHAN
 Date : 2009.05.09(SUN)
*******************************************************************************/
DECLARE @dbname sysname
SET @dbname = NULL 
SELECT bup.user_name AS [User]
, bup.database_name AS [Database]
, bup.server_name AS [Server]
, bup.backup_start_date AS [Backup Started]
, bup.backup_finish_date AS [Backup Finished]
, CAST((CAST(DATEDIFF(s, bup.backup_start_date, bup.backup_finish_date) AS int))/3600 AS varchar) + ' hours, ' 
 + CAST((CAST(DATEDIFF(s, bup.backup_start_date, bup.backup_finish_date) AS int))/60 AS varchar)+ ' minutes, '
 + CAST((CAST(DATEDIFF(s, bup.backup_start_date, bup.backup_finish_date) AS int))%60 AS varchar)+ ' seconds'
 AS [Total Time]
FROM msdb.dbo.backupset bup
WHERE bup.database_name IN (SELECT name FROM master.dbo.sysdatabases)
ORDER BY bup.database_name



참조 : SQL Server 2005 도움말
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.ko/tsqlref9/html/6ff79bbf-4acf-4f75-926f-38637ca8a943.htm
이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 좐군

2009/05/10 14:01 2009/05/10 14:01
, , , ,
Response
No Trackback , No Comment
RSS :
http://John.tobe30.com/tc/rss/response/137

Trackback URL : http://John.tobe30.com/tc/trackback/137

Leave a comment
[로그인][오픈아이디란?]

[SQL Server] XML의 특정값 수정하기

SQL Server 2005에서 XML 타입의 modify()메소를 이용하여 XML의 특정값을 수정하는 예제이다.  
XML DML에서 replace value of xpath with value 구문을 이용하는 것이다.

DECLARE @xml XML
SELECT  @xml = N'<root>
                  <elements>
                     <event id="1"/>
                  </elements>
                 </root>'
SET @xml.modify('
replace value of (/root/elements/event/@id)[1]
with "999"
')
SELECT @xml --Result --@xml='<root><elements><event id="999" /></elements></root>'


이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 좐군

2009/02/25 23:41 2009/02/25 23:41
, ,
Response
No Trackback , No Comment
RSS :
http://John.tobe30.com/tc/rss/response/77

Trackback URL : http://John.tobe30.com/tc/trackback/77

Leave a comment
[로그인][오픈아이디란?]