블로그 이미지
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. 3. 10. 22:51 Photograph by ../일상
북서울 꿈의 숲을 다녀왔습니다. 
서울숲과는 다른 느낌의 무언가가 있더군요...

서울숲이 아무래도 조성된지 좀 된 숲이라 식물들이 숲처럼 잘 어우러져 있다는 특징이 있는데 반해 꿈의 숲은 아직까지는 그런점은 부족하지만 잘 계획된 듯 경사형 엘리베이터, 카페, 분수, 전시관 등 보다 많은 볼거리를 제공합니다. 
(사슴은 거기나 여기나 모두 다 있더군요... )

 


동쪽 주차장에서 노루숲을 지나면 위처럼 계단 위로 나오게 됩니다. 천천히 계단을 내려오면...  아래처럼 이쁜 호수(?)가 보입니다. 
이름은 월영지... 아직 겨울이라 분수는 보이지 않습니다. 

 
대신 물고기들이 살고 있는데 아이들이 건빵 부스러기를 던져주면 우~ 모여듭니다. 그러나, 물이 그다지 맑지 않아 아쉽습니다.


 아이들이 물고기들에게 과자 부스러기를 주면서 잠자리채로 잡을려고 하고 있습니다. ㅡㅡ;;

 

  녹색은 식욕을 감퇴시킵니다. ㅎㅎ 아이들이 그냥 뒀으면 좋겠지만... 음... 

 


 월영지 주변에는 정자가 하나 있습니다. 사람들이 잠시 쉴수 있게 해놓은 곳인데... 흠... 나라망신입니다. 
강소희님이 얼른 다시 오셔서 지우셔야 할 것 같습니다. 그리고, 영문... 얼른 지워야 할텐데요... 
 

  
월영지를 자나 조금 올라가다보면.. 상상톡톡 미술관이 나옵니다.
2층으로 3관으로 이루어져 있으며 우리가 갔을때는 "맛있는 미술" 전시가 있었습니다. 어른은 3천원 아이는 2천원
작품수는 다소 부족해 보이지만 그래도 아이들이 좋아하더군요. 

 
담당하시는 Staff 분들이 친절하게 설명을 해주십니다. 사진도 많이들 찍으시고 ^^


 음식과 관련된 작품들이 있습니다. 음식 자체 혹은 음식과 관련된 이야기.. 

 

 
미술관을 지나 언덕을 가다 보면 꿈의숲 아트센터와 전망대를 볼 수 있습니다.
가는길에 보면 넓은 광장이 있는데 아이들이 뛰어놀기 좋습니다.  

 
 이런 간단한 놀이터도 있습니다. 좀더 다양한 놀이기구가 필요할 듯 합니다.

 

 
전망대는 저렇게 생겼습니다. 조금은 구조가 아찔해 보이지만... 그래도 사람들의 호기심을 자극합니다. 올라가서 구경하는 모든것은 무료입니다. 
올라가기 힘든 분들을 위해서 엘리베이터가 잘 되어 있습니다. (계단으로 올라가면 경사가 있어서 좀 힘듭니다.)

 


올라가면 요렇게 생긴 전망대가 있습니다. 서울 시내가 모두 보입니다. 3층으로 이루어져있습니다. 
전망대에는 카페도 있어 커피나 와플등을 즐길 수 있습니다.

 
전망대를 내려오면서 꿈의숲 아트센터내부를 구경했습니다. 숲속의 생명전을 하고 있더군요.
물론 무료관람이 가능하고 사진촬영도 할 수 있더군요. (관리하시는분이 계신데 특별히 말씀을 하지 않으셔서)

 


 이런 작품들이 있습니다. 쿠바, 남아메리카 작가들의 작품이 전시되어 있습니다. 아이들이 보기에는 다소 따분할 수 있을 듯 합니다. (물론 이것이 아이들을 위한 전시는 아닙니다.)

 
아트센터 2층에 있는 카페입니다. 북카페로 아이들 책방이 있고 일반인들을 위한 좌석도 잘 되어 있습니다. 근처에 살고 있다면 커피한잔과 책 한권으로 여유를 만끽할 수 있을 것 같습니다.

간만에 사진 포스팅을 하니 정리가 잘 안되네요. 사진도 일관성이 없고...

여튼... 북서울 꿈의 숲.. 지금도 만족스럽지만 2-3년 후가 더 기대됩니다. 그때가 되면 좀더 자연 친화적인 숲의 모습을 가지게 되겠지요. ^^ 

'Photograph by .. > 일상' 카테고리의 다른 글

[일상] 더킹 투하츠  (0) 2012.03.21
[핸폰] 옵티머스 뷰..  (0) 2012.03.18
써니힐 "나쁜 남자" 가사...  (0) 2012.01.14
[영화] 트렌스포머3  (0) 2011.07.03
[일상] 소소한 지름 ^^  (0) 2011.07.03
posted by LifeisSimple
2012. 3. 6. 22:46 Brain Trainning/DataBase

TDE 성능 관련 테스트 자료가 올라왔네요 음... TDE 사용에 고민이 좀 필요할 듯 합니다. 
 Data 복호화가 필요하다고 생각되는 부분에서는 CPU를 많이 잡아먹습니다. 여기에 Data Compression까지 사용한다면... CPU 사용률은 거의 예술적일듯 합니다. 신중하지 않으면 사고사건사례로 올라갈 수 있습니다.

아래의 테스트에 Table Compression 시의 테스트도 하나 들어갔으면 하네요... 얼마나 더 Over 하게 될지... 

출처 : 
http://www.mssqltips.com/sqlservertip/2641/sql-server-transparent-data-encryption-tde-performance-comparison/?utm_source=dailynewsletter&utm_medium=email&utm_content=headline&utm_campaign=201235  

SQL Server Transparent Data Encryption (TDE) Performance Comparison

Problem

Every new release of SQL Server gives us new features that will hopefully improve our database system in some way. Data security has been a hot topic over the last few years and one of the new features introduced in SQL Server 2008, Transparent Data Encryption (TDE), addresses this topic. This feature gives us a way to secure our data on the backend without any front end code changes. The only concern I had with this new feature was exactly how much overhead would it produce on my server. This tip will take a look at the performance impact of implementing this feature using a few basic database operations.

Solution

For those that aren't yet familiar with TDE, you can read the following links which give an overview of TDE and also some information on how to get started implementing it on one of your own databases. In this tip will we will simply focus on the performance impact of having a TDE enabled database versus a database without TDE enabled and will not get into any details on the configuration of this feature.

One thing to note is all the tests below were run on a server running SQL Server 2008 with a 3GB database. Prior to executing each statement I also ran DBCC DROPCLEANBUFFERS to empty the buffer cache. This ensured that for every operation data would have to be decrypted if required and not just read directly from the buffer pool as data in the buffer pool is not encrypted.


Backup Performance

As it's an operation that we perform daily, let's first take a look at how this feature will affect our backup performance. For this test I ran scripts that performed both compressed and uncompressed full backups with TDE enabled and disabled. Each backup script was run 3 times and the averages are displayed below for each type of script execution.

 TDE EnabledTDE not Enabled
 CPU (ms)READSWRITESDURATION (ms)CPU (ms)READSWRITESDURATION (ms)
With compression 234 319 14 57264 195 298 13 51632
No compression 203 319 14 70384 171 300 13 55714

We see from the results above that having TDE enabled results in about a 16% increase in the cpu used during the backup operation. As well, we see the total duration of the backup took anywhere from 10-20% longer with TDE enabled (depending on whether or not you were using backup compression). All in all this is a fairly small price to pay to have your database encrypted. An important thing to note with having TDE enabled on your database is that you get the extra benefit of having your backups encrypted as well thus providing extra security for all of your offline data.


SELECT, INSERT, UPDATE and DELETE Performance

Now that we know the impact TDE is going to have on our backups let's take a look at what if any impact we can anticipate for the applications that access our database. For this test I created a script with 10 SELECT, 5 INSERT, 8 UPDATE and 5 DELETE statements. Each script was run 3 times and the averages are displayed below broken up by statement type.

 TDE EnabledTDE not Enabled
 CPU (ms)READSWRITESDURATION (ms)CPU (ms)READSWRITESDURATION (ms)
SELECT 7390 121576 18 26037103 3062 121397 1 23409175
INSERT 125 784 16 1509177 32 798 16 1254881
UPDATE 500 2181 31 1376947 108 2215 24 1080074
DELETE 502 2380 30 1271479 63 2417 29 708979

Looking at these results we can see that we get approximately a 10% increase in the duration of our SQL statements with TDE enabled which isn't too bad. The real impact of using TDE is evident here with the performance hit we take in CPU. With TDE enabled we use approximately 60% more CPU for the same workload. Keep in mind these results are measuring the performance of the entire workload. Looking at each statement type individually we can see that we take an even bigger performance hit in CPU when doing inserts, updates and deletes as compared to select statements. Depending on the behaviour of your application this may be an important thing to consider when deciding on whether or not you want to use TDE.


Index Rebuild Performance

Another operation that we as DBAs perform routinely, whether it be weekly, monthly or some other schedule, is index maintenance. For this test I created a script that rebuilt every index in my database. The script was run 3 times and the averages are displayed below.

 CPU (ms)READSWRITESDURATION (ms)
TDE Enabled 14936 347345 46028 21898
TDE not Enabled 7420 347116 46190 17133

The results here are pretty consistent with what we had seen above with our other DML statements. For an index rebuild we see approximate a 50% increase in CPU usage and a 20% increase in duration with TDE enabled as compared to having it not enabled.


Summary

While this does not represent every type of operation executed on your database it gives a good indication of what you could expect the impact to be if you were to implement TDE on your database. One thing to keep in mind is that these numbers are a worst case scenario. In a real world application a lot of the data would already be in the buffer pool when a statement is run so it would not have to be decrypted and therefore the performance impact would be much less. I've read from many difference sources that in real world applications you can see anywhere from a 3-10% degradation in performance with TDE enabled. As always you should test in your own environment as your results may vary based on the nature of the data in your database and the applications accessing it.

Next Steps

posted by LifeisSimple
2012. 3. 5. 23:26 Brain Trainning/DataBase
SQL Server 2008에서 지원하기 시작한 DB 암호화 기능입니다.
물론 특별한 스키마 변경없이 사용할 수 있으나...

 CPU에 좀더 부하를 주는 점과 Windows Instant File Initialization 기능을 사용할 수 없음으로 인해 DB파일 생성 및 Growth 에 시간이 걸립니다. (Zero값으로 초기화 하는 시간이 걸리는 거죠) 그리고, 추가로 Data Compression의 효율성을 떨어트립니다.  MS에서는 TDE와 Data Compression을 함께 사용하지 않도록 권고하고 있습니다. 쩝.

전 차라리 정말 필요한 기능이 아니라면 TDE를 사용하지 않겠습니다. 대용량의 OLTP 성 DB라면 더더욱... 중요합니다.

출처 : http://www.simple-talk.com/sql/database-administration/transparent-data-encryption/

Transparent Data Encryption
16 March 2010

 Transparent Data Encryption is designed to protect data by encrypting the physical files of the database, rather than the data itself. Its main purpose is to prevent unauthorized access to the data by restoring the files to another server.  With Transparent Data Encryption in place, this requires the original encryption certificate and master key.  It was introduced in the Enterprise edition of SQL Server 2008. John Magnabosco  explains fully, and guides you through the process of setting it up.

Keyless entry for automobiles was first introduced by American Motors Corporation in 1983 and, today, there are a variety of methods that are available that permit the user to gain access to their automobile without inserting a physical key into the door lock. These include pushing a button on a device that transmits a radio frequency, entering a code into a key pad located beneath the driver's side door handle, or possessing a device, called a fob, that is detected by the automobile's security system.

Of these devices, only the fob offers transparency to the owner of the vehicle. The fob is recognized by the security system and the door is automatically unlocked; in other words, the fob holder is granted access to the vehicle without any distinguishable action required on his or her part. If a person who does not possess the fob attempts to open the door of the automobile, the door remains locked, denying access into the vehicle.

The experience of the car owner in possession of a fob is similar to the experience of the user attempting to gain access to a database in which Transparent Data Encryption (TDE) has been enabled. TDE is distinct from other techniques in that it secures data by encrypting the physical files of the database, rather than the data itself. The data files for a given database are encrypted using a database encryption key in the user database. This key references a key hierarchy in the Master database, and this dependency prevents the data files from being viewed outside their instance.

Therefore, a valid user can access the decrypted contents of the database files without any distinguishable actions, and without even being aware that the underlying data files are encrypted. However, a would-be data thief, who has obtained access to the data files through a stolen backup file, will find he or she is unable to access the data it contains. Overall, this is a straightforward, low-impact feature that has great security benefits; the only caveat being that it requires SQL Server 2008 Enterprise Edition.

