Skip to content

Instantly share code, notes, and snippets.

View nukeguys's full-sized avatar
๐Ÿ’ป

์„ฑ์Šน๊ทœ nukeguys

๐Ÿ’ป
View GitHub Profile
@nukeguys
nukeguys / search_for_sp.sql
Created August 9, 2017 01:02
[search for SP] search for stored procedure via "string" #SP #procedure #search
SELECT OBJECT_NAME(object_id), OBJECT_DEFINITION(object_id)
FROM sys.procedures
WHERE OBJECT_DEFINITION(object_id) LIKE '%์ฐพ์„ ๋‚ด์šฉ%'
@nukeguys
nukeguys / extract_sp_list.sql
Last active June 14, 2018 02:10
[extract SP list] extract stored procedure list to html format #SP #extract #list
/*
SP์ถ”์ถœ
*/
--๋ณ€์ˆ˜
DECLARE @SqlVersion AS CHAR(4)
DECLARE @maxi AS INT , @maxj AS INT
DECLARE @i AS INT , @j AS INT
DECLARE @Output VARCHAR(4000),@description VARCHAR(4000)
CREATE TABLE #Tables (id int identity(1, 1), Object_id int, name varchar(155), type varchar(20), [definition] varchar(MAX))
@nukeguys
nukeguys / tip_proc.sql
Last active August 17, 2017 07:33
[TIP_PROC] tips for procedure #tip #procedure
-- procedure ์ƒ์—์„œ decrypt
DBO.UF_DEC_MRM(ํœด๋Œ€์ „ํ™”๋ฒˆํ˜ธ)
CONVERT(VARCHAR(100), DECRYPTBYKEY(ํœด๋Œ€์ „ํ™”๋ฒˆํ˜ธ))
-- SDA ์ž๋ฃŒ๋ถ„์„ ์ž‘์„ฑ์‹œ parameter ์ œ๊ฑฐ
@DataSection1 VARCHAR(50) = NULL
@nukeguys
nukeguys / tip_git.sh
Last active August 28, 2017 09:12
[TIP_GIT] tips for git #git #tip
# Delete Remote Branch
git push origin --delete <branch_name>
git push origin :<branch_name>
# To list all unstaged tracked changed files
git diff --name-only
# To list all staged tracked changed files
git diff --name-only --staged
@nukeguys
nukeguys / inquire_sql_history.sql
Created August 23, 2017 09:31
[inquire SQL history] inquire excuted query history #inquire #history
-- ref. http://mkklab.tistory.com/7
-- Microsoft SQL Server Management Studio์—์„œ ์ง์ ‘ ์‹คํ–‰ํ–ˆ๋˜ ์ฟผ๋ฆฌ๋“ค๋งŒ ๋ณด์—ฌ์ค€๋‹ค.
SELECT
db_name(st.dbid) DBName,
object_schema_name(objectid, st.dbid) SchemaName,
object_name(objectid, st.dbid) SPName,
qs.total_elapsed_time,
creation_time,
last_execution_time,
@nukeguys
nukeguys / tip_mssql.sql
Last active April 30, 2018 06:59
[TIP_MSSQL] tips for mssql #tip #mssql #helptext #depends #refreshview
-- ref. https://msdn.microsoft.com/ko-kr/library/ms176007(v=sql.90).aspx
-- ref. sys.sql_dependencies
-- object์˜ ์ •์˜
exec sp_helptext N'NAME'
-- object์˜ ์ข…์†์„ฑ ์ •๋ณด in current DB
exec sp_depends N'NAME'
-- view์˜ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ์—…๋ฐ์ดํŠธ
@nukeguys
nukeguys / update_all_views_that_have_dependencies_on_a_changed_object.sql
Created August 23, 2017 11:43
[update all views that have dependencies on a changed object] update all views that have dependencies on a changed object #update #view #dependency
SELECT DISTINCT 'EXEC sp_refreshview ''' + name + ''''
FROM sys.objects so INNER JOIN sys.sql_dependencies sd
ON so.object_id = sd.object_id
WHERE type = 'V'
AND sd.referenced_major_id = object_id('OBJECT_NAME')
@nukeguys
nukeguys / datetime.sql
Last active January 2, 2018 02:09
[DATETIME] tips for datetime #tip #mssql #datetime
-- https://docs.microsoft.com/ko-kr/sql/t-sql/functions/cast-and-convert-transact-sql#date-and-time-styles
SELECT CONVERT(VARCHAR, GETDATE(), 120)
-- ์ง€์ •๋œ ๋‘ ๋‚ ์งœ๋ฅผ ๋”ํ•˜์—ฌ ์ƒˆ ๋‚ ์งœ๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
SELECT DATENAME(๋‚ ์งœ๋ถ€๋ถ„, ๋‚ ์งœ)
-- ๋‘ ๋‚ ์งœ ์‚ฌ์ด์˜ ๊ฐ„๊ฒฉ์„ ๊ณ„์‚ฐํ•˜์—ฌ ์ง€์ •๋œ ๋‹จ์œ„(์‹œ๊ฐ„, ์ผ, ์ฃผ ๋“ฑ)๋กœ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
SELECT DATEDIFF(๋‚ ์งœ๋ถ€๋ถ„,์‹œ์ž‘๋‚ ์งœ, ์ข…๋ฃŒ๋‚ ์งœ)
-- ์ง€์ •ํ•œ ๋‚ ์งœ ๋ถ€๋ถ„์„ ๋ฌธ์ž์—ด๋กœ ๋ฐ˜ํ™˜ํ•œ๋‹ค.