이 블로그 검색

2015년 1월 8일 목요일

Allow to remote connect to SQL Server

To open a port in the Windows firewall for TCP access

1.    On the Start menu, click Run, type WF.msc, and then click OK.




2.    In the Windows Firewall with Advanced Security, in the left pane, right-click Inbound Rules, and then click New Rule in the action pane.




3.    In the Rule Type dialog box, select Port, and then click Next.




4.    In the Protocol and Ports dialog box, select TCP. Select Specific local ports, and then type the port number of the instance of the Database Engine, such as 1433 for the default instance. Click Next.




5.    In the Action dialog box, select Allow the connection, and then click Next.




6.    In the Profile dialog box, select any profiles that describe the computer connection environment when you want to connect to the Database Engine, and then click Next.









7.    In the Name dialog box, type a name and description for this rule, and then click Finish.





2014년 6월 16일 월요일

SSIS UNZIP TASK



 

 

Executable : unzip.exe
 
Arguments : "D:\unzip.exe " -o  "C:\zipFilePath\file.zip" -d "D:\unzipFolderPath\"
폴더명에 공백이 포함된 경우 Double Quotation 으로 묶어줘야 하며
Argument 값에 에서 Double Quotation은   \"  으로 입력한다.
 
 
 

OPENQUERY INSERT/UPDATE/DELETE



-- update
UPDATE OPENQUERY(LINKED1, 'SELECT SSN FROM TESTLINKED WHERE SSN=2')
SET SSN=SSN + 1

-- insert
INSERT OPENQUERY(LINKED1, 'SELECT SSN FROM TESTLINKED WHERE 1=0') VALUES (1000)

-- delete
DELETE OPENQUERY(LINKED1, 'SELECT SSN FROM TESTLINKED WHERE SSN>100')

SQL Server 에 접속되어 있는 IP 찾기


DMBS에서 CMD 명령어를 사용하기 위해 cmdshell 활성화 하는 것은 보안상 취약 있으므로

주의가 필요함.

 

 
 

-----------------------------------------

-- cmdshell Option Enable

sp_configure 'show advanced options', 1

RECONFIGURE

sp_configure 'xp_cmdshell', 1

RECONFIGURE

 

------------------------------------

--- Create Procedure

CREATE PROCEDURE usp_getboundAddresses

AS

BEGIN

 

SET NOCOUNT ON

 

IF OBJECT_ID('tempdb..#SomeTable') IS NULL

CREATE TABLE #SomeTable

(

ShellOutput VARCHAR(500)

)

 

INSERT INTO #SomeTable

EXEC xp_cmdshell 'nbtstat -a .'

 

SELECT

SUBSTRING( ShellOutput,

CHARINDEX('[',ShellOutput)+1,

-- LEN(ShellOutput) - CHARINDEX(']',ShellOutput) -2 --(EN)

 

LEN(ShellOutput) - CHARINDEX(']',ShellOutput) + 1 --(KR)

 

) AS BoundAddress

from #SomeTable

-- WHERE ShellOutput LIKE '%Node IpAddress%' --the important lines(EN)

 

WHERE ShellOutput LIKE '%노드 IpAddress%' --the important lines(KR)

AND ShellOutput NOT LIKE '%0.0.0.0%' --Unassigned addresses

 

DROP TABLE #SomeTable

 

END

 

------------------------------------------

-- Execute Procedure

 

exec usp_getboundAddresses

 

------------------------------------------

-- Result

 

 







Could not continue scan with NOLOCK due to data movement

에러 메세지 : 
Msg 601, Level 12, State 2, Line 8
데이터 이동으로 인해 NOLOCK으로 계속 검색할 수 없습니다.
 
영문 : Could not continue scan with NOLOCK due to data movement 

 
해결 : Index Rebuild 후 다시 쿼리 실행.

SQL Server 버전 정보 확인

SSMS UI 내에서도 확인 가능하겠지만,
쿼리로도 조회 가능.


SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')

제품버전        제품수준     에디션
결과 : 10.0.1600.22       RTM      Enterprise Edition