In this article we will explore the considerations of TDE that must be understood prior to its use. We will also walk through an example of implementing and validating TDE using the HomeLending database. Finally, we will cover the process of removing TDE, should the need arise.
 

How TDE Works

Transparent Data Encryption (TDE) was introduced in SQL Server 2008, as a feature of the Enterprise Edition of that product. The Developer Edition of SQL Server 2008 also offers TDE, but its license limits its use to development and testing only.

As noted above, TDE's specific purpose is to protect data at rest by encrypting the physical files of the database, rather than the data. These physical files include the database file (.mdf), the transaction log file (.ldf) and the backup files (.bak).

The protection of the database files is accomplished through an encryption key hierarchy that exists externally from the database in which TDE has been enabled. The exception to this is the database encryption key, which was introduced to the database encryption key hierarchy specifically to support the TDE feature, and is used to perform the encryption of the database files.

In Figure 1, the key hierarchy, and their required location of each key, is illustrated. The service master key exists at the instance level. The database master key and certificate at the Master database are used to protect the database encryption key that is located at the user database, which is the HomeLending database in our example. The database encryption key is then used to decrypt the database files of the user database.

Figure 1: TDE Encryption Key Hierarchy.

The dependency upon the encryption key hierarchy in the Master database, as well as the instance, prevents the database files from being restored to an instance of SQL Server that does not contain the referenced keys. This level of protection is a great comfort if a backup tape that contains your database backup files were to fall into the wrong hands.

Additionally, the encryption of the backup files prevents the plain text values that are contained within the database being disclosed by opening the backup files using a text editor and scanning its contents. The details regarding this scenario will be covered later in this article.

Benefits and Disadvantages of TDE

Comparing TDE to cell-level encryption is a bit like comparing apples to oranges. They are solutions for different challenges. TDE offers general protection to the database while cell-level encryption offers specific protection to data. I would encourage you to consider using TDE in conjunction with other encryption and obfuscation methods, for a layered approach to protection. To determine whether or not TDE should be part of your protection strategy for sensitive data, consider the following benefits and disadvantages.

Benefits

  • Implementation of TDE does not require any schema modifications.
  • Since the physical data files and not the data itself are encrypted, the primary keys and indexes on the data are unaffected, and so optimal query execution can be maintained.
  • The performance impact on the database is minimal. In their whitepaper titled "Database Encryption in SQL Server 2008 Enterprise Edition", Microsoft estimates the performance degradation for TDE to be 3-5%, while cell-level encryption is estimated to be 20-28%. Of course, the impact well may vary, depending upon your specific environment, and volume of data.
  • The decryption process is invisible to the end user.

Disadvantages

  • Use of TDE renders negligible any benefits to be gained from backup compression, as the backup files will be only minimally compressed. It is not recommended to use these two features together on the same database.
  • TDE does not provide the same granular control, specific to a user or database role, as is offered by cell-level encryption.
  • TDE is available only with SQL Server 2008, Enterprise Edition and so will probably not be available to all installations within your environment.

Considerations when Implementing TDE

Prior to implementing TDE, there are several issues to take into consideration, discussed over the following sections.

Master Key Interdependency

The process of implementing TDE involves the creation of a database master key and certificate, or asymmetric key, on the Master database. Only one database master key can be created for a given database so any other user databases that share the instance, and have TDE implemented, will share a dependency upon the Masterdatabase master key.

This interdependency increases the importance of performing a backup of the Master database master key to ensure the continued accessibility of the TDE-enabled databases.

Performance Impact on TempDB

When TDE is initially implemented, the physical file of the TempDB system database is also encrypted. Since theTempDB database contains temporary data from the TDE-enabled database, its encryption is required to maintain full protection by this feature; otherwise the information that is temporarily stored in the TempDB database from the TDE enabled databases would be exposed through the physical files of TempDB.

The TempDB database is used by all user and system databases in the instance to store temporary objects, such as temporary tables, cursors and work tables for spooling. It also provides row versioning and the ability to rollback transactions.

Once the TempDB database is encrypted, any reference and use of this database by other databases, regardless of whether they have TDE enabled or not, will require encryption and decryption. While this encryption and decryption of the TempDB database files remains transparent to the user, it does have a minimal performance impact on the entire instance. Microsoft has estimated the entire impact of TDE on a SQL Server instance to be 3-5% depending on the server environment and data volume.

TDE and Decryption

TDE is designed to protect data at rest by encrypting the physical data files rather than the data itself. This level of protection prevents the data and backup files from being opened in a text editor to expose the file's contents.

TDE encryption occurs prior to writing data to disk, and the data is decrypted when it is queried and recalled into memory. This encryption and decryption occurs without any additional coding or data type modifications; thus it’s transparency. Once the data is recalled from disk, into memory, it is no longer considered to be at rest. It has become data in transit, which is beyond the scope of this feature. As such, alongside TDE, you should consider applying additional supporting layers of protection to your sensitive data, to ensure complete protection from unauthorized disclosure. For example, you may wish to implement, in addition to TDE, encrypted database connections, cell-level encryption, or one-way encryption. For additional data in transit protection that is required, externally from the database, you may need to consult with, or defer to, your Network Administration team.

Backup and Recovery

As noted previously, TDE prevents the backup files from being opened by a plain text editor. It also limits the recovery of the database backup file to the instance that holds the encryption key hierarchy that was in existence at the time the backup was created.

As illustrated in Figure 1, backup files of databases with TDE enabled are encrypted using a key hierarchy that includes the service master key of the SQL Server instance, the database master key and certificate for the Masterdatabase.

Despite this dependency, none of these keys are included with the standard database backup, and must be backed up separately via the following commands:

  • BACKUP SERVICE MASTER KEY to backup of the service master key.
  • BACKUP MASTER KEY to backup of a database master key.
  • BACKUP CERTIFICATE to backup the certificate.

This behavior is one of the security benefits of TDE. In order to restore the encrypted data to another instance of SQL Server, a user needs to recover the service master key backup file, the Master database master key backup file and the Master database certificate private key, prior to recovering the database backup file.

The database encryption key that is created in the user database, in which TDE has been implemented, is included in the standard database backup. It is stored in the boot record of the database file so that it can be accessed and used to decrypt the user database.

