Advertisement
bdill

Reserved_Keywords.sql

Nov 3rd, 2020 (edited)
3,299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 3.16 KB | None | 0 0
  1. -- Desc: See if any objects are using reserved keywords
  2. -- License: ShoutOutWare - give me a shout out on Twitter @bdill if this script helped you. :)
  3. -- Auth: Brian Dill 2020-11-30
  4. -- Script home: https://pastebin.com/YVRu4NpW
  5. -- Other useful files: https://pastebin.com/u/bdill (scripts, data files, etc.)
  6.  
  7.  
  8. DROP TABLE #tmpReservedWords
  9. CREATE TABLE #tmpReservedWords ( val VARCHAR(100) )
  10.  
  11. INSERT INTO #tmpReservedWords VALUES ('ADD'), ('EXTERNAL'), ('PROCEDURE'), ('ALL'), ('FETCH'), ('PUBLIC'), ('ALTER')
  12. , ('FILE'), ('RAISERROR'), ('AND'), ('FILLFACTOR'), ('READ'), ('ANY'), ('FOR'), ('READTEXT'), ('AS'), ('FOREIGN')
  13. , ('RECONFIGURE'), ('ASC'), ('FREETEXT'), ('REFERENCES'), ('AUTHORIZATION'), ('FREETEXTTABLE'), ('REPLICATION')
  14. , ('BACKUP'), ('FROM'), ('RESTORE'), ('BEGIN'), ('FULL'), ('RESTRICT'), ('BETWEEN'), ('FUNCTION'), ('RETURN')
  15. , ('BREAK'), ('GOTO'), ('REVERT'), ('BROWSE'), ('GRANT'), ('REVOKE'), ('BULK'), ('GROUP'), ('RIGHT'), ('BY')
  16. , ('HAVING'), ('ROLLBACK'), ('CASCADE'), ('HOLDLOCK'), ('ROWCOUNT'), ('CASE'), ('IDENTITY'), ('ROWGUIDCOL')
  17. , ('CHECK'), ('IDENTITY_INSERT'), ('RULE'), ('CHECKPOINT'), ('IDENTITYCOL'), ('SAVE'), ('CLOSE'), ('IF')
  18. , ('SCHEMA'), ('CLUSTERED'), ('IN'), ('SECURITYAUDIT'), ('COALESCE'), ('INDEX'), ('SELECT'), ('COLLATE')
  19. , ('INNER'), ('SEMANTICKEYPHRASETABLE'), ('COLUMN'), ('INSERT'), ('SEMANTICSIMILARITYDETAILSTABLE'), ('COMMIT')
  20. , ('INTERSECT'), ('SEMANTICSIMILARITYTABLE'), ('COMPUTE'), ('INTO'), ('SESSION_USER'), ('CONSTRAINT'), ('IS')
  21. , ('SET'), ('CONTAINS'), ('JOIN'), ('SETUSER'), ('CONTAINSTABLE'), ('KEY'), ('SHUTDOWN'), ('CONTINUE'), ('KILL')
  22. , ('SOME'), ('CONVERT'), ('LEFT'), ('STATISTICS'), ('CREATE'), ('LIKE'), ('SYSTEM_USER'), ('CROSS'), ('LINENO')
  23. , ('TABLE'), ('CURRENT'), ('LOAD'), ('TABLESAMPLE'), ('CURRENT_DATE'), ('MERGE'), ('TEXTSIZE'), ('CURRENT_TIME')
  24. , ('NATIONAL'), ('THEN'), ('CURRENT_TIMESTAMP'), ('NOCHECK'), ('TO'), ('CURRENT_USER'), ('NONCLUSTERED'), ('TOP')
  25. , ('CURSOR'), ('NOT'), ('TRAN'), ('DATABASE'), ('NULL'), ('TRANSACTION'), ('DBCC'), ('NULLIF'), ('TRIGGER')
  26. , ('DEALLOCATE'), ('OF'), ('TRUNCATE'), ('DECLARE'), ('OFF'), ('TRY_CONVERT'), ('DEFAULT'), ('OFFSETS'), ('TSEQUAL')
  27. , ('DELETE'), ('ON'), ('UNION'), ('DENY'), ('OPEN'), ('UNIQUE'), ('DESC'), ('OPENDATASOURCE'), ('UNPIVOT'), ('DISK')
  28. , ('OPENQUERY'), ('UPDATE'), ('DISTINCT'), ('OPENROWSET'), ('UPDATETEXT'), ('DISTRIBUTED'), ('OPENXML'), ('USE')
  29. , ('DOUBLE'), ('OPTION'), ('USER'), ('DROP'), ('OR'), ('VALUES'), ('DUMP'), ('ORDER'), ('VARYING'), ('ELSE'), ('OUTER')
  30. , ('VIEW'), ('END'), ('OVER'), ('WAITFOR'), ('ERRLVL'), ('PERCENT'), ('WHEN'), ('ESCAPE'), ('PIVOT'), ('WHERE')
  31. , ('EXCEPT'), ('PLAN'), ('WHILE'), ('EXEC'), ('PRECISION'), ('WITH'), ('EXECUTE'), ('PRIMARY'), ('WITHIN GROUP')
  32. , ('EXISTS'), ('PRINT'), ('WRITETEXT'), ('EXIT'), ('PROC')
  33.  
  34. SELECT * FROM sys.tables WHERE [name] IN ( SELECT val FROM #tmpReservedWords )
  35.  
  36. SELECT * FROM sys.views WHERE [name] IN ( SELECT val FROM #tmpReservedWords )
  37.  
  38. SELECT * FROM sys.procedures WHERE [name] IN ( SELECT val FROM #tmpReservedWords )
  39.  
  40. SELECT * FROM sys.objects WHERE type IN ('FN', 'IF', 'TF') AND [name] IN ( SELECT val FROM #tmpReservedWords )
  41.  
  42. DROP TABLE #tmpReservedWords
  43.  
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement