안녕하세요. 이성필 입니다.
오랜만에 글을 올리게 되네요. ^^


오늘은 MSSQL의 단축키 관련해서 이야기 해보고자 합니다.

SQL Server를 사용하다 보면 자주사용하는 기능에 대한 short-cut을 지정하게 되는데…
다들 아시겠지만… 도구>옵션 에서 [키보드] 를 선택하면 설정할 수 있습니다.


저는 일단 키보드 구성표를 "SQL Server 2000" 으로 사용합니다. (버릇이라서 ^^)
그리고, 아래처럼 설정을 하여 사용하고 있습니다.

 

USE master

GO

 

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

-- auth : splee

-- date : 20070831

-- desc : 선택한keywordstored procedure 내에사용된모든stored procedure namereturn한다.

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

CREATE PROCEDURE dbo.sp_HelpStoredProcedureName

       @vcKeyword varchar(256)

AS

BEGIN

       SET NOCOUNT ON

 

       SET @vcKeyword = '%' + @vcKeyword + '%';

 

       SELECT name [Stored Procedure Name]

       FROM sys.objects with (nolock)

       WHERE object_id IN (

                                                     SELECT object_id

                                                     FROM sys.sql_modules with (nolock)

                                                     WHERE definition LIKE @vcKeyword

                                                     )

       ORDER BY 1 ASC;

 

       SET NOCOUNT OFF

END;

GO

exec sp_MS_marksystemobject 'sp_HelpStoredProcedureName'

GO

 

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

-- auth : splee

-- date : 20070831

-- desc : 선택한keyword가이름인Table의컬럼을컴마(,) 로연결해서출럭한다.

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

CREATE PROCEDURE dbo.sp_HelpColumnNameWithComma

       @TableName varchar(1024)

AS

BEGIN

       DECLARE @tmp TABLE (iSeq int identity(1, 1), COLUMN_NAME varchar(1024));

       DECLARE @iMax int, @iMin int, @Result varchar(2048);

 

       INSERT INTO @tmp (COLUMN_NAME)

       SELECT COLUMN_NAME

       FROM INFORMATION_SCHEMA.COLUMNS

       WHERE TABLE_NAME = @TableName

       ORDER BY ORDINAL_POSITION;

 

       SELECT @iMax = MAX(iSeq), @iMin = MIN(iSeq) FROM @tmp;

 

       SELECT @Result = COLUMN_NAME FROM @tmp WHERE iSeq = @iMin;

 

       SET @iMin = @iMin + 1;

 

       WHILE @iMax >= @iMin

       BEGIN

             SELECT @Result = @Result + ', ' + COLUMN_NAME

             FROM @tmp

             WHERE iSeq = @iMin;

 

             SET @iMin = @iMin + 1;

       END

 

       SELECT @Result;

END;

GO

exec sp_MS_marksystemobject 'sp_HelpColumnNameWithComma'

GO

 

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

-- Auth : splee

-- Date : 20090903

-- Desc : 선택한keyword가이름인TableDescription과컬럼의Description을출력한다.

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

CREATE PROCEDURE sp_HelpTableDescription

       @TableName varchar(256)

AS

BEGIN

       SELECT sys.objects.name [Table name]

             , ISNULL(CONVERT(varchar(1024), sys.extended_properties.value), '') [Table description]

       FROM sys.objects with (nolock)

             LEFT OUTER JOIN sys.extended_properties with (nolock) 

                    ON (sys.objects.object_id = sys.extended_properties.major_id)

                    AND (sys.extended_properties.minor_id = 0)

       WHERE sys.objects.name = @TableName AND type_desc = 'USER_TABLE'

       ORDER BY 1

 

       SELECT uvCol.name [Column name]

             , uvType.name [Data type]

             , uvCol.max_length [Length]

             , uvCol.is_nullable [Nullable]

             , CONVERT(varchar(2048), uvProperty.value) [Column description]

       FROM sys.columns uvCol with (nolock)

             LEFT OUTER JOIN sys.types uvType with (nolock)

                    ON uvCol.user_type_id = uvType.user_type_id

             LEFT OUTER JOIN sys.extended_properties uvProperty with (nolock)

                    ON (uvCol.object_id = uvProperty.major_id) AND (uvCol.column_id = uvProperty.minor_id)

       WHERE uvCol.object_id =

             (

             SELECT object_id

             FROM sys.objects with (nolock)

             WHERE name = @TableName AND type_desc = 'USER_TABLE'

             )

       ORDER BY uvCol.column_id ASC

END;

GO

exec sp_MS_marksystemobject 'sp_HelpTableDescription'

GO

 

/*---------------------------------------

Alt + F1 : sp_help (defualt filxed)

Ctrl + F1 : sp_helpIndex

Ctrl + 1 : sp_who (defualt filxed)

Ctrl + 2 : sp_lock (defualt filxed)

Ctrl + 3 : sp_helptext

Ctrl + 4 : sp_HelpColumnNameWithComma

Ctrl + 5 : sp_HelpStoredProcedureName

Ctrl + 6 :

Ctrl + 7 :

Ctrl + 8 :

Ctrl + 9 : sp_HelpTableDescription

Ctrl + 0 :

---------------------------------------*/

 

이외에 sp_lock2 정도를 6번 정도에 사용하는 수도 있습니다..
다른 분들께서는 어떤 기능의 단축키를 사용하시나요??
같이 공유해 보았으면 합니다. ^^





profile