When the service master key and database master key are backed up, it is recommended to store their backup files in a separate location from the database files. This separation will ensure continued protection of the encrypted data in the event that the database backup media is stolen or compromised.

TDE and Replication

If the TDE-enabled database is part of a replication setup, the subscribing database must also have TDE implemented. The data that is traveling between the databases will be in plain text and is vulnerable to unauthorized disclosure. A method of encrypting connections, such as secure socket layers (SSL) or Internet protocol security (IPSec), is recommended.

TDE and FileStream Data

The FILESTREAM data type stores large unstructured objects, such as documents and images, in an integrated physical file that is separate from the database file. When TDE is implemented on a user database that containsFILESTREAM data, the filestream files remain unencrypted.

Implementing TDE

In this section, we will implement TDE using the HomeLending database. Our TDE implementation, in comparison to cell-level encryption, will be very simple. There are no modifications to the schema required, there are no permissions that need to be granted to database users and roles in order to use TDE, and there are no additional database objects that must be created to perform the encryption and decryption methods.

On the other hand, the person performing the implementation of TDE does require specific permissions; namelyCONTROL permissions on the Master and HomeLending databases. It is recommended to perform this process while the database is not in use by other users.

Backup before Proceeding

It is a general best practice to backup a database prior to making modifications. However, it is especially important when implementing TDE, in order to ensure that, should the TDE implementation need to be reversed, you can cleanly recover the database in its original form.

In addition, by performing a database backup, a new checkpoint will be established in the transaction log. The creation of a checkpoint truncates all inactive items in your transaction log prior to the new checkpoint. This will ensure that your transaction log is free from unencrypted items, prior to the TDE implementation. Listing 1 shows the backup command for the HomeLending database.

USE HomeLending;

GO

 

BACKUP DATABASE HomeLending

    TO DISK = 'D:\HomeLending\Backup\HomeLending.bak'

    WITH NOFORMAT,

    INIT, 

    NAME = 'HomeLending-Full Database Backup',

    SKIP,

    NOREWIND,

    NOUNLOAD, 

    STATS = 10

GO

Listing 1: Backing up the HomeLending database, prior to TDE.

With the backup successfully completed, we can begin the process of implementing TDE.

The Master Database

Our first step is to create a database master key for our Master database, using the CREATE MASTER KEYmethod, as shown in Listing 2.

USE master;

GO

 

CREATE MASTER KEY

   ENCRYPTION BY PASSWORD = 'MyStr0ngP@ssw0rd2009';

GO

Listing 2: Creating the database master key in the Master database.

Notice that, while ENCRYPTED BY PASSWORD is a required argument to the method, our intent, as in Chapter 5, is to instead protect the database master key with the service master key. This option is automatically available to us, upon creation of the database master key.

A search against the sys.key_encryptions catalog view for the ##MS_DatabaseMasterKey## key, as shown in Listing 3, returns ENCRYPTION BY MASTER KEY, in reference to the service master key.

USE master;

GO

 

SELECT

    b.name,

    a.crypt_type_desc

FROM

    sys.key_encryptions a

    INNER JOIN sys.symmetric_keys b

        ON a.key_id = b.symmetric_key_id

WHERE

    b.name = '##MS_DatabaseMasterKey##';

GO

Listing 3: Confirming protection of the database master key by the service master key.

The next step is to create a self-signed certificate that is protected by the database master key of our Masterdatabase. All certificates created within SQL Server, as opposed to being imported, are self-signed. This associates the certificate to the database.

Certificates are created using the CREATE CERTIFICATE method:

USE HomeLending;

GO

 

CREATE CERTIFICATE MyHighCert

    WITH SUBJECT = 'Cert used for sensitive class of high';

GO

Listing 4.

Since this certificate is located in the Master database and will be used to protect the database encryption key of our HomeLending database, we will name this certificate MasterCert, as shown in Listing 5.

USE master;

GO

 

CREATE CERTIFICATE MasterCert

    WITH SUBJECT = 'Cert used for TDE';

GO

Listing 5: Creating the MasterCert self-signed .

As for Listing 4, by omitting the ENCRYPTION BY PASSWORD argument, we are specifying that the certificate is to be protected by the database master key.

At this point in the process you should perform a backup of the certificate with its private key, using the BACKUPCERTIFICATE command shown in Listing 6. In the event that the HomeLending database needs to be restored, this certificate and its private key will be required.

USE master;

GO

 

BACKUP CERTIFICATE MasterCert

    TO FILE = 'D:\HomeLending\Backup\MasterCert.bak'

    WITH PRIVATE KEY (

               FILE = 'D:\HomeLending\Backup\MasterCert.pvk',

               ENCRYPTION BY PASSWORD = 'MyB@ckUpP@ssw0rd');

GO

Listing 6: Backing up the MasterCert certificate.

Since our MasterCert certificate is protected by the Master database master key, the DECRYPTION BYPASSWORD argument is not included in the WITH PRIVATE KEY argument of this command.

The User Database

Having created the database master key and the MasterCert certificate in the Master database, we are ready to create the database encryption key for the HomeLending database which we will use to perform the cryptographic functions for the physical files of our database.

The database encryption key is created using the CREATE DATABASE ENCRYPTION KEY command. The arguments to this method include:

  • WITH ALGORITHM: Specifies the algorithm used, which in turn dictates the strength of the key.
  • ENCRYPTION BY:  Defines the protection method of the key. The key used in the ENCRYPTION BYargument can be a certificate or an asymmetric key that is located in the Master database.

Listing 7 shows the exact command used for the HomeLending database's database encryption key.

USE HomeLending;

GO

 

CREATE DATABASE ENCRYPTION KEY

    WITH ALGORITHM = AES_128

    ENCRYPTION BY SERVER CERTIFICATE MasterCert;

GO

Listing 7: Creating the HomeLending database encryption key.

The AES_128 option specifies Advanced Encryption Standard (AES) with a 128 bit key length, and we protect the database encryption key with the MasterCert certificate that was created in the Master database.

The final step in the setup process of TDE is to enable it. This is accomplished by executing the ALTER DATABASE command with the SET ENCRYPTION ON argument.

USE HomeLending;

GO

 

ALTER DATABASE HomeLending

    SET ENCRYPTION ON;

GO

Listing 8: Enabling TDE.

At this point, an encryption scan occurs, which is the process by which the physical files of the database are scanned and encrypted. Included in this scan process are the database files, TempDB database files and transaction log files.

Transaction log files contain information that is used to maintain data integrity and are used in the restoration process. Within these files are a series of smaller units called virtual log files (VLFs). These VLFs contain records that pertain to transactions within the database file. Prior to the implementation of TDE, these VLFs contain unencrypted data. During the encryption scan any pages that have been in the buffer cache and modified, known asdirty pages, are written to disk, a new VLF is created and the prior inactive VLFs are truncated. This results in a transaction log that only contains encrypted data.

The duration of the encryption scan will vary depending upon the size of the database files. Once the process has completed, the encryption_state column in the sys.dm_database_encryption_keys dynamic management view will reflect the encryption state of "encrypted", and will show the value of "3" in this column, for our HomeLendingdatabase.

Verifying TDE

Once the implementation of TDE is complete there are a few ways you can verify that these steps indeed succeeded.

Using Dm_Database_Encryption_Keys

Dynamic management views (DMV) are built-in views that provide metadata regarding the settings, health and properties of SQL Server instances and databases. The sys.dm_database_encryption_keys DMV presents information about the database encryption keys used in a given database, as well as the encryption state of the database.

Note:
Database encryption keys are only utilized for the benefit of the TDE feature of SQL Server 2008; therefore this DMV is not available in SQL Server 2005.

Through the use of a query in which the sys.dm_database_encryption_keys DMV and the sys.databasescatalog view are joined through the database_id column, we are able to determine the success of the TDE implementation, as demonstrated in Listing 9.

USE master;

GO

 

SELECT

    db.name,

    db.is_encrypted,

    dm.encryption_state,

    dm.percent_complete,

    dm.key_algorithm,

    dm.key_length

FROM

    sys.databases db

    LEFT OUTER JOIN sys.dm_database_encryption_keys dm

        ON db.database_id = dm.database_id;

GO

Listing 9: Verifying TDE using dm_database_encryption_keys.

A return value of "1" for the is_encrypted column of the sys.databases catalog view indicates that the database has been encrypted through TDE.

The value of the encryption_state column from the sys.dm_database_encryption_keys DMV reflects whether or not the encryption process is complete. A value of "3" indicates that the encryption process is complete. A value of "2" in this column indicates that the encryption process is in progress. The percent_complete column from the same DMV indicates the progress of the encryption process. This column only reflects a value other than "0" when the database encryption state is in the process of changing (being encrypted or decrypted).

In this sample query, I added the key_algorithm and key_length columns to illustrate an interesting dynamic in regard to the TempDB database, as shown in the results in Table 1.

Table 1: Results of TDE verification query.

As previously noted, the encryption of the TempDB is a byproduct of implementing TDE on any given database within an instance of SQL Server. The is_encrypted column for our HomeLending database contains the value of "1" which indicates that it has been successfully encrypted; but the TempDB contains the value of "0", while the values in the other columns indicate that encryption has taken place. This is because the TempDB database is encrypted outside of the established TDE key hierarchy.

This is further emphasized by the algorithm that is used to encrypt the TempDB database. As you will recall, the creation of the database encryption key for the HomeLending database was designated as AES_128, which uses a key length of 128 bits. The results of this query show that the TempDB database is actually using a key length of 256 bits.

The reason for the separate encryption process lies in the inherent behavior of the TempDB database; when the SQL Server instance is stopped and started the TempDB database is dropped and recreated. This can be verified by performing the following steps:

  1. Stop the SQL Server instance.
  2. Start the SQL Server instance.
  3. Execute SELECT * FROM SYS.DATABASES, using the Master database.

The result of the third step will reveal that the column titled CREATE_DATE for the TempDB database will be approximately the date and time that you restarted the SQL Server instance. When thesys.dm_database_encryption_keys DMV is executed, the database encryption key for the TempDB database will still be included in the results and the column titled CREATE_DATE will also reflect the time that the instance was restarted. This illustrates that when the TempDB database is recreated so is its database encryption key.

At first glance the comparison of the CREATE_DATE columns of the sys.databases andsys.dm_database_encryption_keys DMV may raise concern since they do not match; but consider that thesys.dm_database_encryption_keys DMV reflects the date and time in Greenwich Mean Time (GMT) while thesys.databases catalog view reflects the date and time according to your time zone. Depending on your location this may appear to be in the future or in the past. In my case, being on Eastern Standard Time (EST) in the United States the sys.dm_database_encryption_keys DMV CREATE_DATE is five hours into the future.

Verification through Backup and Recovery

Another method of verifying the success of a TDE implementation is to perform a backup of the database, after TDE has been enabled, as shown in Listing 10. When doing so, make sure not to overwrite the backup file that was created prior to implementing TDE.

USE HomeLending;

GO

 

BACKUP DATABASE HomeLending

    TO DISK = 'D:\HomeLending\Backup\HomeLending_PostTDE.bak'

    WITH NOFORMAT,

    INIT, 

    NAME = 'HomeLending-Full Database Backup',

    SKIP,

    NOREWIND,

    NOUNLOAD, 

    STATS = 10

GO

Listing 10: Backing up the HomeLending database after TDE is implemented.

The next step is to compare the contents of the pre-TDE and post-TDE backup files, by opening both files up in a simple text editor such as Notepad, Wordpad or Textpad. We can perform a search within the pre-TDE backup file for the plain text of a known sensitive data value. For example, we will search for the value of "319726 Rocky Fabien Avenue" which is contained in the Borrower_Address table in the HomeLending database.

This search reveals the searched value in plain text, as shown in Figure 2. In addition, if you were to manually scan through the backup file, you would find that the metadata of our database objects, such as tables, views, stored procedures and user defined functions are revealed in plain text.

Figure 2: Backup File - Unencrypted.

The same search on our post-TDE backup file will result in the message box shown in Figure 3, stating that it cannot find the requested value. This is because the entire backup file, including the metadata of our database objects, has been encrypted and no longer contains any plain text values.

Figure 3: Search Results in Encrypted Backup File.

One final test in regard to the backup file is to attempt to restore the post-TDE backup file onto a different instance than the one in which the HomeLending database resides, using the RECOVER DATABASE command, as shown in Listing 11.

USE master;

GO

 

RESTORE DATABASE HomeLending

    FROM DISK = 'D:\HomeLending\Backup\HomeLending_PostTDE.bak'

    WITH FILE = 1, 

    NOUNLOAD, 

    REPLACE, 

    STATS = 10

GO

Listing 11: Attempting to restore the HomeLending database.

