'MSSQL'에 해당되는 글 3

  1. 2006.08.01 MSSQL 테이블 정의서를 쉽게 만들어보자!! 8
  2. 2006.07.22 Stored Procedure(저장 프로시져) 코딩을 쉽게 하자
  3. 2006.07.20 저장 프로시져 파라미터 매칭값

MSSQL 테이블 정의서를 쉽게 만들어보자!!

Written by Ssemi™(semin Seol), www.Ssemi.net

개발자의 필요 덕목 중 개발능력도 물론 중요하지만, 문서화는 매우 중요한 요소입니다.
문서화 능력 하나로 인해 같은 개발능력을 갖고 있는 개발자라 할 지라도, 차이점이 존재하게 만들 수 있기 때문이지요.

Stored Procedure(저장 프로시져) 코딩을 쉽게 하자에 이은 2탄은 바로 테이블 정의서를 쉽게 만들어 보는 것입니다.
사수에게 테이블 정보를 전달 받을 때, 혹은 부사수에게 테이블에 대한 내용을 알려줄때 유용하게 사용하실 수 있습니다.


Document Table List

MSSQL Eterprise Manager의 다이어그램을 출력하기 용의하게 변경한 ASP 스크립트 파일입니다.

▶ 미리보기(Preview)

이곳에서 미리보기 가능합니다 (새창으로 띄우실려면 shift + 마우스 클릭)


▶ 다운로드(Download)



▶ 사용법(How to use)

파일을 열어보시면 아래와 같은 부분이 있습니다. 해당 정보를 입력해주세요.

'--------------------------------------------------------------------------
'    // 사용자 지정 사항
'--------------------------------------------------------------------------
' 디비 연결 - DB Connect
'--------------------------------------------------------------------------
   Dim DBSRV, DBName, DBID, DBPW
   DBSRV = ""
   DBName = ""
   DBID = ""
   DBPW = ""
'--------------------------------------------------------------------------
' 개인 정보 - Personal Info
'--------------------------------------------------------------------------
   ProjectName = "TABLE INFOMATION"
   YourName = "Your Name"
'--------------------------------------------------------------------------
' 종이 픽셀 설정 (Default : A4)
   PaperHeight = "1010" ' A4용지에 맞는 종이 높이값
'--------------------------------------------------------------------------


▶ 주의사항

  • 이 스크립트의 실행은 DBMSMSSQL임에 한해 실행되고 보여집니다.
  • 인터넷 익스플로러(Internet Explorer) + A4용지에 최적화 되어있습니다
  • 파이어폭스(Firefox)에서는 용지 중앙에 아주 알맞게 출력됩니다. (단 테이블이 이쁘질 않음 ㅜ_ㅜ)
  • 출력 용지를 변경하실 때에는 IE메뉴 - 파일 - 인쇄 미리보기를 통해 PaperHeight 의 값을 설정해주시고 출력한다면 좀 더 멋진 결과물을 받으실 수 있습니다.
작은 프로그램 하나로 당신의 문서화 능력을 업그레이드 시키세요! :)
2006. 8. 1. 16:13

Stored Procedure(저장 프로시져) 코딩을 쉽게 하자

Written by Ssemi™(semin Seol), www.Ssemi.net

귀차니즘에 빠진 Ssemi™의 Library 제 3탄 - SP_CodingMaker를 소개합니다.

제가 쓰는 에디터 프로그램은 EditPlus입니다.
그러다 보니 모두 하드코딩(Hard Coding)을 하게 되는데요

ASP작업시에 Command 개체를 통해서 Stored Procedure를 사용하는 코드를 작성할 때, Parameter 값을 입력하게 됩니다.
With oCmd
   .ActiveConnection = strConnect
   .CommandType = 4
   .CommandText = "sp_Login"
   .Parameters.Append .CreateParameter("@UserID", 200, &H0001, 16, UserID)
   .Parameters.Append .CreateParameter("@Password", 200, &H0001, 20, Password)
   .Parameters.Append .CreateParameter("@OutError", 3, &H0002, 0)
   .Execute, , 128
   OutError = .Parameters("@OutError").Value
   IF isNull(OutError) OR Len(OutError) = 0 Then OutError = 0 ELSE OutError = CLng(OutError) End IF
   SET oRs = .Execute
   .Parameters.Delete "@UserID"
   .Parameters.Delete "@Password"
   .Parameters.Delete "@OutError"
End With

이부분은 거의 뭐 직접 작성하기 보단, Ctrl + C (복사하기) 와 Ctrl + V (붙이기)로 작성을 해나가는데요.
이게 나름대로 귀찮은 작업니다. 이걸 간편히 하고자 부분 수정만 하면 편하게 사용할 수 있게 하나 만들어 놓았었습니다.
나름대로 지저분하게 만들어 놓았던 것을 약간 스타일링(!) 하고, 코드 좀 수정(!)해서 배포합니다.


Store Procedure Coding Maker

귀차니즘의 ASPer에게 이것이 아주 도움이 되기를 희망하면서..... ^_^

▶ 다운로드(Download)


▶ 사용법

파일을 열어보시면 아래와 같은 부분이 있습니다. 해당 정보를 입력해주세요.

'-----------------------------------------------------------
'    // 디비 연결
'-----------------------------------------------------------
Dim DBSrv, DBName, DBID, DBPW
DBSrv = ""
DBName = ""
DBID = ""
DBPW = ""
'-----------------------------------------------------------
'    // 객체 이름 지정
'-----------------------------------------------------------
Dim RecordSetObjectName, CommandObjectName
RecordSetObjectName = "oRs"
CommandObjectName = "oCmd"
'-----------------------------------------------------------

후에 ASP를 실행하시면 아래와 같은 결과창이 뜨게 됩니다.
파일을 실행한 화면입니다

파일 실행한 화면

제일 아래는 DBHelper Class를 사용하는 사용자(?)를 위해 특별히(..) - 저도 요즘 써보고 있거든요;;;;

▶ 주의사항

@RETURN_VALUE를 안쓴다는 가정하에 진행된 스크립트 파일입니다.
파일안에서 @RETURN_VALUE에 대한 내용을 아예 삭제시켰거든요 ^_^;
MSSQL2000에서는 @RETURN_VALUE가 제대로 안먹어서 @변수 하나 만들어서 OUTPUT으로 빼서 사용하는편이 훨씬 좋아서요!

데이터타입을 Decimal 혹은 Numeric 값을 쓸 경우 Precision 과 NumericScale 을 정의해야 하는데,
이 부분을 제가 사용한 적이 없어서 코드에 넣어두지 않았습니다.


앞으로 업데이트 할 예정이니 ^_^ 일단은 사용해주시기 바랍니다.

Enjoy Your Coding!
2006. 7. 22. 11:03

저장 프로시져 파라미터 매칭값

Stored Procedure(저장 프로시져) 코딩을 쉽게 하자를 하다가 알아버린(!) 내용입니다.

* 저장 프로시져 파라미터 매칭값
ConstantValueDescription
AdArray
(Does not apply to ADOX.)
0x2000A flag value, always combined with another data type constant, that indicates an array of that other data type.
adBigInt20Indicates an eight-byte signed integer (DBTYPE_I8).
adBinary128Indicates a binary value (DBTYPE_BYTES).
adBoolean11Indicates a boolean value (DBTYPE_BOOL).
adBSTR8Indicates a null-terminated character string (Unicode) (DBTYPE_BSTR).
adChapter136Indicates a four-byte chapter value that identifies rows in a child rowset (DBTYPE_HCHAPTER).
adChar129Indicates a string value (DBTYPE_STR).
adCurrency6Indicates a currency value (DBTYPE_CY). Currency is a fixed-point number with four digits to the right of the decimal point. It is stored in an eight-byte signed integer scaled by 10,000.
adDate7Indicates a date value (DBTYPE_DATE). A date is stored as a double, the whole part of which is the number of days since December 30, 1899, and the fractional part of which is the fraction of a day.
adDBDate133Indicates a date value (yyyymmdd) (DBTYPE_DBDATE).
adDBTime134Indicates a time value (hhmmss) (DBTYPE_DBTIME).
adDBTimeStamp135Indicates a date/time stamp (yyyymmddhhmmss plus a fraction in billionths) (DBTYPE_DBTIMESTAMP).
adDecimal14Indicates an exact numeric value with a fixed precision and scale (DBTYPE_DECIMAL).
adDouble5Indicates a double-precision floating-point value (DBTYPE_R8).
adEmpty0Specifies no value (DBTYPE_EMPTY).
adError10Indicates a 32-bit error code (DBTYPE_ERROR).
adFileTime64Indicates a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (DBTYPE_FILETIME).
adGUID72Indicates a globally unique identifier (GUID) (DBTYPE_GUID).
adIDispatch9Indicates a pointer to an IDispatch interface on a COM object (DBTYPE_IDISPATCH).

Note   This data type is currently not supported by ADO. Usage may cause unpredictable results.

adInteger3Indicates a four-byte signed integer (DBTYPE_I4).
adIUnknown13Indicates a pointer to an IUnknown interface on a COM object (DBTYPE_IUNKNOWN).

Note   This data type is currently not supported by ADO. Usage may cause unpredictable results.

adLongVarBinary205Indicates a long binary value (Parameter object only).
adLongVarChar201Indicates a long string value (Parameter object only).
adLongVarWChar203Indicates a long null-terminated Unicode string value (Parameter object only).
adNumeric131Indicates an exact numeric value with a fixed precision and scale (DBTYPE_NUMERIC).
adPropVariant138Indicates an Automation PROPVARIANT (DBTYPE_PROP_VARIANT).
adSingle4Indicates a single-precision floating-point value (DBTYPE_R4).
adSmallInt2Indicates a two-byte signed integer (DBTYPE_I2).
adTinyInt16Indicates a one-byte signed integer (DBTYPE_I1).
adUnsignedBigInt21Indicates an eight-byte unsigned integer (DBTYPE_UI8).
adUnsignedInt19Indicates a four-byte unsigned integer (DBTYPE_UI4).
adUnsignedSmallInt18Indicates a two-byte unsigned integer (DBTYPE_UI2).
adUnsignedTinyInt17Indicates a one-byte unsigned integer (DBTYPE_UI1).
adUserDefined132Indicates a user-defined variable (DBTYPE_UDT).
adVarBinary204Indicates a binary value (Parameter object only).
adVarChar200Indicates a string value (Parameter object only).
adVariant12Indicates an Automation Variant (DBTYPE_VARIANT).

Note   This data type is currently not supported by ADO. Usage may cause unpredictable results.

adVarNumeric139Indicates a numeric value (Parameter object only).
adVarWChar202Indicates a null-terminated Unicode character string.
adWChar130Indicates a null-terminated Unicode character string (DBTYPE_WSTR).


* SQL자료형과 ADO파라미터개체의 Type속성매칭  
SQL Server Data TypeADO Data Type
bigintadBigInt
binaryadBinary
bitadBoolean
charadChar
datetimeadDBTimeStamp
decimaladNumeric
floatadDouble
imageadVarbinary
intadInteger
moneyadCurrency
ncharadWChar
ntextadLongVarWChar
numericadNumeric
nvarcharadVarWChar
realadSingle
smalldatetimeadTimeStamp
smallintadSmallInt
smallmoneyadCurrency
sql_variantadVariant
sysnameadWChar
textadLongVarChar
timestampadBinary
tinyintadVarbinary
uniqueidentifieradGUID
varbinaryadVarbinary
varcharadVarChar

* 출처와 다르게 부분 스스로 수정한 곳

※ 출처 - SQLER
2006. 7. 20. 09:49