This attempt will return an error message that states that the certificate at the Master database level, in which theHomeLending database encryption key is protected, does not exist; therefore the attempt will fail.

Msg 33111, Level 16, State 3, Line 2

Cannot find server certifiate with thumbprint…

 

Msg 3013, Level 16, State 3, Line 2
RESTORE DATABASE is terminating abnormally

Using EXECUTE AS

Finally, we can perform a test to determine that the data that is contained within the encrypted HomeLendingdatabase files can be read by valid users of the database, as shown in Listing 12. We use EXECUTE AS USER to impersonate various users within the database and test their ability to access the encrypted data. The use ofREVERT terminates the impersonation and returns us to our original user account.

USE HomeLending;

GO

 

-- execute as a user who is a member of Sensitive_high role

EXECUTE AS USER = 'WOLFBA';

GO

SELECT * FROM dbo.Borrower;

GO

REVERT;

GO

 

-- execute as a user who is a member of Sensitive_medium role

EXECUTE AS USER = 'KELLEYWB';

GO

SELECT * FROM dbo.Borrower;

GO

REVERT;

GO

 

-- execute as a user who is a member of Sensitive_low role

EXECUTE AS USER = 'JONESBF';

GO

SELECT * FROM dbo.Borrower;

GO

REVERT;

GO

Listing 12: Verifying TDE using EXECUTE AS queries.

Each query in the above script successfully returns the contents of the Borrower table within the HomeLendingdatabase. This demonstrates that the automatic decryption is functioning as expected, and verifies that permissions to the appropriate database objects are not affected.

Reversing the Implementation of TDE

It was once said that the only things certain in life are death and taxes. It could be argued that change is another certainty. You may find yourself in a situation where TDE has been implemented, you have validated that it works, are ready for users to begin using the newly-encrypted database and then, lo-and-behold, a request to reverse TDE comes your way.

Boss: "I would like you to proceed with implementing TDE immediately …"

DBA: "Cool, I'll get right on it."
(DBA Implements TDE)

Boss: "Hey, as I was saying yesterday: I would like you to proceed with implementing TDE next week after our presentation to the Technology Committee."

DBA: "No problem … ah …"
(Begin reversal process)

If, at the time this request comes your way, no transactions have been performed on the encrypted database then you can reverse the TDE implementation using the following steps:

  1. Restore the backup file of the HomeLending database that was created before TDE was implemented.
  2. Drop the certificate that was created in the Master database. This should only be done if there are no other user databases in the instance that have been TDE-enabled. If there are other user databases in the instance that have TDE enabled, you will want to leave the Master database items untouched.
  3. Drop the database master key that was created in the Master database. This should only be done if there are no other user databases in the instance that have TDE enabled. Otherwise, you will want to leave theMaster database items untouched.
  4. Restart the instance in which the HomeLending database resides. If there are not any other user databases on the instance that have TDE implemented, this action will force the recreation of the TempDBdatabase in an unencrypted format.

Listing 13 shows the code to implement these steps.

USE master;

GO

 

RESTORE DATABASE HomeLending

    FROM DISK = 'D:\HomeLending\Backup\HomeLending.bak'

    WITH FILE = 1, 

    NOUNLOAD, 

    REPLACE, 

    STATS = 10;

GO

 

DROP CERTIFICATE MasterCert;

GO

 

DROP MASTER KEY;

GO

 

-- Restart Instance Though SQL Server Management Studio:

-- Right-Click instance and click on "Restart" option.

Listing 13: Reversing TDE when no transactions have occurred.

If the request to reverse the implementation of TDE comes after transactions have occurred, or a copy of the pre-TDE backup file is no longer available, the following steps can be performed:

  1. Alter the HomeLending database to have the ENCRYPTION option set to the value of OFF.
  2. Wait until the decryption process is complete. Use the sys.dm_database_encryption_keys DMV to determine its status. A value of "1" returned in the encryption_status column indicates that the decryption is complete.
  3. Drop the database encryption key for the HomeLending database.
  4. Restart the instance in which the HomeLending database resides. If there are not any other user databases on the instance that have TDE implemented, this action will force the recreation of the TempDBdatabase in an unencrypted format.

Listing 14 shows the code to implement these steps.

USE HomeLending;

GO

 

ALTER DATABASE HomeLending

    SET ENCRYPTION OFF;

GO

 

-- Before proceeding, wait until the decryption process is complete.

-- Use the sys.dm_database_encryption_keys dmv to determine this.

 

DROP DATABASE ENCRYPTION KEY;

GO

 

-- Restart Instance Though SQL Server Management Studio:

-- Right-Click instance and click on "Restart" option.

Listing 14: Reversing TDE after transactions have occurred.

We will need to keep the certificate and database master key that was setup in the Master database, since there will remain some dependencies upon these keys that affect the recoverability of the database.

It is recommended to perform either of these removal options while the database is not in use by other users. In addition, it is always recommended that a backup be made of the database, the database master key and certificate prior to reversing TDE.

Summary

Through this demonstration we have successfully implemented TDE for the HomeLending database and validated that it is enabled. In addition, the steps to reverse TDE have been provided in the event that it is requested.

While TDE does not offer the granularity of protection that cell-level encryption offers, it does provide a level of protection that cannot be achieved through cell-level encryption. This feature provides a means to render unreadable the plain text that would otherwise be disclosed in the database backup files.

Thanks to the encryption key hierarchy that is external to the database, additional protection is offered by restricting restoration of the encrypted database to the instance from which the backup files were created.

Implementing TDE in conjunction with cell-level encryption provides a layered approach to data security, which enhances its effectiveness. Another option for protecting sensitive data that is available is one-way encryption, also referred to as hashing. One-way encryption can be applied alongside TDE, cell-level encryption and other obfuscation methods.



This article has been viewed 12950 times.
posted by LifeisSimple
2012. 3. 4. 21:34 Brain Trainning/DataBase
posted by LifeisSimple
2012. 3. 3. 21:35 Brain Trainning/Server
윈도우 2008 버전에서 지원되는 Hyper-V (v1)에서는 다음과 같은 이슈가 있다고 하는군요... 
따라서, Hyper-V를 사용해 가상화를 구성하는 입장에서는 2008 Server가 아닌 2008 R2를 사용하여 아래 이슈가 해결된 Hyper-V v2를 사용해야겠습니다.

1. 하나의 Host 에서 다른 Host 로  VM을  Migration을 하는 경우 필히 다운 타임을 가져가야 합니다.
2. 한 Host 당 16개의 logical Processor 만을 지원합니다.
3. Virtual Machine에 대한 동적인 리소스 지원이 부족합니다. (메모리 등)

위의 것들이 문제가 된다고 생각하시면...
Hyper-V 버전을 잘 체크해서 v2를 사용할 수 있도록 해야 하겠습니다. 위의 것들 말고도 많은 향상이 있다고 합니다.

참고로 2008 R2 Hyper-V v2 에서는 다음과 같은 것들을 지원합니다.
1) 윈도우 2008 보다 2008 R2의 지원  Processor의 수가 늘었습니다. (64->256 Logical Processor) 
2) SLAT(Second Level Address Translation)를 지원하여 VM 의 Virtual-to-Physical Address Mapping 성능을 향상시켰다고 합니다.
3) Dynamic Memory를 지원해서 VM을 다운시키지 않고 동적으로 메모리를 추가 할 수 있습니다. (R2 Service Pack 1이상에서 가능) 
posted by LifeisSimple
2012. 2. 26. 08:08 Brain Trainning/DataBase
다양한 옵션을 가진 스트레스 테스트 툴입니다. 
UI도 간단하고 옵션설정도 다양합니다. HA 테스트도 된다는... 강점이 후~

예전에는  MS 것을 사용했는데 ... 이제는 이녀석으로 전환해야겠군요 ㅎㅎ

http://www.sqlstress.com/

SQLStress is a tool to stress test a Microsoft SQL Server installation. Its main purpose is to find infrastructure problems within an installation. It can also be used for hardware sizing, system tuning or benchmarking. The focus is on simplicity. You should be up and running within minutes.

Prerequisite is an installed version of the .Net Framework 2.0. The tool will run on x86, x64 and Itanium. It is tested on Microsoft SQL Server 2008 and Microsoft SQL Server 2005, however most of the functionality will work on Microsoft SQL Server 2000 as well.

Features

  • Load testing: Statement mix can be defined to remodel actual workloads
  • Implements performance counters that include statement response times
  • Can combine statements from different users to a distributed transaction exercising MSDTC
  • Can use databases on multiple instances
  • Can be used for cluster failover tests
  • Can be used for mirroring failover tests
  • Very efficient, can simulate thousands of virtual users
  • Transaction scheduler can sustain a specified number of transactions per second
  • Can be used to run stress tests against an SMTP server

The current version of the tool is free, but I reserve the right to create a commercial version with additional functionality in the future.


posted by LifeisSimple
2012. 2. 25. 16:33 Brain Trainning/DataBase
 DB가  Suspect모드로 들어가게 되면 다음과 같은 방법으로 처리합니다. 2005버전
(특히나 빠른 복구시간을 요하는 경우 얼른 처리를)

출처 : http://www.MSSQLTips.com/tip.asp?id=1914

1. 상태변경 (Turn off Suspect flag on Database)
Exec sp_resetstatus 'DB_Name'

2. Emergency Mode 로 전환해서 문제해결 (해결중에 다른 사용자의 접근 차단)
Alter Database DB_Name SET EMERGENCY

3. 정합성 체크
DBCC checkdb ('DB_Name')

4. 정합성에 큰 문제가 없다면 Single_User Mode 로 전환
Alter Database DB_Name Set Single_User with Rollback Immediate

5. 데이터 에러 체크 (일부 데이터 유실 허용)
DBCC CheckDB ('DB_Name', Repair_Allow_Data_Loss)

6. Multi_User 모드 변환 후 정상 서비스
Alter Database DB_Name Set Multi_User


이런 방식으로 복구를 해줍니다. 
 
posted by LifeisSimple
2012. 2. 23. 21:42 Brain Trainning
는 아니고...

키노트를 공부하기 시작했습니다. ㅎㅎㅎ

첫번째 연습... 표 만들기... 생각보다 깔끔하고 이쁘게 만들어지는군요.
 (내용은 단축키... )

 
11 이 II 로 보이는 폰토이긴 하지만 그냥 전체적으로 깔끔해서 좋습니다.  

'Brain Trainning' 카테고리의 다른 글

MS 워드를 활용한 블로그 글올리기  (1) 2011.01.09
가상화 관련 링크  (0) 2010.11.18
MS 2009 PDC 자료  (0) 2010.07.15
Shift-Space 로 한영전환 Reg  (0) 2010.06.07
각 나라별 사용 IP대역  (0) 2010.05.06
posted by LifeisSimple
2012. 2. 18. 11:57 Brain Trainning/Server

시퀄 서버를 구성할때 가성비를 고려해 Multi Core CPU를 많이 도입하고 있습니다. (시퀄 라이선스는 소켓기준입니다.)

여기에 Hyper Threaing까지 사용하면 2 CPU소켓 으로 최대 40 Logical Core (E7 제품군의 경우) 가 가능합니다. 
(2 * E7-8800 * Hyper-Threading = 40 Logical Core)

그런데, 보통 시퀄서버를 세팅할때 Hyper Threading 을 Disable 하고 사용합니다. (2세대 Hyper-Threading 일 경우는 ON 을 해줍니다만 그냥 죽여버리는 경우가 있죠. 이러면 아까운 절반의 Logical Core를 버리게 됩니다. )

이렇게 사용하는 이유는...

1세대 Hyper-Threading 을 사용하게 되면 Logical Core 가 2이 되면서 이 2 Core가 L2 Cache를 공유하게 됩니다.
이때, 두 Core 간의 Application Data를 Cache로 다시 Loading 하게 되는 Context Switching  이 과도하게 발생해 성능상에 문제를 발생시키는 것입니다. 

이런 증상은 2세대 Hyper-Threading 에서 수정되어졌다고 합니다. 

2세대를 지원하는 것으로는
Intel Nehalem 또는 Westmere 기반의 Xeon 5500, 5600, 6500 과 7500, E7 제품 군입니다.

잘 확인해서 가성비를 극대화 할 수 있어야 하겠습니다. 

그리고, 처음 구매할때 IO만큼이나 CPU에 관심을 가져야 합니다. 요즘엔 Storage 의 성능을 커버하기 위해 여분의 CPU 를 활용하는 방안이 시퀄에 도입되고 있습니다. 바로 압축기능이죠 이 기능을 활용하면 CPU는 좀더 (3~10% 정도) 사용하는 대신 I/O및 Storage 사용량을 줄일 수 있습니다. Data Compression 의 경우 Zip 을 사용한것과 유사한 정도로 압축효과를 거둘 수 있습니다. 

아래 링크를 보면 Intel 의 CPU를 비교 가능합니다.

www.intel.com 의 http://www.intel.com/content/www/us/en/processor-comparison/compare-intel-processors.html?select=server.html 

추가 --
아래는 하이퍼 스래딩에 관한 글입니다. "프로그래머가 몰랐던 멀티코어 CPU 이야기" 에서 발췌했습니다.
동시 멀티스레딩으로 만들어진 두 논리 프로세서에 많은 캐시가 필요하다면 이 또한 해가 될 수 있다. 하이퍼스레딩과 같은 기술을 고려해서 캐시를 만들기란 쉽지 않다. 따라서 보통 캐시 장치는 동시 멀티스레딩에 무관하다. 최악에는 하이퍼스레팅으로 두 프로그램의 실행 시간이 비 하이퍼스레팅 기반의 프로세서보다 느려질 수도 있다. 두 논리 프로세서가 캐시 충돌을 자주 일으킨다면 성능이 저하될 수도 있다. 그러나 꼭 단점만 있는 것은 아니다. 다른 관점에서 보면 두 논리 프로세서가 캐시를 공유하므로 서로 좋은 효과를 낼 수도 있다. 한 논리 프로세서가 미리 데이터를 캐시에 올려다 놓고, 운 좋게 나머지 논리 프로세서가 이것을 공유한다면 이득을 얻을 수 있다. 
위의 글의 경우는 주로 시퀄서버는 1세대 Hyper-Threading에서 운이 안좋았군요.

그래도, 2세대에서는 개선이 되었고, 윈도우 2008 R2, 윈도우 7에서는 하이퍼스레딩에 적합한 스케줄링이 되어 그런 문제는 없는 듯 합니다. 
(2세대에 대한 부작용에 관한글은 아직 없는 듯 하네요)

마지막으로, Hyper-Threading 환경에서 OLAP, OLTP 성능에 대한 고민이 필요할 듯 합니다.  

참고 : NUMA 구조 (Non-Uniform Memory Access)
 


" NUMA 공유 메모리 구조에서는 시스템 전체적으로는 메모리 주소를 공유하지만, 물리적인 메모리 위치는 떨어져 있을 수 있다. NUMA의 장점은 바로 확장성에 있다. NUMA구조에서는 한 프로세서와 가까이 있는 메모리로의 접근이 다른 메모리보다 빠르다. 메모리 접근 속도가 물리적인 프로세서와 메모리의 위치에 따라 결정되기에 '비균일' 메모리 접근 속도가 만들어지는 것이다. 따라서 소프트웨어나 운영체제는 NUMA 환경이라면 이것을 인지해 최적화 할 것이다. "
posted by LifeisSimple
2012. 2. 18. 08:59 Brain Trainning/DataBase
어쩔 수 없이 동적 쿼리를 사용하다가 보면 가끔씩 아무 생각없이 넘어가는 부분이 많이 있습니다. 
이런 몇가지 부분을 고민해서 해결한다면 좋은 성능과 유지보수 용이성을 가진 쿼리를 만들 수 있습니다.

1.  SQL Injection
 - 동적 쿼리를 만들다 보면 흔히 고민하게 되는 부분입니다. 명확한 파라미터 타입 사용, char 타입의 사용시에는 꼭 필요한 길이만, 그리고, 마지막으로 변수값에 대한 필터링이 필요하겠습니다.

2.  Like 문
 - 보통 Like 를 사용할때 문장을 연결하는 경우가 있습니다.
 
 set @strSQL = ' select top 10 * from mt_song_tmp where song_name like ''' + @likeParam + '%'' '

   이렇게 바꿀 수 있습니다.
   set @strSQL = ' select top 10 * from mt_song_tmp where song_name like @likeParam ' <-- sp_executesql 을 사용해야 합니다.

   위의 두 쿼리는 파라미터 값만 변경하면 됩니다. 첫번 것은 보통 파라미터 값이 '물건' 이렇게 들어온다면 수정한 문장에서 사용되어 지는 파라미터 값은 '물건%' 라고 하면 되겠지요.

3. 디버깅
 - 동적쿼리는 디버깅 하기가 좀 귀찮은 면이 있습니다. 그렇지만 간단한 파라미터 하나로 디버깅을 할 수 있도록 하면 유지보수성이 좋아집니다. #debug 같은 느낌이랄까요.
  create proc dbo.UP_GetProductInfo
    @likeParam varchar(100),
    @debug bit = 0
  as 
  .......

 if @debug = 1
   print @likeParam -- or 실행될 문장
 else
   exec sp_executesql -- 직접 실행 

4. 유지보수
 - 가끔씩 어떤 테이블을 변경하면서 관련된 쿼리를 찾아야 하는 경우가 발생합니다. 이럴때는 sp_depends 를 사용하게 되는데요. 동적쿼리를 사용하다보면 이 녀석들은 안나타나게 됩니다. 특히나 테이블명을 동적으로 변경하는 쿼리들은 알수가 없게 됩니다. (DMV 쿼리 구문으로도 찾기 어려운 경우가 있습니다.)
이럴때를 대비해서 아래와 같이 가볍게(?) 하나 넣어주게 되면 향후 유지보수성이 좋아지게 됩니다.

if 1 = 2
begin
  select top(0) 0 from mt_song_tmp;
end 


이상 몇가지를 정리해봤습니다. 

동적쿼리는 구현해야하는 동기 만큼이나 귀찮은 녀석입니다. 조금만 더 신경쓴다면 시스템을 장애로 밀어넣는 훌륭한(?) 품질의 쿼리를 생산하지 않으리라 생각됩니다. 향후 유지보수에도 큰 도움이 될 것입니다.

대략적인 쿼리의 모습은 다음과 같습니다.

create proc dbo.UP_GetSongINFO

           @likeParam varchar(100),

           @debug bit = 0

as

 

set nocount on

 

declare @strSQL nvarchar(2000)

declare @paramDefinition nvarchar(1000)

 

set @strSQL = 'select * from mt_song_tmp where song_nm like @likeParam'

 

set @paramDefinition = '@likeParam varchar(100)'

 

if @debug = 1

begin

           print @likeParam

end

else

           exec sp_executesql @strSQL, @paramDefinition, @likeParam

 

 

if 1 = 2

begin

           select top (0) 0 from mt_song_tmp with (nolock)

end

 

  
 
posted by LifeisSimple