├── .editorconfig ├── .gitattributes ├── .github ├── FUNDING.yml └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Development Application Settings ├── Microsoft │ └── SQL Server Management Studio │ │ ├── Code Snippets │ │ └── SLASH STAR COMMENT (surrounds).snippet │ │ └── General Settings │ │ └── SSMS.vssettings └── Red Gate │ └── SQL Prompt │ ├── Code Analysis Rules │ └── CodeAnalysisSettings.casettings │ ├── General Settings │ └── Prompt.settings │ ├── Snippets │ ├── AzDBRestoreStatus-994ccf57-8872-4852-b022-cb687b391b68.json │ ├── EveryTableColumnDataType-e89a9ebc-8f4b-42df-87ac-f384ffb3de4b.json │ ├── LongestDataLength-15a13d48-b02e-4617-b8db-df2edfb6ab5a.json │ ├── TemporalTableCompressedCheck-84f815aa-9a04-4682-823e-d4e1d08c20b4.json │ ├── ac-5fbb148a-1d62-4ddf-90c4-1859daf90492.json │ ├── af-b3c80997-d675-471d-97f9-d167ccebb5c0.json │ ├── alert-714a58ce-272e-444d-a4d1-ba7ed9406d76.json │ ├── ap-317d6604-fdf3-4d92-9b93-e8e8dd3b7356.json │ ├── at-c50bb30b-e175-4f1b-9b4e-53099b69b075.json │ ├── ata-8e82fdf5-5ce0-4f9e-9419-41d9bac36c34.json │ ├── atac-0e5c57be-ba55-47f6-b8ea-a81ee6d9030d.json │ ├── atd-45fcfff5-a6e4-41d3-9cdc-b4c8d21bbb5a.json │ ├── atdc-ef215adf-06dc-4dd9-b05d-d35edd9d79f3.json │ ├── atdt-39c3acc5-3fd1-46a7-9fc9-b182f113c96e.json │ ├── atdta-040229ea-7d7c-4957-b263-09734c12e1f2.json │ ├── atet-c4e0d22d-244e-4ef3-980a-00b807ab014d.json │ ├── ateta-8ab5469b-82ad-488e-98d7-530a634e6127.json │ ├── azopenrowset-2a2624ed-a934-4582-aa9a-6056df361db8.json │ ├── azscale-e87e077b-daf4-44d9-b183-9ab230059201.json │ ├── be-be27a73c-15fb-40dd-992d-9b05c0f54d64.json │ ├── bt-5e72be93-a6a3-446d-8c84-3b398ba58fdd.json │ ├── buf-7363fb6d-c728-4633-ae8d-464db1b80a4e.json │ ├── ccc-50a0db4d-a380-4898-a48e-e5f42233ef43.json │ ├── cci-36278968-93e7-4d9b-8e58-2a2f1df054f2.json │ ├── cdb-3cb0e0f2-0461-4048-820a-29632d0d5d31.json │ ├── cdbsnap-0fb515a5-2832-42e0-829a-3cfffe271abd.json │ ├── chk-f7f6b91b-4bc5-4d05-b627-b3ebed72232d.json │ ├── citf-ec65b7c5-2414-43ed-9514-faf11e123f08.json │ ├── cj-df805520-f59a-4333-ade3-761407505ac7.json │ ├── cl-de1fcf2e-4436-43a5-b208-ad49668e6dbb.json │ ├── clrp-99f1f2b4-6aee-4464-9cd1-ee96479de411.json │ ├── cmtblock-2c1ab9f3-421d-4839-8edb-fb50237651da.json │ ├── cmtline-7b5e5616-b404-41ee-baa8-b81d1316c2ac.json │ ├── cni-dfb60004-dd04-40db-9ff2-95d5f546f28c.json │ ├── cnt-1a01e74c-824e-4bef-92c6-e21644ed67b5.json │ ├── cp-d6aa947d-5636-4e53-a16a-d93d3c8255da.json │ ├── cseq-760a95b9-a6ef-4f94-b8fc-abea54787b2e.json │ ├── csf-57a707fd-2c95-4d27-964e-7b27fb5c2bcb.json │ ├── ct-d549e06d-2453-49f7-bf1c-8f9249e7072a.json │ ├── cte-a745034e-2cd6-4a08-b825-d80860bf98ca.json │ ├── ctf-6121a3bc-5c5d-48b6-ba04-680806f5d1ee.json │ ├── ctr-cfd1e9b0-7af2-4602-99af-fe239f6e75f8.json │ ├── ctt-a9ba3e1d-9d41-4f84-8d68-b59019d59077.json │ ├── cu-c9cc9091-91d1-4966-b4ba-655a34678f4a.json │ ├── cuci-90333136-a90f-4278-9fa3-e7f1cc01c1c2.json │ ├── cuni-976195ca-f9c1-4f1f-97fe-3e0c56a27fdd.json │ ├── curff-9bfcd873-5e2a-4a35-8b6c-5363f02bbf79.json │ ├── cv-5a7bc141-ae05-46f7-bc7b-654bbdf9d302.json │ ├── cw-b8412917-d95e-4eb2-8871-c1caecb18ad5.json │ ├── dd-8839c31f-0191-4f17-a822-8197e969d959.json │ ├── df-6fe464bb-14c1-4fc7-8e30-aa2dce4b3755.json │ ├── dfn-62721689-d5c0-4a8b-8096-ca1361001364.json │ ├── di-fd7cafcd-3362-4934-889b-88b3434d5b90.json │ ├── dl-76d104c4-42bd-4448-b8ed-2f6e454dc04d.json │ ├── dp-6fb0ddaf-f731-45a0-a10c-f9395fca7723.json │ ├── dseq-02c73dcc-abe9-4ec5-a90e-2e19eac421c8.json │ ├── dt-1b026389-cf7e-4cdd-9881-bd21828f02ab.json │ ├── du-d425e16b-0feb-482a-b44e-daba985c1b1a.json │ ├── dupk-914a3407-dc4b-4d7e-afc7-a180d7d4a291.json │ ├── dv-8116bed6-529b-409e-a2dd-78a380376553.json │ ├── eata-07c49a65-a060-4180-8cf5-524474d6270a.json │ ├── err-dceff8fe-5df0-4bfd-86dd-fe84f76ad6e9.json │ ├── fj-713fd209-a910-418e-981d-235de0de55d3.json │ ├── fk-f309d072-0ad3-40cf-bcf9-b136a61b148b.json │ ├── foff-caf93e3a-bef2-4318-a41a-1f6f9719b5ab.json │ ├── foj-7dd9edfb-75aa-4e47-a7dc-4e89a7d7d1dc.json │ ├── fon-22a709a0-2328-4f8b-b9ba-04adb5c89d96.json │ ├── gb-88eacacc-c05b-45dc-ba54-4faf14bb830c.json │ ├── gep-286dca70-9277-4472-b6f1-128d94501f07.json │ ├── git-330dccdd-60ce-49d8-81ba-bc11894d6c41.json │ ├── giust-77a84a71-9144-42bc-b25c-47ab69c89e0b.json │ ├── gst-a70223e6-d8d9-4a7b-88a2-5d6561d155cd.json │ ├── gut-370af63d-1578-4eb9-aa58-1a24834e5114.json │ ├── header-e31a0b75-d45a-4c8d-b0fe-ed89eb7378c6.json │ ├── hhmm-35b3d645-ecae-4082-a129-43e36557d549.json │ ├── ida-4b1199ef-ec27-40ef-8490-7d6317dcf4a7.json │ ├── idf-ccf88047-11ba-4e2b-8dcc-59c31ac4a28f.json │ ├── idl-e309d0b6-7881-4f6c-9276-8f0884c2db49.json │ ├── idp-ccfabdf7-c0f6-4fdc-b55a-dd8c42f0fc36.json │ ├── ids-c7063adf-598a-48f1-a39b-8b0263873188.json │ ├── idt-08ee8abe-ac13-4ebe-a3a0-dd5b7d780926.json │ ├── idtr-d1b02a3b-27ca-43be-a726-72f214f823ac.json │ ├── idu-d190a9c3-8141-4a89-8cb6-802befbcbacd.json │ ├── idv-0e250b2b-5e69-49cb-94d8-756e776cd599.json │ ├── ifs-e2036955-99d3-490f-81bc-f7d3ecb61b69.json │ ├── ii-abf2ee0e-791e-4815-b315-9b2ae3239a45.json │ ├── ij-8117ea6f-51f6-4099-aa52-a6366e73eafd.json │ ├── inn-5640d594-ec8d-4459-b996-20d5a58174d4.json │ ├── is-b053855e-a834-4f4f-b334-3784278354b0.json │ ├── isc-5c8bd23f-bb77-4ffa-8995-fd7e79c8f8c1.json │ ├── isns-c85d2975-4de8-4b3a-8b21-cf28d762ebcd.json │ ├── j-00d1410e-79cf-4d75-bf79-0c8ce5249612.json │ ├── lin-5b4717ca-f6e3-4cd9-b9f0-cebef0a00601.json │ ├── linn-7a2faf46-fa85-4f47-9009-35cd71d0be06.json │ ├── lj-c334dacb-9403-4388-b212-ad397d1f7a86.json │ ├── lk-3f5f2f0a-75af-42ca-8d3b-89abf9ce29ab.json │ ├── loj-556b9599-3526-4891-ac9a-dad2081ba1c9.json │ ├── mmddyyyy-d1b754e5-16bf-4f1f-a0d7-233f3d15d4c5.json │ ├── mmddyyyyhhmm-add4cbf9-cf13-4e71-a8bb-c717acf3a1b4.json │ ├── mro-9f4793b9-82ac-4b2f-b8d2-04121ce04202.json │ ├── num-b62377c6-24e5-412b-8323-6c8eba37990d.json │ ├── numc-9f61ad71-b9e4-45bb-8700-f139fcaa275f.json │ ├── nvseq-eecdc143-2087-44a7-80b6-aacdc62312d0.json │ ├── ob-bc85e3d9-27d6-43be-aff2-21413bf476d3.json │ ├── per-a43b59b0-1e21-4de5-8340-2f964dff6a4c.json │ ├── profiler-4da70a5d-526d-4656-b45a-53dbf5a9d58d.json │ ├── pvt-48864df4-c52a-4265-ba34-1a475cf9a092.json │ ├── rj-97c9a8ef-fae2-4d91-9cb5-bf1329f04404.json │ ├── rnum-7e12b596-6b70-44bb-ba33-735a17d3e8c4.json │ ├── roj-6b6ec907-f87e-4c08-aca1-e0f61e5ca9cc.json │ ├── rt-fc3d2f65-85d4-40ab-9dc3-21ba593e9ab4.json │ ├── san-6654906d-f2ec-400d-be64-3e45afff3ed8.json │ ├── scf-3efeb915-d830-4c47-9056-2518d771cb8f.json │ ├── sd-e03a2401-dbaf-4017-b1b7-3b541a20b2a3.json │ ├── setvar-3b5a7fe2-bda9-473b-abbc-48f72272eb60.json │ ├── smf-cefe535f-adae-47e9-b329-6df61ec5f92f.json │ ├── sph-82a89101-2cdb-48ad-a059-5a791958f399.json │ ├── spt-51290a9c-5955-4f7f-bc38-b1bf150408be.json │ ├── sqi-722928c6-e62c-4e24-95bc-c53b8ee20af4.json │ ├── ss0-d2e91135-a38b-4aac-91e1-5137fc3bf81f.json │ ├── ssf-da5bee9a-e757-41e7-a55c-b13ff0080ac9.json │ ├── ssf2-5e77e99a-6563-4184-9d6a-85b0d00f3384.json │ ├── sst-4b208cf2-995f-41ac-9883-ff9ad9790b54.json │ ├── st100-a0f36423-8b7e-432b-8abb-94fa37f82122.json │ ├── strip-ee654fea-7302-4cea-be9d-dc219d65c579.json │ ├── sxa-fa1005d3-b116-4f79-aae4-a7004fdaedb8.json │ ├── tab-9b7accb0-9b99-4e8b-875c-85b59003e98a.json │ ├── tac-b02f94ad-b956-478c-8ce9-7e12e1e0cd7d.json │ ├── tal-c5da142c-49b6-4685-9897-d0cf15ab64eb.json │ ├── tat-988f529c-7926-427b-b244-1aaacbd8bf41.json │ ├── tc-5b72fd4a-4fe0-41f8-ac20-3e187d7ff805.json │ ├── tca-41af3a3e-7ac3-4956-b829-c150c40ec7d1.json │ ├── tce-652a18d3-44ac-4f7f-b874-e3ae4d27fc19.json │ ├── tco-d482823f-9db6-4b4e-b5bf-7a4e638ac197.json │ ├── tct-da925080-ff0e-4d4b-9ac7-b7c1216b69a4.json │ ├── te-9dc51561-fbd0-48d2-ac5f-65e662216b8f.json │ ├── tes-31eb4d04-d6af-4896-b876-299ea1801285.json │ ├── tet-31701e8b-b14d-44ed-b830-92729f6e5dcd.json │ ├── tf-6e743807-1b8e-47a8-8b9d-bea4eae4da2a.json │ ├── tff-9cda5178-8ac7-4ce7-9130-26095e1f18f8.json │ ├── tft-2d8c5136-2612-4360-a3d1-a76c0d4f4262.json │ ├── tie-0c94bf8a-c3e1-4291-b33e-82f9d1bf32e3.json │ ├── timings-7d383e40-1a19-486e-957e-ccafc12e2309.json │ ├── tmt-07a9ca4a-7a46-4d48-b769-458dfb67c936.json │ ├── tnc-15a24b82-208b-4d01-a3d2-6d0bf68519a9.json │ ├── tne-f07f828e-5e54-4631-9ff3-bf66a155053e.json │ ├── tnt-f18d091b-ba00-4485-ad31-f28705162c40.json │ ├── today-a03dee51-9fe5-4a93-a8d0-1b41e9a92cd6.json │ ├── toe-f9e123af-79cf-4755-a61a-5e1431f74c89.json │ ├── tpc-cec1a30a-2c83-44a9-90de-cd529921d095.json │ ├── trf-db5a83c1-3d10-49d9-86af-0bc433b9e6d6.json │ ├── trim-dc639ce6-2362-496b-ba66-dd244381b366.json │ ├── trims-7e909586-9924-4eb8-84b2-613a707eea83.json │ ├── trn-5ba594b3-5c5b-4644-836c-ad77f78c3de5.json │ ├── tro-364d732f-df4e-4f0b-9969-7394e2e8badb.json │ ├── tso-d2cf62bc-246d-4d29-896d-4685a791c63c.json │ ├── tsp-557e6746-23a5-4ac0-8620-3a930a0df08e.json │ ├── tt-0c7e21b2-0c24-4847-870f-696b07f72a00.json │ ├── tvc-fc6f60d1-0637-4786-8223-e9bb81f9d92a.json │ ├── txe-4c563904-edde-48d9-ade3-5f294ab301da.json │ ├── txn-22b5775e-43a9-453a-a8ee-c1ba1014252d.json │ ├── txp-457a18fb-aac4-4c8f-8d37-389c64e9452d.json │ ├── uci-1d8d3e81-30d3-4cab-9e85-be8a845817ef.json │ ├── w2-8d1cfff9-3850-46d2-b6ed-99376104e804.json │ ├── wdc-9691418f-fb24-4824-937c-3e9ce3cd544e.json │ ├── wn-1f487fd4-2350-4846-aac5-ce856c4df6c3.json │ ├── wt-b3c14629-861f-48e0-95ed-dbb2e5a3d185.json │ └── xpfd-df4b3d19-aa14-43ad-8b27-7fd6963ec199.json │ └── Styles │ ├── Kevin Martin-b9530d2c-850d-46b0-b8b4-51a5899a376e.json │ ├── Team Collapsed-fcb648ec-57c1-48f9-a40f-d3e81de7b8de.json │ └── Team Expanded-6d4cd025-b548-497f-bf21-3d5c64111b1f.json ├── Images ├── Mixing_Data_Types_in_JOIN_or_WHERE_Clauses.png ├── Non-SARGable Does Not Get Index Recommendation.png ├── Using_a_Non-SARGable_Expression_in_a_WHERE_Clause.png ├── sp_Develop - Emergent Software - SQL Server Assess - GitHub Open Graph.png ├── sp_Develop - Emergent Software - SQL Server Assess - LinkedIn Profile Background.png ├── sp_Develop - Emergent Software - SQL Server Assess - Twitch Profile Banner.png ├── sp_Develop - Emergent Software - SQL Server Assess - Twitch Video Player Banner Offline.png ├── sp_Develop - Emergent Software - SQL Server Assess - Twitter Header.png └── sp_Develop_Results.png ├── LICENSE.md ├── README.md ├── SECURITY.md ├── Test Database ├── Custom Scripts │ └── Post-Deployment │ │ └── PostScript.sql ├── Data │ └── dbo.UnencryptedData_Data.sql ├── Filter.scpf ├── Functions │ ├── DBA.fnPrefixNameTableValuedFunctionSkipMe.sql │ ├── DBA.fn_PrefixNameSkipMe.sql │ ├── dbo.MulitStatement.sql │ ├── dbo.NonInlineable.sql │ ├── dbo.fnPrefixNameTableValuedFunction.sql │ └── dbo.fn_PrefixName.sql ├── RedGate.ssc ├── RedGateDatabaseInfo.xml ├── Security │ └── Schemas │ │ ├── DBA.sql │ │ └── Schema_Including_$pecial_Characters_in_Name.sql ├── Stored Procedures │ ├── DBA.spPrefixNameSkipMe.sql │ ├── dbo.DoNotLock1Get.sql │ ├── dbo.DoNotLock2Get.sql │ ├── dbo.DoNotLock3Get.sql │ ├── dbo.DoNotLock4Get.sql │ ├── dbo.HardcodedDatabaseNameReference.sql │ ├── dbo.NoSetNocountUsed.sql │ ├── dbo.SelectEverything.sql │ ├── dbo.SelectEverything10.sql │ ├── dbo.SelectEverything2.sql │ ├── dbo.SelectEverything3.sql │ ├── dbo.SelectEverything4.sql │ ├── dbo.SelectEverything5.sql │ ├── dbo.SelectEverything6.sql │ ├── dbo.SelectEverything7.sql │ ├── dbo.SelectEverything8.sql │ ├── dbo.SelectEverything9.sql │ ├── dbo.SelectEverythingWithIfExists.sql │ ├── dbo.SetOptions.sql │ ├── dbo.spPrefixName.sql │ ├── dbo.sp_PrefixName.sql │ └── dbo.usp_PrefixName.sql ├── Tables │ ├── DBA.DevelopCheckToSkip.sql │ ├── DBA.IDPrimaryKeyColumnNameSkipMe.sql │ ├── dbo.(ContainsIllegalCharacters).sql │ ├── dbo.1StartsWithANumber.sql │ ├── dbo.ColumnCollationDifferent.sql │ ├── dbo.ColumnSameAsTable.sql │ ├── dbo.DataType.sql │ ├── dbo.DisabledIndex.sql │ ├── dbo.FalsePositiveStatus.sql │ ├── dbo.ForeignKeyMissing.sql │ ├── dbo.GenericOrClassWord.sql │ ├── dbo.HypotheticalIndex.sql │ ├── dbo.IDPrimaryKeyColumnName.sql │ ├── dbo.LowIndexFillFactor.sql │ ├── dbo.NamingForeignKeyRelationship.sql │ ├── dbo.Newspaper.sql │ ├── dbo.NewspaperReader.sql │ ├── dbo.NoPrimaryKey.sql │ ├── dbo.Number2020.sql │ ├── dbo.Procedure.sql │ ├── dbo.Reader.sql │ ├── dbo.SelectEverythingTrigger.sql │ ├── dbo.TemporalTable.sql │ ├── dbo.TriggerUse.sql │ ├── dbo.UNIQUEIDENTIFIERClusteredIndex.sql │ ├── dbo.UnderScore_Name.sql │ ├── dbo.UnencryptedData.sql │ ├── dbo.UniqueConstraint.sql │ ├── dbo.Untrusted.sql │ ├── dbo.Users.sql │ ├── dbo.Wide.sql │ ├── dbo.tStore.sql │ └── dbo.tblPhone.sql ├── Types │ └── User-defined Data Types │ │ ├── dbo.SSN.sql │ │ ├── dbo.udPhone.sql │ │ └── dbo.ud_Price.sql └── Views │ ├── DBA.vPhoneSkipMe.sql │ ├── dbo.vHardcodedDatabaseNameReference.sql │ ├── dbo.vPhone.sql │ └── dbo.vwPhones.sql ├── docs ├── Contact.md ├── DevelopmentAppSettings.md ├── HowToSkipChecks.md ├── Images │ ├── JOIN_Elimination_NOT_NULL.png │ ├── JOIN_Elimination_NULL.png │ ├── Mixing_Data_Types_in_JOIN_or_WHERE_Clauses.png │ ├── Non-SARGable_Does_Not_Get_Index_Recommendation.png │ ├── Not_Using_Location_Comment_Statement_Parent.png │ ├── UNIQUEIDENTIFIER_For_Primary_Key.png │ ├── Using_a_Non-SARGable_Expression_in_a_WHERE_Clause.png │ └── sp_Develop_Results.png ├── InstallInstruction.md ├── ParameterExplanations.md ├── ResultsExplanations.md ├── TestDatabaseInstall.md ├── UsageInstructions.md ├── _config.yml ├── favicon.ico ├── findings │ ├── ConfigurationIssues.md │ ├── CurrentHighCheckId.md │ ├── DataIssues.md │ ├── DataTypeConventions.md │ ├── Index.md │ ├── NamingConventions.md │ ├── RunningIssues.md │ ├── SQLCodeDevelopment.md │ └── TableConventions.md └── index.md └── sp_Develop.sql /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 4 7 | end_of_line = crlf 8 | charset = utf-8 9 | 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | 13 | [*.md] 14 | trim_trailing_whitespace = false 15 | insert_final_newline = false 16 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # T-SQL files 2 | *.sql text 3 | 4 | # linguist overrides 5 | *.sql linguist-language=TSQL 6 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Version of the script** 11 | Look in the stored procedure, and it'll have a version date & number near the top. Put that in here. If it's not the current version (dated in the last month), then upgrade to the current version and test that before reporting a bug - we fix a lot of stuff in each new build. We'll flat out close bug reports for older builds. 12 | 13 | 14 | **What is the Check Id?** 15 | 16 | 17 | **What is the current behavior?** 18 | 19 | 20 | **If the current behavior is a bug, please provide the steps to reproduce.** 21 | 22 | 23 | **What is the expected behavior?** 24 | 25 | 26 | **Which versions of SQL Server and which OS are affected by this issue? Did this work in previous versions of our procedures?** 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | 14 | **Describe the solution you'd like** 15 | A clear and concise description of what you want to happen. 16 | 17 | 18 | **Describe alternatives you've considered** 19 | A clear and concise description of any alternative solutions or features you've considered. 20 | 21 | 22 | **Are you ready to build the code for the feature?** 23 | As much as we'd love to build everything that everyone wants for free, we need your help. Open source is built with your help and code. Are you ready to commit time to this project? Have you got existing code you can help contribute to solve the problem? 24 | -------------------------------------------------------------------------------- /Development Application Settings/Microsoft/SQL Server Management Studio/Code Snippets/SLASH STAR COMMENT (surrounds).snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | <_locDefinition xmlns="urn:locstudio"> 4 | <_locDefault _loc="locNone" /> 5 | <_locTag _loc="locData">Title 6 | <_locTag _loc="locData">Description 7 | <_locTag _loc="locData">Author 8 | <_locTag _loc="locData">ToolTip 9 | <_locTag _loc="locData">Default 10 | 11 | 12 |
13 | SLASH STAR COMMENT (surrounds) 14 | 15 | Surround selected text with slash star comment block /**/ 16 | wBob 17 | 18 | SurroundsWith 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
32 |
-------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Code Analysis Rules/CodeAnalysisSettings.casettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | false 4 | true 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | ^THROW$ 19 | 20 | 21 | 22 | Warning 23 | Warning 24 | Warning 25 | Warning 26 | Warning 27 | Warning 28 | Warning 29 | Warning 30 | Warning 31 | Warning 32 | Warning 33 | Warning 34 | Warning 35 | Warning 36 | Warning 37 | Warning 38 | Ignore 39 | Warning 40 | Warning 41 | Warning 42 | Warning 43 | Warning 44 | Warning 45 | Warning 46 | Warning 47 | Warning 48 | Warning 49 | Warning 50 | Warning 51 | Warning 52 | Warning 53 | Warning 54 | Warning 55 | Warning 56 | Warning 57 | Warning 58 | Warning 59 | Warning 60 | Warning 61 | Warning 62 | Warning 63 | Warning 64 | Warning 65 | Warning 66 | Warning 67 | Warning 68 | Warning 69 | Warning 70 | Warning 71 | Warning 72 | Warning 73 | Warning 74 | Warning 75 | Warning 76 | Warning 77 | Warning 78 | Warning 79 | Warning 80 | Warning 81 | Warning 82 | Warning 83 | Warning 84 | Warning 85 | Warning 86 | Warning 87 | Warning 88 | Warning 89 | Warning 90 | Warning 91 | Warning 92 | Warning 93 | Warning 94 | Warning 95 | Warning 96 | Warning 97 | Warning 98 | Warning 99 | Warning 100 | Warning 101 | Warning 102 | Warning 103 | Warning 104 | Warning 105 | Warning 106 | Warning 107 | Warning 108 | Ignore 109 | Warning 110 | Warning 111 | Warning 112 | Warning 113 | Warning 114 | Ignore 115 | Warning 116 | 117 | false 118 | 119 | f9a6f2ab-7f36-4c68-9f05-647e5286ef50 120 | -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/General Settings/Prompt.settings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/8787a1a70ccd9933336cffaf98d6b3a92e117eec/Development Application Settings/Red Gate/SQL Prompt/General Settings/Prompt.settings -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/AzDBRestoreStatus-994ccf57-8872-4852-b022-cb687b391b68.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "994ccf57-8872-4852-b022-cb687b391b68", 3 | "prefix": "AzDBRestoreStatus", 4 | "description": "ES: Azure Database Restore Status", 5 | "body": "SELECT\r\n DatabaseName = major_resource_id\r\n ,RestoreState = state_desc\r\n ,PercentComplete = percent_complete\r\n ,StartTime = start_time AT TIME ZONE 'UTC' AT TIME ZONE 'Central Standard Time'\r\n ,LastModifyTime = last_modify_time AT TIME ZONE 'UTC' AT TIME ZONE 'Central Standard Time'\r\n ,ErrorCode = error_code\r\n ,ErrorDescription = error_desc\r\n ,ErrorSeverity = error_severity\r\n ,ErrorState = error_state\r\nFROM\r\n sys.dm_operation_status\r\nWHERE\r\n operation = N'DATABASE RESTORE'\r\nORDER BY\r\n start_time DESC;" 6 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/LongestDataLength-15a13d48-b02e-4617-b8db-df2edfb6ab5a.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "15a13d48-b02e-4617-b8db-df2edfb6ab5a", 3 | "prefix": "LongestDataLength", 4 | "description": "ES: This script help find the longest data value in each of the text columns. Helpful for creating ETL tables.", 5 | "body": "DECLARE @TableName sysname = '.';\r\n\r\nSET NOCOUNT ON;\r\n\r\nDECLARE\r\n @column_id varchar(36)\r\n ,@StringToExecute nvarchar(MAX);\r\n\r\nDROP TABLE IF EXISTS #Receiver;\r\nCREATE TABLE #Receiver (LongestDataLength int NULL);\r\n\r\nDROP TABLE IF EXISTS #Results;\r\nCREATE TABLE #Results (\r\n column_id varchar(36) NOT NULL\r\n ,TableName sysname NOT NULL\r\n ,ColumnName sysname NOT NULL\r\n ,DataType sysname NOT NULL\r\n ,MaxColumnLength varchar(250) NULL\r\n ,LongestDataLength varchar(250) NULL\r\n ,StringToExecute nvarchar(MAX) NULL\r\n);\r\n\r\nINSERT INTO #Results (\r\n column_id\r\n ,TableName\r\n ,ColumnName\r\n ,DataType\r\n ,MaxColumnLength\r\n ,LongestDataLength\r\n ,StringToExecute\r\n)\r\nSELECT\r\n column_id = C.column_id\r\n ,TableName = OBJECT_NAME(C.object_id)\r\n ,ColumnName = C.name\r\n ,DataType = T.name\r\n ,MaxColumnLength = CASE WHEN T.name NOT IN ('varchar', 'nvarchar', 'char', 'nchar', 'sysname')\r\n THEN 'NA'\r\n WHEN C.max_length = -1\r\n THEN 'MAX'\r\n ELSE CAST(C.max_length AS varchar(250))\r\n END\r\n ,LongestDataLength = 'NA'\r\n ,StringToExecute = N'SELECT MAX(LEN(' + C.name + ')) FROM ' + QUOTENAME(OBJECT_SCHEMA_NAME(C.object_id)) + '.' + QUOTENAME(OBJECT_NAME(C.object_id)) + N';'\r\nFROM\r\n sys.columns AS C\r\n INNER JOIN sys.types AS T\r\n ON C.user_type_id = T.user_type_id\r\nWHERE\r\n C.object_id = OBJECT_ID(@TableName);\r\n\r\n\r\nDECLARE LengthCursor CURSOR LOCAL FAST_FORWARD FOR\r\n SELECT column_id, StringToExecute FROM #Results WHERE MaxColumnLength <> 'NA' ORDER BY column_id ASC;\r\n\r\nOPEN LengthCursor;\r\n\r\nFETCH NEXT FROM LengthCursor\r\nINTO\r\n @column_id\r\n ,@StringToExecute;\r\n\r\nWHILE @@FETCH_STATUS = 0\r\n BEGIN\r\n INSERT INTO #Receiver (LongestDataLength)\r\n EXEC sys.sp_executesql @stmt = @StringToExecute;\r\n\r\n UPDATE\r\n #Results\r\n SET\r\n LongestDataLength = (SELECT LongestDataLength FROM #Receiver)\r\n WHERE\r\n column_id = @column_id;\r\n\r\n DELETE FROM #Receiver;\r\n\r\n FETCH NEXT FROM LengthCursor\r\n INTO\r\n @column_id\r\n ,@StringToExecute;\r\n END;\r\nCLOSE LengthCursor;\r\nDEALLOCATE LengthCursor;\r\n\r\nSELECT\r\n TableName\r\n ,ColumnName\r\n ,DataType\r\n ,MaxColumnLength\r\n ,LongestDataLength\r\nFROM\r\n #Results;" 6 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/TemporalTableCompressedCheck-84f815aa-9a04-4682-823e-d4e1d08c20b4.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "84f815aa-9a04-4682-823e-d4e1d08c20b4", 3 | "prefix": "TemporalTableCompressedCheck", 4 | "description": "ES: Check system-versioned temporal tables are page compressed", 5 | "body": "/* This query will list if system-versioned temporal tables are not compressed. \r\n By default, the history table is PAGE compressed.\r\n You can execute the ALTER TSQL statement to apply page compression. Do not forget to change ONLINE to ON OR OFF.\r\n Redgate Snippet: TemporalTableCompressedCheck\r\n*/\r\nSELECT\r\n SchemaName = S.name\r\n ,TableName = T.name\r\n ,DataCompression = P.data_compression_desc\r\n ,[ALTER TSQL] = N'ALTER INDEX ' + CAST(QUOTENAME(I.name) AS nvarchar(128)) + N' ON ' + CAST(QUOTENAME(S.name) AS nvarchar(128)) + N'.' + CAST(QUOTENAME(T.name) AS nvarchar(128)) + N' REBUILD PARTITION = ALL WITH (STATISTICS_NORECOMPUTE = OFF, ONLINE = ?, DATA_COMPRESSION = PAGE);'\r\nFROM\r\n sys.partitions AS P\r\n INNER JOIN sys.indexes AS I\r\n ON I.object_id = P.object_id\r\n AND I.index_id = P.index_id\r\n INNER JOIN sys.objects AS O\r\n ON I.object_id = O.object_id\r\n INNER JOIN sys.tables AS T\r\n ON O.object_id = T.object_id\r\n INNER JOIN sys.schemas AS S\r\n ON T.schema_id = S.schema_id\r\nWHERE\r\n T.temporal_type = 1 /* HISTORY_TABLE */\r\nAND I.type <> 5 /* CLUSTERED */\r\nAND P.data_compression <> 2 /* Not Page compressed, which is the default for system-versioned temporal tables */\r\nORDER BY\r\n S.name\r\n ,T.name;" 6 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/ac-5fbb148a-1d62-4ddf-90c4-1859daf90492.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "5fbb148a-1d62-4ddf-90c4-1859daf90492", 3 | "name": "ac", 4 | "prefix": "ac", 5 | "description": "ALTER COLUMN", 6 | "body": "ALTER COLUMN ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/af-b3c80997-d675-471d-97f9-d167ccebb5c0.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "b3c80997-d675-471d-97f9-d167ccebb5c0", 3 | "name": "af", 4 | "prefix": "af", 5 | "description": "ALTER FUNCTION", 6 | "body": "ALTER FUNCTION ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/ap-317d6604-fdf3-4d92-9b93-e8e8dd3b7356.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "317d6604-fdf3-4d92-9b93-e8e8dd3b7356", 3 | "name": "ap", 4 | "prefix": "ap", 5 | "description": "ALTER PROCEDURE", 6 | "body": "ALTER PROCEDURE ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/at-c50bb30b-e175-4f1b-9b4e-53099b69b075.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "c50bb30b-e175-4f1b-9b4e-53099b69b075", 3 | "name": "at", 4 | "prefix": "at", 5 | "description": "ALTER TABLE", 6 | "body": "ALTER TABLE ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/ata-8e82fdf5-5ce0-4f9e-9419-41d9bac36c34.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "8e82fdf5-5ce0-4f9e-9419-41d9bac36c34", 3 | "name": "ata", 4 | "prefix": "ata", 5 | "description": "Add column", 6 | "body": "ALTER TABLE $CURSOR$ ADD ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/atac-0e5c57be-ba55-47f6-b8ea-a81ee6d9030d.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "0e5c57be-ba55-47f6-b8ea-a81ee6d9030d", 3 | "name": "atac", 4 | "prefix": "atac", 5 | "description": "Modify column", 6 | "body": "ALTER TABLE $CURSOR$ ALTER COLUMN ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/atd-45fcfff5-a6e4-41d3-9cdc-b4c8d21bbb5a.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "45fcfff5-a6e4-41d3-9cdc-b4c8d21bbb5a", 3 | "name": "atd", 4 | "prefix": "atd", 5 | "description": "Drop column", 6 | "body": "ALTER TABLE $CURSOR$ DROP COLUMN", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/atdc-ef215adf-06dc-4dd9-b05d-d35edd9d79f3.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "ef215adf-06dc-4dd9-b05d-d35edd9d79f3", 3 | "name": "atdc", 4 | "prefix": "atdc", 5 | "description": "Drop constraint", 6 | "body": "ALTER TABLE $CURSOR$ DROP CONSTRAINT ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/atdt-39c3acc5-3fd1-46a7-9fc9-b182f113c96e.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "39c3acc5-3fd1-46a7-9fc9-b182f113c96e", 3 | "name": "atdt", 4 | "prefix": "atdt", 5 | "description": "Disable trigger", 6 | "body": "ALTER TABLE $CURSOR$ DISABLE TRIGGER ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/atdta-040229ea-7d7c-4957-b263-09734c12e1f2.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "040229ea-7d7c-4957-b263-09734c12e1f2", 3 | "name": "atdta", 4 | "prefix": "atdta", 5 | "description": "Disable all triggers on table", 6 | "body": "ALTER TABLE $CURSOR$ DISABLE TRIGGER ALL\nGO", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/atet-c4e0d22d-244e-4ef3-980a-00b807ab014d.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "c4e0d22d-244e-4ef3-980a-00b807ab014d", 3 | "name": "atet", 4 | "prefix": "atet", 5 | "description": "Enable trigger", 6 | "body": "ALTER TABLE $CURSOR$ ENABLE TRIGGER ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/ateta-8ab5469b-82ad-488e-98d7-530a634e6127.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "8ab5469b-82ad-488e-98d7-530a634e6127", 3 | "name": "ateta", 4 | "prefix": "ateta", 5 | "description": "Enable all triggers on table", 6 | "body": "ALTER TABLE $CURSOR$ ENABLE TRIGGER ALL\nGO", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/azopenrowset-2a2624ed-a934-4582-aa9a-6056df361db8.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "2a2624ed-a934-4582-aa9a-6056df361db8", 3 | "prefix": "azopenrowset", 4 | "description": "ES: Query a file from Azure storage container", 5 | "body": "SELECT\r\n *\r\nFROM\r\n OPENROWSET(BULK '', DATA_SOURCE = '', SINGLE_CLOB) AS DataFile;" 6 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/azscale-e87e077b-daf4-44d9-b183-9ab230059201.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "e87e077b-daf4-44d9-b183-9ab230059201", 3 | "prefix": "azscale", 4 | "description": "ES: Azure Database scale check and alter", 5 | "body": "SELECT\r\n Edition = DATABASEPROPERTYEX(DB_NAME(), 'EDITION')\r\n ,ServiceObjective = DATABASEPROPERTYEX(DB_NAME(), 'ServiceObjective')\r\n ,MaxSizeInGB = CONVERT(bigint, DATABASEPROPERTYEX(DB_NAME(), 'MaxSizeInBytes')) / 1024 / 1024 / 1024\r\n ,CurrentSizeInGB = (SELECT (SUM(CAST((size * 8.0 / 1024 / 1024) AS decimal(15, 2))))FROM sys.database_files);\r\n\r\n/*\r\n-- Edition Basic\r\n-- Standard\r\n-- Premium\r\n-- ServiceObjective Basic = Basic (5 DTU)\r\n-- Standard = S0 (10 DTU), S1 (20 DTU), S2 (50 DTU), S3 (100 DTU), S4 (200 DTU), S6 (400 DTU), S7 (800 DTU), S9 (1600 DTU), S12 (3000 DTU)\r\n-- Premium = P1 (125 DTU), P2 (250 DTU), P4 (500 DTU), P6 (1000 DTU), P11 (1750 DTU), P15 (4000 DTU)\r\n-- MaxSizeInGB Basic = 2\r\n-- Standard = 0.1 - 1024\r\n-- Premium = 0.1 = 4096\r\n\r\nDECLARE\r\n @Edition AS nvarchar(MAX) = N'Basic'\r\n ,@ServiceObjective AS nvarchar(MAX) = N'Basic'\r\n ,@MaxSizeInGB AS nvarchar(MAX) = N'2';\r\n\r\nDECLARE @StringToExecute AS nvarchar(MAX) = N'';\r\n\r\nSET @StringToExecute = N'ALTER DATABASE [' + DB_NAME() + N'] MODIFY (EDITION = ''' + @Edition + N''', MAXSIZE = ' + @MaxSizeInGB + N' GB, SERVICE_OBJECTIVE = ''' + @ServiceObjective + N''');';\r\n\r\nSELECT @StringToExecute;\r\n\r\nEXECUTE sp_executesql @stmt = @StringToExecute;\r\n*/" 6 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/be-be27a73c-15fb-40dd-992d-9b05c0f54d64.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "be27a73c-15fb-40dd-992d-9b05c0f54d64", 3 | "name": "be", 4 | "prefix": "be", 5 | "description": "Inserts BEGIN..END block", 6 | "body": "BEGIN\n\t$CURSOR$\nEND", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/bt-5e72be93-a6a3-446d-8c84-3b398ba58fdd.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "5e72be93-a6a3-446d-8c84-3b398ba58fdd", 3 | "name": "bt", 4 | "prefix": "bt", 5 | "description": "Begin transaction", 6 | "body": "BEGIN TRANSACTION", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/buf-7363fb6d-c728-4633-ae8d-464db1b80a4e.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "7363fb6d-c728-4633-ae8d-464db1b80a4e", 3 | "prefix": "buf", 4 | "description": "ES: Returns information about all the data pages that are currently in the SQL Server buffer pool.", 5 | "body": "/* Returns information about all the data pages that are currently in the SQL Server buffer pool. */\r\nSELECT\r\n ObjectSchemaName = '.All'\r\n ,ObjectName = '.All'\r\n ,CachedPagesCount = FORMAT(COUNT(*), '#,##0')\r\n ,IndexName = '.All'\r\nFROM\r\n sys.dm_os_buffer_descriptors\r\nWHERE\r\n database_id = DB_ID()\r\nUNION ALL\r\nSELECT\r\n ObjectSchemaName = obj.ObjectSchemaName\r\n ,ObjectName = obj.ObjectName\r\n ,CachedPagesCount = FORMAT(COUNT(*), '#,##0')\r\n ,IndexName = i.name\r\nFROM\r\n sys.dm_os_buffer_descriptors AS bd\r\n INNER JOIN (\r\n SELECT\r\n p.object_id\r\n ,ObjectName = OBJECT_NAME(p.object_id)\r\n ,ObjectSchemaName = OBJECT_SCHEMA_NAME(p.object_id)\r\n ,p.index_id\r\n ,au.allocation_unit_id\r\n FROM\r\n sys.allocation_units AS au\r\n INNER JOIN sys.partitions AS p\r\n ON au.container_id = p.hobt_id\r\n AND (au.type = 1 OR au.type = 3)\r\n UNION ALL\r\n SELECT\r\n p.object_id\r\n ,ObjectName = OBJECT_NAME(p.object_id)\r\n ,ObjectSchemaName = OBJECT_SCHEMA_NAME(p.object_id)\r\n ,p.index_id\r\n ,au.allocation_unit_id\r\n FROM\r\n sys.allocation_units AS au\r\n INNER JOIN sys.partitions AS p\r\n ON au.container_id = p.partition_id\r\n AND au.type = 2\r\n ) AS obj\r\n ON bd.allocation_unit_id = obj.allocation_unit_id\r\n LEFT JOIN sys.indexes AS i\r\n ON obj.object_id = i.object_id\r\n AND obj.index_id = i.index_id\r\nWHERE\r\n bd.database_id = DB_ID()\r\nAND obj.ObjectSchemaName NOT IN (N'sys') /* Remove this to see system objects and user objects */\r\nGROUP BY\r\n obj.ObjectName\r\n ,obj.ObjectSchemaName\r\n ,i.name\r\nORDER BY\r\n ObjectSchemaName ASC\r\n ,ObjectName ASC;" 6 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/ccc-50a0db4d-a380-4898-a48e-e5f42233ef43.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "50a0db4d-a380-4898-a48e-e5f42233ef43", 3 | "name": "ccc", 4 | "prefix": "ccc", 5 | "description": "CREATE CELL CALCULATION fragment", 6 | "body": "CREATE CELL CALCULATION ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/cci-36278968-93e7-4d9b-8e58-2a2f1df054f2.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "36278968-93e7-4d9b-8e58-2a2f1df054f2", 3 | "name": "cci", 4 | "prefix": "cci", 5 | "description": "Create non-unique clustered index", 6 | "body": "CREATE CLUSTERED INDEX $CURSOR$\nON -- table | view ( column1 [ ASC | DESC ], ..., columnN ( ASC | DESC ] )\n--WITH PAD_INDEX\n-- | FILLFACTOR = fillfactor\n-- | IGNORE_DUP_KEY\n-- | DROP_EXISTING\n-- | STATISTICS_NORECOMPUTE\n-- | SORT_IN_TEMPDB, .. as required\n-- ON filegroup\nGO\n", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/cdb-3cb0e0f2-0461-4048-820a-29632d0d5d31.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "3cb0e0f2-0461-4048-820a-29632d0d5d31", 3 | "name": "cdb", 4 | "prefix": "cdb", 5 | "description": "CREATE DATABASE statement", 6 | "body": "CREATE DATABASE $CURSOR$ --database_name\nON\nPRIMARY ( -- or use FILEGROUP filegroup_name\n NAME = logical_file_name,\n FILENAME = 'os_file_name',\n SIZE = size,\n MAXSIZE = max_size|UNLIMITED,\n FILEGROWTH = growth_increment\n) --, and repeat as required\nLOG ON\n(\n NAME = logical_file_name,\n FILENAME = 'os_file_name',\n SIZE = size,\n MAXSIZE = max_size|UNLIMITED,\n FILEGROWTH = growth_increment\n) --, and repeat as required\n--COLLATE collation_name\n--WITH\n-- DB_CHAINING ON/OFF\n-- TRUSTWORTHY ON/OFF\n--FOR LOAD\n--FOR ATTACH\n--WITH\n-- ENABLE_BROKER\n-- NEW_BROKER\n-- ERROR_BROKER_CONVERSATIONS\n--FOR ATTACH_REBUILD_LOG\nGO\n", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/cdbsnap-0fb515a5-2832-42e0-829a-3cfffe271abd.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "0fb515a5-2832-42e0-829a-3cfffe271abd", 3 | "name": "cdbsnap", 4 | "prefix": "cdbsnap", 5 | "description": "Create a database snapshot", 6 | "body": "CREATE DATABASE $CURSOR$ \nON \n (\n NAME = /* logical_file_name */,\n FILENAME = /* 'os_file_name' */\n ) [ ,...n ] \nAS SNAPSHOT OF /* source_database_name */\nGO\n", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/chk-f7f6b91b-4bc5-4d05-b627-b3ebed72232d.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "f7f6b91b-4bc5-4d05-b627-b3ebed72232d", 3 | "name": "chk", 4 | "prefix": "chk", 5 | "description": "Creates an extended event session, runs the code you want to test, extracts the output and then stops the session", 6 | "body": "IF EXISTS --if the session already exists, then delete it. We are assuming you've changed something\n (\n SELECT * FROM sys.server_event_sessions\n WHERE server_event_sessions.name = 'CheckingSQLStatements'\n )\n DROP EVENT SESSION CheckingSQLStatements ON SERVER;\nGO\nCREATE EVENT SESSION CheckingSQLStatements --call it what you wish, of course\nON SERVER\n ADD EVENT sqlserver.sql_statement_completed --we just have one event\n (ACTION (sqlserver.database_name, sqlserver.sql_text, sqlserver.plan_handle)-- and these global vars\n WHERE (sqlserver.like_i_sql_unicode_string(sqlserver.sql_text, N'--Test these queries%'))\n\t --we just want the batch and nothing else so we put an identifying string at the start\n )\n ADD TARGET package0.ring_buffer \n --we don't need a more permanent record or a bucket count\nWITH (STARTUP_STATE = OFF);\nGO\nALTER EVENT SESSION CheckingSQLStatements ON SERVER STATE = START;\n--V-----The Batch being tested starts here ------V\nGO --don't change this next line without changing the WHERE clause above\n--Test these queries\n-------------------------------------------------------------------\n\n$SELECTEDTEXT$\n\n------------------------------------------------------------------\ngo\nDECLARE @Target_Data XML =\n (\n SELECT TOP 1 Cast(xet.target_data AS XML) AS targetdata\n FROM sys.dm_xe_session_targets AS xet\n INNER JOIN sys.dm_xe_sessions AS xes\n ON xes.address = xet.event_session_address\n WHERE xes.name = 'CheckingSQLStatements'\n AND xet.target_name = 'ring_buffer'\n );\nSELECT \nCONVERT(datetime2,\n SwitchOffset(CONVERT(datetimeoffset,the.event_data.value('(@timestamp)[1]', 'datetime2')),\n\t\tDateName(TzOffset, SYSDATETIMEOFFSET()))) AS datetime_local,\nCONVERT(DECIMAL(6,3),round(the.event_data.value('(data[@name=\"duration\"]/value)[1]', 'bigint')/1000000.0,3,1)) AS duration,\nthe.event_data.value('(data[@name=\"statement\"]/value)[1]', 'nvarchar(max)') AS [statement],\n--the.event_data.value('(action[@name=\"sql_text\"]/value)[1]', 'nvarchar(max)') AS sql_text,\n--the.event_data.value('(action[@name=\"database_name\"]/value)[1]', 'nvarchar(80)') AS [database_name],\nqp.query_plan,\nthe.event_data.value('(data[@name=\"cpu_time\"]/value)[1]', 'bigint') AS [cpu_time(microsSecs)],\nthe.event_data.value('(data[@name=\"physical_reads\"]/value)[1]', 'bigint') AS physical_reads,\nthe.event_data.value('(data[@name=\"logical_reads\"]/value)[1]', 'bigint') AS logical_reads,\nthe.event_data.value('(data[@name=\"writes\"]/value)[1]', 'bigint') AS writes,\nthe.event_data.value('(data[@name=\"row_count\"]/value)[1]', 'bigint') AS row_count\n--the.event_data.value('(data[@name=\"last_row_count\"]/value)[1]', 'int') AS last_row_count,\n--the.event_data.value('(data[@name=\"line_number\"]/value)[1]', 'int') AS line_number,\n--the.event_data.value('(data[@name=\"offset\"]/value)[1]', 'int') AS offset,\n--the.event_data.value('(data[@name=\"offset_end\"]/value)[1]', 'int') AS offset_end,\n\nFROM @Target_Data.nodes('//RingBufferTarget/event') AS the (event_data)\n CROSS APPLY sys.dm_exec_query_plan(\n Convert(varbinary(64),--convert to valid plan handle\n '0x' + the.event_data.value('(action[@name=\"plan_handle\"]/value)[1]', 'nvarchar(max)')\n\t\t ,1)) as qp\n\nALTER EVENT SESSION CheckingSQLStatements ON SERVER STATE = STOP;", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/citf-ec65b7c5-2414-43ed-9514-faf11e123f08.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "ec65b7c5-2414-43ed-9514-faf11e123f08", 3 | "name": "citf", 4 | "prefix": "citf", 5 | "description": "ES: Create inline table-valued function", 6 | "body": "/**********************************************************************************************************************\n** Author: $USER$\n** Created On: $DATE$\n** Modified On: $DATE$\n** Description: \n**********************************************************************************************************************/\nCREATE FUNCTION .(\n\t-- @ParameterName AS DataType [ = DefaultValue ]\n) RETURNS TABLE\nAS\nRETURN\n\t-- Return the result of the function\n\t$SELECTIONSTART$SELECT ColumnName = 1;$SELECTIONEND$\nGO", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/cj-df805520-f59a-4333-ade3-761407505ac7.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "df805520-f59a-4333-ade3-761407505ac7", 3 | "name": "cj", 4 | "prefix": "cj", 5 | "description": "CROSS JOIN fragment", 6 | "body": "CROSS JOIN ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/cl-de1fcf2e-4436-43a5-b208-ad49668e6dbb.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "de1fcf2e-4436-43a5-b208-ad49668e6dbb", 3 | "name": "cl", 4 | "prefix": "cl", 5 | "description": "Create a new SQL Server login", 6 | "body": "CREATE LOGIN $CURSOR$ /* Add WITH or FROM (below) as appropriate */\n--WITH\n-- PASSWORD = 'password' /* HASHED */ /* MUST CHANGE */\n-- SID = sid\n-- DEFAULT_DATABASE = database\n-- DEFAULT_LANGUAGE = language\n-- CHECK_EXPIRATION = ON | OFF\n-- CHECK_POLICY = ON | OFF\n-- CREDENTIAL = credential_name\n--FROM\n-- WINDOWS\n-- WITH\n-- DEFAULT_DATABASE = database\n-- DEFAULT_LANGUAGE = language\n-- CERTIFICATE certificate_name\n-- ASYMMETRIC KEY key_name\nGO\n", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/clrp-99f1f2b4-6aee-4464-9cd1-ee96479de411.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "99f1f2b4-6aee-4464-9cd1-ee96479de411", 3 | "name": "clrp", 4 | "prefix": "clrp", 5 | "description": "Create a CLR stored procedure", 6 | "body": "--SET QUOTED_IDENTIFIER ON|OFF\n--SET ANSI_NULLS ON|OFF\n\nCREATE PROCEDURE $CURSOR$\n(\n\t--@parameter_name AS scalar_data_type ( = default_value ), ...\n)\n-- WITH EXECUTE AS CALLER|SELF|OWNER| 'user_name'\nAS EXTERNAL NAME -- assembly_name.class_name.static_method_name\nGO\n\n--SET QUOTED_IDENTIFIER ON|OFF\n--SET ANSI_NULLS ON|OFF", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/cmtblock-2c1ab9f3-421d-4839-8edb-fb50237651da.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "2c1ab9f3-421d-4839-8edb-fb50237651da", 3 | "prefix": "cmtblock", 4 | "description": "ES: Comment with /* */ on a block.", 5 | "body": "/* \r\n $SELECTEDTEXT$ \r\n*/" 6 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/cmtline-7b5e5616-b404-41ee-baa8-b81d1316c2ac.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "7b5e5616-b404-41ee-baa8-b81d1316c2ac", 3 | "prefix": "cmtline", 4 | "description": "ES: Comment with /* */ on one line.", 5 | "body": "/* $SELECTEDTEXT$ */" 6 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/cni-dfb60004-dd04-40db-9ff2-95d5f546f28c.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "dfb60004-dd04-40db-9ff2-95d5f546f28c", 3 | "name": "cni", 4 | "prefix": "cni", 5 | "description": "Create non-unique nonclustered index", 6 | "body": "CREATE NONCLUSTERED INDEX $CURSOR$\nON -- table | view ( column1 [ ASC | DESC ], ..., columnN ( ASC | DESC ] )\n--WITH PAD_INDEX\n-- | FILLFACTOR = fillfactor\n-- | IGNORE_DUP_KEY\n-- | DROP_EXISTING\n-- | STATISTICS_NORECOMPUTE\n-- | SORT_IN_TEMPDB, .. as required\n-- ON filegroup\nGO\n", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/cp-d6aa947d-5636-4e53-a16a-d93d3c8255da.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "d6aa947d-5636-4e53-a16a-d93d3c8255da", 3 | "prefix": "cp", 4 | "description": "ES: Create a stored procedure", 5 | "body": "SET QUOTED_IDENTIFIER, ANSI_NULLS ON;\nGO\n/**********************************************************************************************************************\n** Author: $USER$\n** Created On: $DATE$\n** Modified On: $DATE$\n** Description: Description\n**********************************************************************************************************************/\nCREATE OR ALTER PROCEDURE . (\n\t-- @ParameterName AS DataType [ = DefaultValue ]\n)\n-- WITH ENCRYPTION, RECOMPILE, EXECUTE AS CALLER|SELF|OWNER| 'user_name'\nAS\n\tBEGIN\n\t\tSET NOCOUNT, XACT_ABORT ON;\n\t\n\t\t$SELECTIONSTART$--SELECT\n\t\t--\tTableId = TN.TableId\n\t\t-- ,ColumnName1 = TN.Column1\n\t\t-- ,ColumnName2 = TN.Column2\n\t\t--FROM\n\t\t--\tSchemaName.TableName AS TN\n\t\t--WHERE\n\t\t--\tTN.TableId = @TableId;$SELECTIONEND$\n\n\tEND\nGO" 6 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/cseq-760a95b9-a6ef-4f94-b8fc-abea54787b2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "760a95b9-a6ef-4f94-b8fc-abea54787b2e", 3 | "name": "cseq", 4 | "prefix": "cseq", 5 | "description": "Create Sequence starts with x increment by y cache and cicle", 6 | "body": "CREATE SEQUENCE $SchemaName$.$SequenceName$ \nSTART WITH $Start$\nINCREMENT BY $End$\n$Cycle$\n$Cache$;", 7 | "placeholders": [ 8 | { 9 | "name": "SchemaName", 10 | "defaultValue": "" 11 | }, 12 | { 13 | "name": "SequenceName", 14 | "defaultValue": "" 15 | }, 16 | { 17 | "name": "Start", 18 | "defaultValue": "1" 19 | }, 20 | { 21 | "name": "End", 22 | "defaultValue": "2147483647" 23 | }, 24 | { 25 | "name": "Cycle", 26 | "defaultValue": "CYCLE" 27 | }, 28 | { 29 | "name": "Cache", 30 | "defaultValue": "CACHE" 31 | } 32 | ] 33 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/csf-57a707fd-2c95-4d27-964e-7b27fb5c2bcb.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "57a707fd-2c95-4d27-964e-7b27fb5c2bcb", 3 | "name": "csf", 4 | "prefix": "csf", 5 | "description": "ES: Create scalar function", 6 | "body": "/**********************************************************************************************************************\n** Author: $USER$\n** Created On: $DATE$\n** Modified On: $DATE$\n** Description: \n**********************************************************************************************************************/\nCREATE OR ALTER FUNCTION .(\n\t-- @ParameterName AS DataType [ = DefaultValue ]\n) RETURNS \n-- WITH ENCRYPTION, SCHEMABINDING, RETURNS NULL ON NULL INPUT, CALLED ON NULL INPUT, EXECUTE AS CALLER|SELF|OWNER 'user_name', INLINE = {ON|OFF}\nAS\n\tBEGIN\n\t\t-- Determine if an UDF is the best option. SQL Server 2019+ might possibly inline this function.\n\t\t-- User-defined scalar functions suck – even when they don’t access data.\n\t\t-- https://www.brentozar.com/archive/2019/05/user-defined-scalar-functions-suck-even-when-they-dont-access-data/\n\n \t\t-- Declare the return variable\n\t\tDECLARE <@ResultVariable, sysname, @VariableName> \n\n\t\t-- Add the T-SQL statements to compute the return value\n\t\t$SELECTIONSTART$SELECT <@ResultVariable, sysname, @VariableName> = @ParameterName$SELECTIONEND$\n\n\t\t-- Return the result of the function\n\t\tRETURN <@ResultVariable, sysname, @VariableName>\n\tEND\nGO", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/ct-d549e06d-2453-49f7-bf1c-8f9249e7072a.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "d549e06d-2453-49f7-bf1c-8f9249e7072a", 3 | "name": "ct", 4 | "prefix": "ct", 5 | "description": "ES: Create a table", 6 | "body": "CREATE TABLE .\n(\n\t INT NOT NULL IDENTITY(1, 1) CONSTRAINT PRIMARY KEY, \n\t NVARCHAR(100) NOT NULL$CURSOR$\n)\nGO", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/cte-a745034e-2cd6-4a08-b825-d80860bf98ca.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "a745034e-2cd6-4a08-b825-d80860bf98ca", 3 | "prefix": "cte", 4 | "description": "New common table expression", 5 | "body": ";WITH cteName\n AS (\n $SELECTIONSTART$SELECT col1\n FROM someTable$SELECTIONEND$\n )\n\nSELECT *\nFROM cteName" 6 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/ctf-6121a3bc-5c5d-48b6-ba04-680806f5d1ee.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "6121a3bc-5c5d-48b6-ba04-680806f5d1ee", 3 | "name": "ctf", 4 | "prefix": "ctf", 5 | "description": "ES: Create multi-statement table-valued function", 6 | "body": "/**********************************************************************************************************************\n** Author: $USER$\n** Created On: $DATE$\n** Modified On: $DATE$\n** Description: \n**********************************************************************************************************************/\nCREATE FUNCTION .(\n\t-- @ParameterName1 AS DataType [ = DefaultValue ]\n\t-- @ParameterName2 AS DataType [ = DefaultValue ]\n) RETURNS <@TableVariableName, SYSNAME, @VariableName> TABLE (\n\t NOT NULL,\n\t NOT NULL\n)\n-- WITH ENCRYPTION, RECOMPILE, EXECUTE AS CALLER|SELF|OWNER| 'user_name'\nAS\nBEGIN\n\t-- Return the result of the function\n\tINSERT INTO <@TableVariableName, SYSNAME, @VariableName> (\n\t\t,\n\t\t\n\t)\n\t$SELECTIONSTART$SELECT = 1, = 2;$SELECTIONEND$\n\tRETURN;\nEND\nGO", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/ctr-cfd1e9b0-7af2-4602-99af-fe239f6e75f8.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "cfd1e9b0-7af2-4602-99af-fe239f6e75f8", 3 | "name": "ctr", 4 | "prefix": "ctr", 5 | "description": "Commit transaction", 6 | "body": "COMMIT TRANSACTION", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/ctt-a9ba3e1d-9d41-4f84-8d68-b59019d59077.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "a9ba3e1d-9d41-4f84-8d68-b59019d59077", 3 | "name": "ctt", 4 | "prefix": "ctt", 5 | "description": "Create TEMP Table", 6 | "body": "IF (OBJECT_ID(N'tempdb..#$table_name$') IS NOT NULL) DROP TABLE #$table_name$ ;\nCREATE TABLE #$table_name$ ($CURSOR$);", 7 | "placeholders": [ 8 | { 9 | "name": "table_name", 10 | "defaultValue": "tmpTable" 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/cuci-90333136-a90f-4278-9fa3-e7f1cc01c1c2.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "90333136-a90f-4278-9fa3-e7f1cc01c1c2", 3 | "name": "cuci", 4 | "prefix": "cuci", 5 | "description": "Create unique clustered index", 6 | "body": "CREATE UNIQUE CLUSTERED INDEX $CURSOR$\nON -- table | view ( column1 [ ASC | DESC ], ..., columnN ( ASC | DESC ] )\n--WITH PAD_INDEX\n-- | FILLFACTOR = fillfactor\n-- | IGNORE_DUP_KEY\n-- | DROP_EXISTING\n-- | STATISTICS_NORECOMPUTE\n-- | SORT_IN_TEMPDB, .. as required\n-- ON filegroup\nGO\n", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/cuni-976195ca-f9c1-4f1f-97fe-3e0c56a27fdd.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "976195ca-f9c1-4f1f-97fe-3e0c56a27fdd", 3 | "name": "cuni", 4 | "prefix": "cuni", 5 | "description": "Create unique nonclustered index", 6 | "body": "CREATE UNIQUE NONCLUSTERED INDEX $CURSOR$\nON -- table | view ( column1 [ ASC | DESC ], ..., columnN ( ASC | DESC ] )\n--WITH PAD_INDEX\n-- | FILLFACTOR = fillfactor\n-- | IGNORE_DUP_KEY\n-- | DROP_EXISTING\n-- | STATISTICS_NORECOMPUTE\n-- | SORT_IN_TEMPDB, .. as required\n-- ON filegroup\nGO\n", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/curff-9bfcd873-5e2a-4a35-8b6c-5363f02bbf79.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "9bfcd873-5e2a-4a35-8b6c-5363f02bbf79", 3 | "name": "curff", 4 | "prefix": "curff", 5 | "description": "Boilerplate code for fast-forward read-only cursor", 6 | "body": "DECLARE /* variables */\n\nDECLARE $CURSOR$ CURSOR FAST_FORWARD READ_ONLY FOR\n/* SELECT statement */\n\nOPEN /* cursor name */\n\nFETCH NEXT FROM /* cursor name */ INTO /* variables */\n\nWHILE @@FETCH_STATUS = 0\nBEGIN\n\n/* cursor logic */\n\nFETCH NEXT FROM /* cursor name */ INTO /* variables */\n\nEND\n\nCLOSE /* cursor name */\nDEALLOCATE /* cursor name */", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/cv-5a7bc141-ae05-46f7-bc7b-654bbdf9d302.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "5a7bc141-ae05-46f7-bc7b-654bbdf9d302", 3 | "name": "cv", 4 | "prefix": "cv", 5 | "description": "Create a view", 6 | "body": "CREATE VIEW $CURSOR$\n--WITH ENCRYPTION, SCHEMABINDING, VIEW_METADATA\nAS\n\tSELECT /* query specification */\n-- WITH CHECK OPTION\nGO\n", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/cw-b8412917-d95e-4eb2-8871-c1caecb18ad5.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "b8412917-d95e-4eb2-8871-c1caecb18ad5", 3 | "name": "cw", 4 | "prefix": "cw", 5 | "description": "CASE WHEN", 6 | "body": "CASE WHEN ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/dd-8839c31f-0191-4f17-a822-8197e969d959.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "8839c31f-0191-4f17-a822-8197e969d959", 3 | "name": "dd", 4 | "prefix": "dd", 5 | "description": "Drop a database", 6 | "body": "DROP DATABASE ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/df-6fe464bb-14c1-4fc7-8e30-aa2dce4b3755.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "6fe464bb-14c1-4fc7-8e30-aa2dce4b3755", 3 | "name": "df", 4 | "prefix": "df", 5 | "description": "DELETE FROM fragment", 6 | "body": "DELETE FROM ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/dfn-62721689-d5c0-4a8b-8096-ca1361001364.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "62721689-d5c0-4a8b-8096-ca1361001364", 3 | "name": "dfn", 4 | "prefix": "dfn", 5 | "description": "Drop a function", 6 | "body": "DROP FUNCTION ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/di-fd7cafcd-3362-4934-889b-88b3434d5b90.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "fd7cafcd-3362-4934-889b-88b3434d5b90", 3 | "name": "di", 4 | "prefix": "di", 5 | "description": "Drop an index", 6 | "body": "DROP INDEX ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/dl-76d104c4-42bd-4448-b8ed-2f6e454dc04d.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "76d104c4-42bd-4448-b8ed-2f6e454dc04d", 3 | "name": "dl", 4 | "prefix": "dl", 5 | "description": "Drop a login", 6 | "body": "DROP LOGIN ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/dp-6fb0ddaf-f731-45a0-a10c-f9395fca7723.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "6fb0ddaf-f731-45a0-a10c-f9395fca7723", 3 | "name": "dp", 4 | "prefix": "dp", 5 | "description": "Drop a stored procedure", 6 | "body": "DROP PROCEDURE ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/dseq-02c73dcc-abe9-4ec5-a90e-2e19eac421c8.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "02c73dcc-abe9-4ec5-a90e-2e19eac421c8", 3 | "name": "dseq", 4 | "prefix": "dseq", 5 | "description": "Drop sequence", 6 | "body": "DROP SEQUENCE $SchemaName$.$SequenceName$;", 7 | "placeholders": [ 8 | { 9 | "name": "SchemaName", 10 | "defaultValue": "" 11 | }, 12 | { 13 | "name": "SequenceName", 14 | "defaultValue": "" 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/dt-1b026389-cf7e-4cdd-9881-bd21828f02ab.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "1b026389-cf7e-4cdd-9881-bd21828f02ab", 3 | "name": "dt", 4 | "prefix": "dt", 5 | "description": "Drop a table", 6 | "body": "DROP TABLE ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/du-d425e16b-0feb-482a-b44e-daba985c1b1a.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "d425e16b-0feb-482a-b44e-daba985c1b1a", 3 | "name": "du", 4 | "prefix": "du", 5 | "description": "Drop a user", 6 | "body": "DROP USER ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/dupk-914a3407-dc4b-4d7e-afc7-a180d7d4a291.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "914a3407-dc4b-4d7e-afc7-a180d7d4a291", 3 | "name": "dupk", 4 | "prefix": "dupk", 5 | "description": "Check for n-uplicate values on a column", 6 | "body": "SELECT\n\t$Column$\nFROM\n\t$SchemaName$.$ObjectName$\nGROUP BY\n\t$Column$\nHAVING\n\tCOUNT(1) > $Occurrences$;", 7 | "placeholders": [ 8 | { 9 | "name": "Column", 10 | "defaultValue": "" 11 | }, 12 | { 13 | "name": "SchemaName", 14 | "defaultValue": "" 15 | }, 16 | { 17 | "name": "ObjectName", 18 | "defaultValue": "" 19 | }, 20 | { 21 | "name": "Occurrences", 22 | "defaultValue": "" 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/dv-8116bed6-529b-409e-a2dd-78a380376553.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "8116bed6-529b-409e-a2dd-78a380376553", 3 | "name": "dv", 4 | "prefix": "dv", 5 | "description": "Drop a view", 6 | "body": "DROP VIEW ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/eata-07c49a65-a060-4180-8cf5-524474d6270a.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "07c49a65-a060-4180-8cf5-524474d6270a", 3 | "name": "eata", 4 | "prefix": "eata", 5 | "description": "Add column (enhanced edition)", 6 | "body": "USE \nGO\n \n-- Add a new column to the table\nALTER TABLE .
\n ADD -- \nGO\nEXEC sys.sp_addextendedproperty \n@name = N'MS_Description', \n@value = N'', \n@level0type = N'SCHEMA', @level0name = , \n@level1type = N'TABLE', @level1name =
,\n@level2type = N'COLUMN', @level2name = ;", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/err-dceff8fe-5df0-4bfd-86dd-fe84f76ad6e9.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "dceff8fe-5df0-4bfd-86dd-fe84f76ad6e9", 3 | "name": "err", 4 | "prefix": "err", 5 | "description": "Inserts @@ERROR function call", 6 | "body": "@@ERROR", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/fj-713fd209-a910-418e-981d-235de0de55d3.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "713fd209-a910-418e-981d-235de0de55d3", 3 | "name": "fj", 4 | "prefix": "fj", 5 | "description": "FULL JOIN fragment", 6 | "body": "FULL JOIN ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/fk-f309d072-0ad3-40cf-bcf9-b136a61b148b.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "f309d072-0ad3-40cf-bcf9-b136a61b148b", 3 | "prefix": "fk", 4 | "description": "ES: Create ALTER statement for untrusted FK", 5 | "body": "SELECT\r\n 'ALTER TABLE ' + QUOTENAME(S.name) + '.' + QUOTENAME(T.name) + ' WITH CHECK CHECK CONSTRAINT ' + FK.name + ';'\r\nFROM\r\n sys.foreign_keys AS FK\r\n INNER JOIN sys.tables AS T\r\n ON FK.parent_object_id = T.object_id\r\n INNER JOIN sys.schemas AS S\r\n ON T.schema_id = S.schema_id\r\nWHERE\r\n FK.is_not_trusted = 1\r\nORDER BY\r\n S.name\r\n ,T.name;" 6 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/foff-caf93e3a-bef2-4318-a41a-1f6f9719b5ab.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "caf93e3a-bef2-4318-a41a-1f6f9719b5ab", 3 | "name": "foff", 4 | "prefix": "foff", 5 | "description": "Disable formatting from this point onwards", 6 | "body": "--SQL Prompt Formatting Off", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/foj-7dd9edfb-75aa-4e47-a7dc-4e89a7d7d1dc.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "7dd9edfb-75aa-4e47-a7dc-4e89a7d7d1dc", 3 | "name": "foj", 4 | "prefix": "foj", 5 | "description": "FULL OUTER JOIN fragment", 6 | "body": "FULL OUTER JOIN ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/fon-22a709a0-2328-4f8b-b9ba-04adb5c89d96.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "22a709a0-2328-4f8b-b9ba-04adb5c89d96", 3 | "name": "fon", 4 | "prefix": "fon", 5 | "description": "Enable formatting from this point onwards", 6 | "body": "--SQL Prompt Formatting On", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/gb-88eacacc-c05b-45dc-ba54-4faf14bb830c.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "88eacacc-c05b-45dc-ba54-4faf14bb830c", 3 | "name": "gb", 4 | "prefix": "gb", 5 | "description": "GROUP BY", 6 | "body": "GROUP BY ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/gep-286dca70-9277-4472-b6f1-128d94501f07.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "286dca70-9277-4472-b6f1-128d94501f07", 3 | "name": "gep", 4 | "prefix": "gep", 5 | "description": "Grant Execute on Procedure", 6 | "body": "GRANT EXECUTE ON $ProcedureName$ TO $RoleOrUser$;", 7 | "placeholders": [ 8 | { 9 | "name": "ProcedureName", 10 | "defaultValue": "" 11 | }, 12 | { 13 | "name": "RoleOrUser", 14 | "defaultValue": "" 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/git-330dccdd-60ce-49d8-81ba-bc11894d6c41.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "330dccdd-60ce-49d8-81ba-bc11894d6c41", 3 | "name": "git", 4 | "prefix": "git", 5 | "description": "Grant Insert on Table", 6 | "body": "GRANT INSERT ON $ObjectName$ TO $RoleOrUser$", 7 | "placeholders": [ 8 | { 9 | "name": "ObjectName", 10 | "defaultValue": "" 11 | }, 12 | { 13 | "name": "RoleOrUser", 14 | "defaultValue": "" 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/giust-77a84a71-9144-42bc-b25c-47ab69c89e0b.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "77a84a71-9144-42bc-b25c-47ab69c89e0b", 3 | "name": "giust", 4 | "prefix": "giust", 5 | "description": "Grant Insert Update Select on Table", 6 | "body": "GRANT INSERT UPDATE SELECT ON $ObjectName$ TO $RoleOrUser$;", 7 | "placeholders": [ 8 | { 9 | "name": "ObjectName", 10 | "defaultValue": "" 11 | }, 12 | { 13 | "name": "RoleOrUser", 14 | "defaultValue": "" 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/gst-a70223e6-d8d9-4a7b-88a2-5d6561d155cd.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "a70223e6-d8d9-4a7b-88a2-5d6561d155cd", 3 | "name": "gst", 4 | "prefix": "gst", 5 | "description": "Grant Select on Table", 6 | "body": "GRANT SELECT ON $ObjectName$ TO $RoleOrUser$;", 7 | "placeholders": [ 8 | { 9 | "name": "ObjectName", 10 | "defaultValue": "" 11 | }, 12 | { 13 | "name": "RoleOrUser", 14 | "defaultValue": "" 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/gut-370af63d-1578-4eb9-aa58-1a24834e5114.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "370af63d-1578-4eb9-aa58-1a24834e5114", 3 | "name": "gut", 4 | "prefix": "gut", 5 | "description": "Grant Update on Table", 6 | "body": "GRANT UPDATE ON $ObjectName$ TO $RoleOrUser$;", 7 | "placeholders": [ 8 | { 9 | "name": "ObjectName", 10 | "defaultValue": "" 11 | }, 12 | { 13 | "name": "RoleOrUser", 14 | "defaultValue": "" 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/header-e31a0b75-d45a-4c8d-b0fe-ed89eb7378c6.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "e31a0b75-d45a-4c8d-b0fe-ed89eb7378c6", 3 | "name": "header", 4 | "prefix": "header", 5 | "description": "ES: Template header for stored procedure", 6 | "body": "/**********************************************************************************************************************\n** Author: $USER$\n** Created On: $DATE$\n** Modified On: $DATE$\n** Description: $CURSOR$\n**********************************************************************************************************************/", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/hhmm-35b3d645-ecae-4082-a129-43e36557d549.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "35b3d645-ecae-4082-a129-43e36557d549", 3 | "name": "hhmm", 4 | "prefix": "hhmm", 5 | "description": "HH:mm format", 6 | "body": "LEFT(CONVERT(VARCHAR(8), $date_column$, 108),5) as HHMM", 7 | "placeholders": [ 8 | { 9 | "name": "date_column", 10 | "defaultValue": "" 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/ida-4b1199ef-ec27-40ef-8490-7d6317dcf4a7.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "4b1199ef-ec27-40ef-8490-7d6317dcf4a7", 3 | "name": "ida", 4 | "prefix": "ida", 5 | "description": "IF EXISTS DROP: Assembly - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "IF ASSEMBLYPROPERTY('$CURSOR$','CLRName') IS NOT NULL DROP ASSEMBLY ;", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/idf-ccf88047-11ba-4e2b-8dcc-59c31ac4a28f.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "ccf88047-11ba-4e2b-8dcc-59c31ac4a28f", 3 | "name": "idf", 4 | "prefix": "idf", 5 | "description": "IF EXISTS DROP: Function - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "IF OBJECT_ID('$CURSOR$') IS NOT NULL DROP FUNCTION ;\nGO\n", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/idl-e309d0b6-7881-4f6c-9276-8f0884c2db49.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "e309d0b6-7881-4f6c-9276-8f0884c2db49", 3 | "name": "idl", 4 | "prefix": "idl", 5 | "description": "IF EXISTS DROP: Login - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "IF SUSER_SID('$CURSOR$') IS NOT NULL DROP LOGIN ;", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/idp-ccfabdf7-c0f6-4fdc-b55a-dd8c42f0fc36.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "ccfabdf7-c0f6-4fdc-b55a-dd8c42f0fc36", 3 | "name": "idp", 4 | "prefix": "idp", 5 | "description": "IF EXISTS DROP: Procedure - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "IF OBJECT_ID('$CURSOR$') IS NOT NULL DROP PROCEDURE ;\nGO\n", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/ids-c7063adf-598a-48f1-a39b-8b0263873188.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "c7063adf-598a-48f1-a39b-8b0263873188", 3 | "name": "ids", 4 | "prefix": "ids", 5 | "description": "IF EXISTS DROP: Synonym - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "IF OBJECT_ID('$CURSOR$') IS NOT NULL DROP SYNONYM ;", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/idt-08ee8abe-ac13-4ebe-a3a0-dd5b7d780926.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "08ee8abe-ac13-4ebe-a3a0-dd5b7d780926", 3 | "name": "idt", 4 | "prefix": "idt", 5 | "description": "IF EXISTS DROP: Table - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "IF OBJECT_ID('$CURSOR$') IS NOT NULL DROP TABLE ;", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/idtr-d1b02a3b-27ca-43be-a726-72f214f823ac.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "d1b02a3b-27ca-43be-a726-72f214f823ac", 3 | "name": "idtr", 4 | "prefix": "idtr", 5 | "description": "IF EXISTS DROP: Trigger - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "IF OBJECT_ID('$CURSOR$') IS NOT NULL DROP TRIGGER ;\nGO\n", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/idu-d190a9c3-8141-4a89-8cb6-802befbcbacd.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "d190a9c3-8141-4a89-8cb6-802befbcbacd", 3 | "name": "idu", 4 | "prefix": "idu", 5 | "description": "IF EXISTS DROP: User - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "IF USER_ID('$CURSOR$') IS NOT NULL DROP USER ;", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/idv-0e250b2b-5e69-49cb-94d8-756e776cd599.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "0e250b2b-5e69-49cb-94d8-756e776cd599", 3 | "name": "idv", 4 | "prefix": "idv", 5 | "description": "IF EXISTS DROP: View - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "IF OBJECT_ID('$CURSOR$') IS NOT NULL DROP VIEW ;\nGO\n", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/ifs-e2036955-99d3-490f-81bc-f7d3ecb61b69.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "e2036955-99d3-490f-81bc-f7d3ecb61b69", 3 | "name": "ifs", 4 | "prefix": "ifs", 5 | "description": "IF fragment", 6 | "body": "IF $condition$\nBEGIN\n $SELECTEDTEXT$$CURSOR$\nEND", 7 | "placeholders": [ 8 | { 9 | "name": "condition", 10 | "defaultValue": "1 = 1" 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/ii-abf2ee0e-791e-4815-b315-9b2ae3239a45.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "abf2ee0e-791e-4815-b315-9b2ae3239a45", 3 | "name": "ii", 4 | "prefix": "ii", 5 | "description": "INSERT INTO fragment", 6 | "body": "INSERT INTO ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/ij-8117ea6f-51f6-4099-aa52-a6366e73eafd.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "8117ea6f-51f6-4099-aa52-a6366e73eafd", 3 | "name": "ij", 4 | "prefix": "ij", 5 | "description": "INNER JOIN fragment", 6 | "body": "INNER JOIN ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/inn-5640d594-ec8d-4459-b996-20d5a58174d4.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "5640d594-ec8d-4459-b996-20d5a58174d4", 3 | "name": "inn", 4 | "prefix": "inn", 5 | "description": "Is Not Null", 6 | "body": "IS NOT NULL ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/is-b053855e-a834-4f4f-b334-3784278354b0.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "b053855e-a834-4f4f-b334-3784278354b0", 3 | "name": "is", 4 | "prefix": "is", 5 | "description": "Shortcut for INFORMATION_SCHEMA", 6 | "body": "INFORMATION_SCHEMA", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/isc-5c8bd23f-bb77-4ffa-8995-fd7e79c8f8c1.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "5c8bd23f-bb77-4ffa-8995-fd7e79c8f8c1", 3 | "name": "isc", 4 | "prefix": "isc", 5 | "description": "Column Information Grabber", 6 | "body": "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME LIKE '%$CURSOR$%' ORDER BY TABLE_SCHEMA, TABLE_NAME ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/isns-c85d2975-4de8-4b3a-8b21-cf28d762ebcd.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "c85d2975-4de8-4b3a-8b21-cf28d762ebcd", 3 | "name": "isns", 4 | "prefix": "isns", 5 | "description": "ISNULL STRING: WRAP CURRENT SELECTION IN ISNULL OPERATOR for a string", 6 | "body": "ISNULL($SELECTEDTEXT$, '$CURSOR$')", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/j-00d1410e-79cf-4d75-bf79-0c8ce5249612.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "00d1410e-79cf-4d75-bf79-0c8ce5249612", 3 | "name": "j", 4 | "prefix": "j", 5 | "description": "JOIN fragment", 6 | "body": "JOIN ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/lin-5b4717ca-f6e3-4cd9-b9f0-cebef0a00601.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "5b4717ca-f6e3-4cd9-b9f0-cebef0a00601", 3 | "name": "lin", 4 | "prefix": "lin", 5 | "description": "Line", 6 | "body": "--------------------------------------------------------------------------------", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/linn-7a2faf46-fa85-4f47-9009-35cd71d0be06.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "7a2faf46-fa85-4f47-9009-35cd71d0be06", 3 | "name": "linn", 4 | "prefix": "linn", 5 | "description": "Double line with space for text comment", 6 | "body": "--------------------------------------------------------------------------------\n-- $CURSOR$\n--------------------------------------------------------------------------------", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/lj-c334dacb-9403-4388-b212-ad397d1f7a86.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "c334dacb-9403-4388-b212-ad397d1f7a86", 3 | "name": "lj", 4 | "prefix": "lj", 5 | "description": "LEFT JOIN", 6 | "body": "LEFT JOIN ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/lk-3f5f2f0a-75af-42ca-8d3b-89abf9ce29ab.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "3f5f2f0a-75af-42ca-8d3b-89abf9ce29ab", 3 | "name": "lk", 4 | "prefix": "lk", 5 | "description": "like '% %'", 6 | "body": "LIKE '%$CURSOR$%'", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/loj-556b9599-3526-4891-ac9a-dad2081ba1c9.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "556b9599-3526-4891-ac9a-dad2081ba1c9", 3 | "name": "loj", 4 | "prefix": "loj", 5 | "description": "LEFT OUTER JOIN fragment", 6 | "body": "LEFT OUTER JOIN ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/mmddyyyy-d1b754e5-16bf-4f1f-a0d7-233f3d15d4c5.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "d1b754e5-16bf-4f1f-a0d7-233f3d15d4c5", 3 | "name": "mmddyyyy", 4 | "prefix": "mmddyyyy", 5 | "description": "MM/DD/YYYY (101) Date Format", 6 | "body": "CONVERT(VARCHAR(10), $column_name$, 101) AS $alias$", 7 | "placeholders": [ 8 | { 9 | "name": "alias", 10 | "defaultValue": "" 11 | }, 12 | { 13 | "name": "column_name", 14 | "defaultValue": "" 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/mmddyyyyhhmm-add4cbf9-cf13-4e71-a8bb-c717acf3a1b4.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "add4cbf9-cf13-4e71-a8bb-c717acf3a1b4", 3 | "name": "mmddyyyyhhmm", 4 | "prefix": "mmddyyyyhhmm", 5 | "description": "Month - Day - Year - hour - minute", 6 | "body": "CONVERT(VARCHAR(10), $date_column$, 101) + ' ' + LEFT(CONVERT(VARCHAR(8), $date_column$, 108),5) as $alias$", 7 | "placeholders": [ 8 | { 9 | "name": "date_column", 10 | "defaultValue": "" 11 | }, 12 | { 13 | "name": "alias", 14 | "defaultValue": "" 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/mro-9f4793b9-82ac-4b2f-b8d2-04121ce04202.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "9f4793b9-82ac-4b2f-b8d2-04121ce04202", 3 | "name": "mro", 4 | "prefix": "mro", 5 | "description": "Retrieves information about 20 most recently created objects from database", 6 | "body": "SELECT TOP 20 [name], [type], crdate\nFROM sysobjects\nORDER BY crdate DESC", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/num-b62377c6-24e5-412b-8323-6c8eba37990d.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "b62377c6-24e5-412b-8323-6c8eba37990d", 3 | "name": "num", 4 | "prefix": "num", 5 | "description": "Format a big number into a readable format", 6 | "body": "FORMAT($CURSOR$,'#,##0')", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/numc-9f61ad71-b9e4-45bb-8700-f139fcaa275f.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "9f61ad71-b9e4-45bb-8700-f139fcaa275f", 3 | "name": "numc", 4 | "prefix": "numc", 5 | "description": "Nicely formatted COUNT(*) as numRows", 6 | "body": "FORMAT(COUNT(*),'#,##0') AS NumRows ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/nvseq-eecdc143-2087-44a7-80b6-aacdc62312d0.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "eecdc143-2087-44a7-80b6-aacdc62312d0", 3 | "name": "nvseq", 4 | "prefix": "nvseq", 5 | "description": "Next Value from a Sequence", 6 | "body": "SELECT NEXT VALUE FOR $SchemaName$.$SequenceName$ as $Alias$; ", 7 | "placeholders": [ 8 | { 9 | "name": "SchemaName", 10 | "defaultValue": "" 11 | }, 12 | { 13 | "name": "SequenceName", 14 | "defaultValue": "" 15 | }, 16 | { 17 | "name": "Alias", 18 | "defaultValue": "NextValue" 19 | } 20 | ] 21 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/ob-bc85e3d9-27d6-43be-aff2-21413bf476d3.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "bc85e3d9-27d6-43be-aff2-21413bf476d3", 3 | "name": "ob", 4 | "prefix": "ob", 5 | "description": "ORDER BY", 6 | "body": "ORDER BY ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/per-a43b59b0-1e21-4de5-8340-2f964dff6a4c.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "a43b59b0-1e21-4de5-8340-2f964dff6a4c", 3 | "prefix": "per", 4 | "description": "ES: SQL Server Permissions (Users, Roles, Securables)", 5 | "body": "--Database Users\nSELECT\n Username = name\n ,create_date\n ,modify_date\n ,type = type_desc\n ,authentication_type = authentication_type_desc\nFROM\n sys.database_principals\nWHERE\n type NOT IN ( 'A', 'G', 'R' )\n AND sid IS NOT NULL\nORDER BY\n Username;\n\n\n--Role Members\nSELECT\n DatabaseRoleName = DP1.name\n ,DatabaseUserName = ISNULL(DP2.name, 'No members')\nFROM\n sys.database_role_members AS DRM\n RIGHT OUTER JOIN sys.database_principals AS DP1 ON DRM.role_principal_id = DP1.principal_id\n LEFT OUTER JOIN sys.database_principals AS DP2 ON DRM.member_principal_id = DP2.principal_id\nWHERE\n DP1.type = 'R'\nORDER BY\n DP1.name;\n\n\n--Role Securables\nSELECT\n Securable = 'GRANT ' + perm.permission_name + ' ON '\n + CASE perm.class_desc\n WHEN 'SCHEMA' THEN\n SCHEMA_NAME(perm.major_id)\n WHEN 'OBJECT_OR_COLUMN' THEN\n CASE\n WHEN perm.minor_id = 0 THEN\n OBJECT_NAME(perm.major_id)COLLATE Latin1_General_CI_AS_KS_WS\n ELSE\n (\n SELECT\n OBJECT_NAME(object_id) + ' (' + name + ')'\n FROM\n sys.columns\n WHERE\n object_id = perm.major_id\n AND column_id = perm.minor_id\n )\n END\n ELSE\n 'other'\n END + ' TO ' + prin.name COLLATE Latin1_General_CI_AS_KS_WS\nFROM\n sys.database_permissions AS perm\n INNER JOIN sys.database_principals AS prin ON perm.grantee_principal_id = prin.principal_id\n LEFT JOIN sys.objects AS o ON o.object_id = perm.major_id -- consider schemas\nWHERE\n perm.major_id > 0\n AND perm.permission_name IN ( 'SELECT', 'INSERT', 'UPDATE', 'DELETE' );" 6 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/pvt-48864df4-c52a-4265-ba34-1a475cf9a092.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "48864df4-c52a-4265-ba34-1a475cf9a092", 3 | "prefix": "pvt", 4 | "description": "ES: Pivot a query when there are too many columns to scroll sideways through.", 5 | "body": "DECLARE @stmt nvarchar(MAX) = N'SELECT\r\n P.[key] as ColumnName,\r\n P.value as ColumnValue\r\nFROM\r\n (' +\r\nN'\r\n$SELECTEDTEXT$\r\n'\r\n+ N' FOR JSON AUTO, WITHOUT_ARRAY_WRAPPER, INCLUDE_NULL_VALUES) AS SQL(JSON)\r\nCROSS APPLY \r\n OPENJSON(SQL.JSON) AS P;';\r\nEXECUTE sys.sp_executesql @stmt = @stmt;" 6 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/rj-97c9a8ef-fae2-4d91-9cb5-bf1329f04404.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "97c9a8ef-fae2-4d91-9cb5-bf1329f04404", 3 | "name": "rj", 4 | "prefix": "rj", 5 | "description": "RIGHT JOIN fragment", 6 | "body": "RIGHT JOIN ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/rnum-7e12b596-6b70-44bb-ba33-735a17d3e8c4.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "7e12b596-6b70-44bb-ba33-735a17d3e8c4", 3 | "name": "rnum", 4 | "prefix": "rnum", 5 | "description": "ROW_NUMBER() OVER () fragment", 6 | "body": "ROW_NUMBER() OVER (ORDER BY $SELECTIONSTART$somecol$SELECTIONEND$) ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/roj-6b6ec907-f87e-4c08-aca1-e0f61e5ca9cc.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "6b6ec907-f87e-4c08-aca1-e0f61e5ca9cc", 3 | "name": "roj", 4 | "prefix": "roj", 5 | "description": "RIGHT OUTER JOIN fragment", 6 | "body": "RIGHT OUTER JOIN ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/rt-fc3d2f65-85d4-40ab-9dc3-21ba593e9ab4.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "fc3d2f65-85d4-40ab-9dc3-21ba593e9ab4", 3 | "name": "rt", 4 | "prefix": "rt", 5 | "description": "Rollback transaction", 6 | "body": "ROLLBACK TRANSACTION", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/san-6654906d-f2ec-400d-be64-3e45afff3ed8.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "6654906d-f2ec-400d-be64-3e45afff3ed8", 3 | "name": "san", 4 | "prefix": "san", 5 | "description": "Change the current ANSI_NULLS setting", 6 | "body": "SET ANSI_NULLS ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/scf-3efeb915-d830-4c47-9056-2518d771cb8f.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "3efeb915-d830-4c47-9056-2518d771cb8f", 3 | "name": "scf", 4 | "prefix": "scf", 5 | "description": "Count number of records returned by query, formatted nicely", 6 | "body": "SELECT FORMAT(COUNT(*),'#,##0') FROM ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/sd-e03a2401-dbaf-4017-b1b7-3b541a20b2a3.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "e03a2401-dbaf-4017-b1b7-3b541a20b2a3", 3 | "name": "sd", 4 | "prefix": "sd", 5 | "description": "SELECT DISTINCT", 6 | "body": "SELECT DISTINCT ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/setvar-3b5a7fe2-bda9-473b-abbc-48f72272eb60.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "3b5a7fe2-bda9-473b-abbc-48f72272eb60", 3 | "name": "setvar", 4 | "prefix": "setvar", 5 | "description": "SQL CMD setvar fragment", 6 | "body": ":setvar $CURSOR$ \"RealValue\" --ALT Q M to toggle SQL CMD mode", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/smf-cefe535f-adae-47e9-b329-6df61ec5f92f.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "cefe535f-adae-47e9-b329-6df61ec5f92f", 3 | "name": "smf", 4 | "prefix": "smf", 5 | "description": "SELECT SUM() FROM", 6 | "body": "SELECT FORMAT(SUM($CURSOR$),'#,##0') FROM ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/sph-82a89101-2cdb-48ad-a059-5a791958f399.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "82a89101-2cdb-48ad-a059-5a791958f399", 3 | "name": "sph", 4 | "prefix": "sph", 5 | "description": "Execute sp_help", 6 | "body": "EXEC sp_help", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/spt-51290a9c-5955-4f7f-bc38-b1bf150408be.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "51290a9c-5955-4f7f-bc38-b1bf150408be", 3 | "name": "spt", 4 | "prefix": "spt", 5 | "description": "Execute sp_helptext", 6 | "body": "EXEC sp_helptext", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/sqi-722928c6-e62c-4e24-95bc-c53b8ee20af4.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "722928c6-e62c-4e24-95bc-c53b8ee20af4", 3 | "name": "sqi", 4 | "prefix": "sqi", 5 | "description": "Change the current QUOTED_IDENTIFIER setting", 6 | "body": "SET QUOTED_IDENTIFIER ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/ss0-d2e91135-a38b-4aac-91e1-5137fc3bf81f.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "d2e91135-a38b-4aac-91e1-5137fc3bf81f", 3 | "name": "ss0", 4 | "prefix": "ss0", 5 | "description": "SELECT TOP 0 * FROM", 6 | "body": "SELECT TOP 0 * FROM ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/ssf-da5bee9a-e757-41e7-a55c-b13ff0080ac9.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "da5bee9a-e757-41e7-a55c-b13ff0080ac9", 3 | "name": "ssf", 4 | "prefix": "ssf", 5 | "description": "SELECT * FROM fragment", 6 | "body": "SELECT * FROM ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/ssf2-5e77e99a-6563-4184-9d6a-85b0d00f3384.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "5e77e99a-6563-4184-9d6a-85b0d00f3384", 3 | "name": "ssf2", 4 | "prefix": "ssf2", 5 | "description": "SELECT * FROM fragment. Formatted nicely with tabs and new lines.", 6 | "body": "SELECT \t* \nFROM \t$CURSOR$", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/sst-4b208cf2-995f-41ac-9883-ff9ad9790b54.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "4b208cf2-995f-41ac-9883-ff9ad9790b54", 3 | "prefix": "sst", 4 | "description": "SELECT TOP 1000 * FROM", 5 | "body": "SELECT TOP (1000) * FROM " 6 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/st100-a0f36423-8b7e-432b-8abb-94fa37f82122.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "a0f36423-8b7e-432b-8abb-94fa37f82122", 3 | "name": "st100", 4 | "prefix": "st100", 5 | "description": "SELECT top 100 rows", 6 | "body": "SELECT TOP (100) * FROM $CURSOR$", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/strip-ee654fea-7302-4cea-be9d-dc219d65c579.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "ee654fea-7302-4cea-be9d-dc219d65c579", 3 | "prefix": "strip", 4 | "description": "ES: This code will strip out unwanted characters and only keep the characters in the @WantedCharacters variable.", 5 | "body": "DECLARE @WantedCharacters nvarchar(100) = N' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; /* Without the space it errors. It is replaced inline. */\r\n\r\nSELECT\r\n OriginalString = v.OriginalString\r\n ,TransformedString = \r\n REPLACE(\r\n REPLACE(\r\n TRANSLATE(\r\n v.OriginalString, \r\n REPLACE(\r\n TRANSLATE(\r\n v.OriginalString \r\n ,@WantedCharacters, \r\n REPLICATE('a', LEN(@WantedCharacters))\r\n )\r\n ,'a'\r\n ,''\r\n ), \r\n REPLICATE(\r\n '0'\r\n ,LEN(\r\n REPLACE(\r\n TRANSLATE(\r\n v.OriginalString\r\n ,@WantedCharacters\r\n ,REPLICATE('a', LEN(@WantedCharacters))\r\n )\r\n ,'a'\r\n ,''\r\n )\r\n )\r\n )\r\n )\r\n ,'0'\r\n ,''\r\n )\r\n ,' ', '')\r\nFROM (\r\n VALUES\r\n (N'Add sample strings in this values list.')\r\n ,(N'abc1234def5678ghi90jkl#@$&')\r\n ,(N'1234567890$@爱')\r\n ,(N'a line')\r\n ,(NULL)\r\n ,(N'JAHDBESBN%*#*@*($E*sd55bn')\r\n ,(N'Some text, other text. ''.,!?/<>\"[]{}|`~@#$%^&*()-+=/\\:;\r\n\r\nAfter a CR/LF!' + +CHAR(13)+CHAR(10)+CHAR(9) + N'After CR/LF & tab character.')\r\n) AS v (OriginalString);" 6 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/sxa-fa1005d3-b116-4f79-aae4-a7004fdaedb8.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "fa1005d3-b116-4f79-aae4-a7004fdaedb8", 3 | "name": "sxa", 4 | "prefix": "sxa", 5 | "description": "Change the current XACT_ABORT setting", 6 | "body": "SET XACT_ABORT ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tab-9b7accb0-9b99-4e8b-875c-85b59003e98a.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "9b7accb0-9b99-4e8b-875c-85b59003e98a", 3 | "name": "tab", 4 | "prefix": "tab", 5 | "description": "tSQLt: about - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "/*\n -----------------\n -- About tSQLt --\n -----------------\n\ntSQLt is an open source unit testing framework for SQL Server. \ntSQLt is coauthored by:\n- Dennis Lloyd Jr. ( @dennislloydjr | http://curiouslycorrect.com/ )\n- Sebastian Meine ( @sqlity | http://sqlity.net )\n\nYou can download tSQLt at http://tSQLt.org/downloads\nA more complete set of SQL Prompt snippets is available there too.\n\ntSQLt provides an array of procedures that help you to write robust test cases\nby isolating dependencies (e.g. tSQLt.FakeTable or tSQLt.SpyProcedure) and \nasserting correct behavior (e.g. tSQLt.AssertEqualsTable or tSQLt.ExpectException).\n\nTo create a test, you first need to create a schema using the tSQLt.NewTextClass\nprocedure. Any procedure that lives in such a schema and that has a name that \nbegins with the four letters \"test\" is considdered a test case. To execute a test\njust run tSQLt.Run passing in either the schema name or the fully qualified\ntest case name. To execute all test cases in the database run tSQLt.RunAll\n\nYou can find the tSQLt manual and examples at http://tsqlt.org/user-guide/\n\nTo check the version of tSQLt that is currently installed execute this query:\nSELECT * FROM tSQLt.Info();\nThe Version and the ClrVersion should always match.\n\nFor an easier way to manage and execute your tests check out Red Gate SQL Test.\n\nBelow is a test case template that also explains the three parts that every \ntest should contain.\n*/\nGO\n-- Comments here are associated with the test.\n-- For test case examples, see: http://tsqlt.org/user-guide/tsqlt-tutorial/\nCREATE PROCEDURE [].[]\nAS\nBEGIN\n --Assemble\n -- This section is for code that sets up the environment. It often\n -- contains calls to methods such as tSQLt.FakeTable and tSQLt.SpyProcedure\n -- along with INSERTs of relevant data.\n -- For more information, see http://tsqlt.org/user-guide/isolating-dependencies/\n \n --Act\n -- Execute the code under test like a stored procedure, function or view\n -- and capture the results in variables or tables.\n \n --Assert\n -- Compare the expected and actual values, or call tSQLt.Fail in an IF statement. \n -- Typical Asserts: tSQLt.AssertEquals, tSQLt.AssertEqualsString, tSQLt.AssertEqualsTable\n -- For a complete list, see: http://tsqlt.org/user-guide/assertions/\n EXEC tSQLt.Fail 'TODO:Implement this test.'\n \nEND;\nGO\n\n", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tac-b02f94ad-b956-478c-8ce9-7e12e1e0cd7d.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "b02f94ad-b956-478c-8ce9-7e12e1e0cd7d", 3 | "name": "tac", 4 | "prefix": "tac", 5 | "description": "tSQLt.ApplyConstraint - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.ApplyConstraint @TableName = '$CURSOR$', @ConstraintName = '';", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tal-c5da142c-49b6-4685-9897-d0cf15ab64eb.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "c5da142c-49b6-4685-9897-d0cf15ab64eb", 3 | "name": "tal", 4 | "prefix": "tal", 5 | "description": "tSQLt.AssertLike - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.AssertLike @ExpectedPattern = '$CURSOR$', @Actual;", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tat-988f529c-7926-427b-b244-1aaacbd8bf41.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "988f529c-7926-427b-b244-1aaacbd8bf41", 3 | "name": "tat", 4 | "prefix": "tat", 5 | "description": "tSQLt.ApplyTrigger - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.ApplyTrigger @TableName = '$CURSOR$', @TriggerName = '';", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tc-5b72fd4a-4fe0-41f8-ac20-3e187d7ff805.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "5b72fd4a-4fe0-41f8-ac20-3e187d7ff805", 3 | "name": "tc", 4 | "prefix": "tc", 5 | "description": "TRY ... CATCH fragment", 6 | "body": "BEGIN TRY\n $SELECTEDTEXT$\nEND TRY\nBEGIN CATCH\n $CURSOR$\nEND CATCH", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tca-41af3a3e-7ac3-4956-b829-c150c40ec7d1.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "41af3a3e-7ac3-4956-b829-c150c40ec7d1", 3 | "name": "tca", 4 | "prefix": "tca", 5 | "description": "tSQLt: SELECT INTO #Actual - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "SELECT *\nINTO #Actual\nFROM $CURSOR$;\n", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tce-652a18d3-44ac-4f7f-b874-e3ae4d27fc19.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "652a18d3-44ac-4f7f-b874-e3ae4d27fc19", 3 | "name": "tce", 4 | "prefix": "tce", 5 | "description": "tSQLt: create #Expected from #Actual - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "SELECT TOP(0) A.* INTO #Expected FROM #Actual A RIGHT JOIN #Actual X ON 1=0;\n", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tco-d482823f-9db6-4b4e-b5bf-7a4e638ac197.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "d482823f-9db6-4b4e-b5bf-7a4e638ac197", 3 | "name": "tco", 4 | "prefix": "tco", 5 | "description": "tSQLt.CaptureOutput - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.CaptureOutput '$CURSOR$';\n\nSELECT * \n INTO #Actual\n FROM tSQLt.CaptureOutputLog;\n\n", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tct-da925080-ff0e-4d4b-9ac7-b7c1216b69a4.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "da925080-ff0e-4d4b-9ac7-b7c1216b69a4", 3 | "name": "tct", 4 | "prefix": "tct", 5 | "description": "tSQLt: Create Test - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "CREATE PROCEDURE $CURSOR$.[test ]\nAS\nBEGIN\n\nEND;\nGO\n", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/te-9dc51561-fbd0-48d2-ac5f-65e662216b8f.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "9dc51561-fbd0-48d2-ac5f-65e662216b8f", 3 | "name": "te", 4 | "prefix": "te", 5 | "description": "tSQLt.AssertEquals - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.AssertEquals @Expected = '$CURSOR$', @Actual;", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tes-31eb4d04-d6af-4896-b876-299ea1801285.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "31eb4d04-d6af-4896-b876-299ea1801285", 3 | "name": "tes", 4 | "prefix": "tes", 5 | "description": "tSQLt.AssertEqualsString - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.AssertEqualsString @Expected = '$CURSOR$', @Actual;", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tet-31701e8b-b14d-44ed-b830-92729f6e5dcd.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "31701e8b-b14d-44ed-b830-92729f6e5dcd", 3 | "name": "tet", 4 | "prefix": "tet", 5 | "description": "tSQLt.AssertEqualsTable - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.AssertEqualsTable '#Expected','#Actual';\n", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tf-6e743807-1b8e-47a8-8b9d-bea4eae4da2a.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "6e743807-1b8e-47a8-8b9d-bea4eae4da2a", 3 | "name": "tf", 4 | "prefix": "tf", 5 | "description": "tSQLt.Fail - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.Fail '$CURSOR$';", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tff-9cda5178-8ac7-4ce7-9130-26095e1f18f8.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "9cda5178-8ac7-4ce7-9130-26095e1f18f8", 3 | "name": "tff", 4 | "prefix": "tff", 5 | "description": "tSQLt.FakeFunction - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.FakeFunction @FunctionName = '$CURSOR$', @FakeFunctionName = '';", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tft-2d8c5136-2612-4360-a3d1-a76c0d4f4262.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "2d8c5136-2612-4360-a3d1-a76c0d4f4262", 3 | "name": "tft", 4 | "prefix": "tft", 5 | "description": "tSQLt.FakeTable - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.FakeTable @TableName = '$CURSOR$', @Identity = 0, @ComputedColumns = 0, @Defaults = 0;", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tie-0c94bf8a-c3e1-4291-b33e-82f9d1bf32e3.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "0c94bf8a-c3e1-4291-b33e-82f9d1bf32e3", 3 | "name": "tie", 4 | "prefix": "tie", 5 | "description": "tSQLt: INSERT INTO #Expected - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "INSERT INTO #Expected\nVALUES($CURSOR$);", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/timings-7d383e40-1a19-486e-957e-ccafc12e2309.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "7d383e40-1a19-486e-957e-ccafc12e2309", 3 | "name": "timings", 4 | "prefix": "timings", 5 | "description": "Wraps a simple timings test harness around the selected code", 6 | "body": "/**\nBased on code by Phil Factor (https://www.red-gate.com/hub/product-learning/sql-prompt/record-t-sql-execution-times-using-sql-prompt-snippet).\n**/\nDECLARE @log table\n(\n TheOrder int IDENTITY(1, 1),\n WhatHappened varchar(200),\n WhenItDid datetime2 DEFAULT GETDATE()\n)\n----start of timing\nINSERT INTO @log(WhatHappened)\nSELECT 'Starting $routine$' --place at the start\n \n$SELECTEDTEXT$$CURSOR$\n \n--where the routine you want to time ends\nINSERT INTO @log(WhatHappened)\nSELECT '$routine$ took '\nSELECT ending.WhatHappened, DATEDIFF(ms, starting.WhenItDid, ending.WhenItDid)\nFROM @log starting\n INNER JOIN @log ending\n ON ending.TheOrder = starting.TheOrder + 1\n--list out all the timings", 7 | "placeholders": [ 8 | { 9 | "name": "routine", 10 | "defaultValue": "" 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tmt-07a9ca4a-7a46-4d48-b769-458dfb67c936.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "07a9ca4a-7a46-4d48-b769-458dfb67c936", 3 | "name": "tmt", 4 | "prefix": "tmt", 5 | "description": "tSQLt.AssertEmptyTable - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.AssertEmptyTable @TableName = '$CURSOR$';", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tnc-15a24b82-208b-4d01-a3d2-6d0bf68519a9.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "15a24b82-208b-4d01-a3d2-6d0bf68519a9", 3 | "name": "tnc", 4 | "prefix": "tnc", 5 | "description": "tSQLt.NewConnection - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.NewConnection @command='$CURSOR$';", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tne-f07f828e-5e54-4631-9ff3-bf66a155053e.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "f07f828e-5e54-4631-9ff3-bf66a155053e", 3 | "name": "tne", 4 | "prefix": "tne", 5 | "description": "tSQLt.AssertNotEquals - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.AssertNotEquals @Expected = '$CURSOR$', @Actual;", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tnt-f18d091b-ba00-4485-ad31-f28705162c40.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "f18d091b-ba00-4485-ad31-f28705162c40", 3 | "name": "tnt", 4 | "prefix": "tnt", 5 | "description": "tSQLt.NewTestClass - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.NewTestClass '$CURSOR$';\nGO\nCREATE PROCEDURE .[test ]\nAS\nBEGIN\n\nEND;\nGO\n", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/today-a03dee51-9fe5-4a93-a8d0-1b41e9a92cd6.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "a03dee51-9fe5-4a93-a8d0-1b41e9a92cd6", 3 | "name": "today", 4 | "prefix": "today", 5 | "description": "CAST(GETDATE() as date)", 6 | "body": "CAST(GETDATE() as DATE)", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/toe-f9e123af-79cf-4755-a61a-5e1431f74c89.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "f9e123af-79cf-4755-a61a-5e1431f74c89", 3 | "name": "toe", 4 | "prefix": "toe", 5 | "description": "tSQLt.AssertObjectExists - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.AssertObjectExists @ObjectName = '$CURSOR$';", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tpc-cec1a30a-2c83-44a9-90de-cd529921d095.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "cec1a30a-2c83-44a9-90de-cd529921d095", 3 | "name": "tpc", 4 | "prefix": "tpc", 5 | "description": "tSQLt: Test Pattern - Current Event - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "DECLARE @actual DATETIME2;\nDECLARE @after DATETIME2;\nDECLARE @before DATETIME2;\n\nSET @before = SYSUTCDATETIME(); \n\nEXEC $CURSOR$\n\nSET @after = SYSUTCDATETIME(); \n\nSELECT @actual = \nFROM \n\nIF(@actual < @before OR @actual > @after OR @actual IS NULL)\nBEGIN\n DECLARE @msg NVARCHAR(MAX) = \n 'Expected:'+\n CONVERT(NVARCHAR(MAX),@before,121)+\n ' <= '+\n ISNULL(CONVERT(NVARCHAR(MAX),@actual,121),'!NULL!')+\n ' <= '+\n CONVERT(NVARCHAR(MAX),@after,121);\n EXEC tSQLt.Fail @msg;\nEND;\n\n", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/trf-db5a83c1-3d10-49d9-86af-0bc433b9e6d6.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "db5a83c1-3d10-49d9-86af-0bc433b9e6d6", 3 | "name": "trf", 4 | "prefix": "trf", 5 | "description": "tSQLt.ResultSetFilter - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.ResultSetFilter @ResultsetNo = 1, @Command = '$CURSOR$';", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/trim-dc639ce6-2362-496b-ba66-dd244381b366.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "dc639ce6-2362-496b-ba66-dd244381b366", 3 | "name": "trim", 4 | "prefix": "trim", 5 | "description": "Left and Right Trim", 6 | "body": "LTRIM(RTRIM($CURSOR$))", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/trims-7e909586-9924-4eb8-84b2-613a707eea83.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "7e909586-9924-4eb8-84b2-613a707eea83", 3 | "name": "trims", 4 | "prefix": "trims", 5 | "description": "Wrap selected text in LTRIM(RTRIM())", 6 | "body": "LTRIM(RTRIM($SELECTEDTEXT$))", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/trn-5ba594b3-5c5b-4644-836c-ad77f78c3de5.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "5ba594b3-5c5b-4644-836c-ad77f78c3de5", 3 | "prefix": "trn", 4 | "description": "ES: Wrap the selected text in a transaction uncomment for concurrency catch if needed.", 5 | "body": "BEGIN TRY\r\n BEGIN TRANSACTION;\r\n\r\n $SELECTEDTEXT$\r\n\r\n /* \r\n IF @@ROWCOUNT = 0\r\n BEGIN\r\n ; THROW 52001, 'The record you attempted to delete was modified by another user after you received the original values! The delete operation was canceled. If you still want to delete this record, click the Delete button again.', 1;\r\n ; THROW 52001, 'The record you attempted to save was modified by another user after you received the original values! The save operation was canceled, and the current values have been displayed. If you still want to update this record, click the Save button again.', 1;\r\n /* Use RAISERROR below if you do not need a hard error thrown.\r\n RAISERROR(N'The record you attempted to delete was modified by another user after you received the original values! The delete operation was canceled. If you still want to delete this record, click the Delete button again.', 1, 1) WITH NOWAIT;\r\n RETURN -1;*/\r\n END; \r\n */\r\n\r\n COMMIT TRANSACTION;\r\nEND TRY\r\nBEGIN CATCH\r\n IF @@TRANCOUNT > 0\r\n BEGIN\r\n ROLLBACK TRANSACTION;\r\n END;\r\n\r\n /* Handle the error here, cleanup, et cetera.\r\n In most cases it is best to bubble up (THROW) the error to the application/client to be displayed to the user and logged.\r\n */\r\n THROW;\r\nEND CATCH;" 6 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tro-364d732f-df4e-4f0b-9969-7394e2e8badb.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "364d732f-df4e-4f0b-9969-7394e2e8badb", 3 | "name": "tro", 4 | "prefix": "tro", 5 | "description": "tSQLt.RemoveObject - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.RemoveObject @ObjectName = '$CURSOR$';", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tso-d2cf62bc-246d-4d29-896d-4685a791c63c.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "d2cf62bc-246d-4d29-896d-4685a791c63c", 3 | "name": "tso", 4 | "prefix": "tso", 5 | "description": "tSQLt.SuppressOutput - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.SuppressOutput @command = '$CURSOR$';", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tsp-557e6746-23a5-4ac0-8620-3a930a0df08e.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "557e6746-23a5-4ac0-8620-3a930a0df08e", 3 | "name": "tsp", 4 | "prefix": "tsp", 5 | "description": "tSQLt.SpyProcedure - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.SpyProcedure @ProcedureName = '$CURSOR$', @CommandToExecute = NULL;", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tt-0c7e21b2-0c24-4847-870f-696b07f72a00.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "0c7e21b2-0c24-4847-870f-696b07f72a00", 3 | "name": "tt", 4 | "prefix": "tt", 5 | "description": "Truncate Table", 6 | "body": "TRUNCATE TABLE ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/tvc-fc6f60d1-0637-4786-8223-e9bb81f9d92a.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "fc6f60d1-0637-4786-8223-e9bb81f9d92a", 3 | "name": "tvc", 4 | "prefix": "tvc", 5 | "description": "ES: Automatically create a table variable (or temp table) in which to store the results of (for example) executing a stored procedure, function or query", 6 | "body": "/**\nSummary: >\nThis is a temporary batch for creating such things as table variables,\ntemporary tables or anything else that needs a column list \nAuthor: Phil Factor\nBased on code from https://www.red-gate.com/hub/product-learning/sql-prompt/building-reusable-table-build-scripts-using-sql-prompt\n**/\nDeclare @TheExpression NVARCHAR(MAX)=\nN'$SELECTEDTEXT$'\n\nSELECT 'DECLARE @$TableVariable$ table ('+\n Stuff ((SELECT ',\n '+QuoteName(Coalesce(DetectDuplicateNames.name+'_'+Convert(VARCHAR(5),f.column_ordinal),f.name))\n + ' '+ System_type_name + CASE WHEN is_nullable = 0 THEN ' NOT' ELSE ''END+' NULL'\n --+ CASE WHEN collation_name IS NULL THEN '' ELSE ' COLLATE '+collation_name END\n AS ThePath\n FROM sys.dm_exec_describe_first_result_set\n (@TheExpression, NULL, 1) AS f\n -- use sys.sp_describe_first_result_set for a batch\n LEFT OUTER JOIN \n (SELECT name AS name FROM sys.dm_exec_describe_first_result_set\n (@TheExpression, NULL, 0) WHERE is_hidden=0 \n GROUP BY name HAVING Count(*)>1) AS DetectDuplicateNames\n ON DetectDuplicateNames.name=f.name\n WHERE f.is_hidden=0\nORDER BY column_ordinal\nFOR XML PATH (''), TYPE).value('.', 'varchar(max)'),1,1,'')+')'", 7 | "placeholders": [ 8 | { 9 | "name": "TableVariable", 10 | "defaultValue": "" 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/txe-4c563904-edde-48d9-ade3-5f294ab301da.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "4c563904-edde-48d9-ade3-5f294ab301da", 3 | "name": "txe", 4 | "prefix": "txe", 5 | "description": "tSQLt.ExpectException - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.ExpectException @ExpectedMessage = '$CURSOR$', @ExpectedSeverity = NULL, @ExpectedState = NULL;", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/txn-22b5775e-43a9-453a-a8ee-c1ba1014252d.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "22b5775e-43a9-453a-a8ee-c1ba1014252d", 3 | "name": "txn", 4 | "prefix": "txn", 5 | "description": "tSQLt.ExpectNoException - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.ExpectNoException;\n", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/txp-457a18fb-aac4-4c8f-8d37-389c64e9452d.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "457a18fb-aac4-4c8f-8d37-389c64e9452d", 3 | "name": "txp", 4 | "prefix": "txp", 5 | "description": "tSQLt.ExpectException:Pattern - [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]", 6 | "body": "EXEC tSQLt.ExpectException @ExpectedMessagePattern = '$CURSOR$', @ExpectedSeverity = NULL, @ExpectedState = NULL;", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/uci-1d8d3e81-30d3-4cab-9e85-be8a845817ef.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "1d8d3e81-30d3-4cab-9e85-be8a845817ef", 3 | "name": "uci", 4 | "prefix": "uci", 5 | "description": "Unique Clustered Index", 6 | "body": "UNIQUE CLUSTERED INDEX uci ON ", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/w2-8d1cfff9-3850-46d2-b6ed-99376104e804.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "8d1cfff9-3850-46d2-b6ed-99376104e804", 3 | "name": "w2", 4 | "prefix": "w2", 5 | "description": "Execute sp_who2", 6 | "body": "EXEC sp_who2", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/wdc-9691418f-fb24-4824-937c-3e9ce3cd544e.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "9691418f-fb24-4824-937c-3e9ce3cd544e", 3 | "name": "wdc", 4 | "prefix": "wdc", 5 | "description": "WITH (DATA_COMPRESSION = PAGE)", 6 | "body": "WITH (DATA_COMPRESSION = PAGE)", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/wn-1f487fd4-2350-4846-aac5-ce856c4df6c3.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "1f487fd4-2350-4846-aac5-ce856c4df6c3", 3 | "name": "wn", 4 | "prefix": "wn", 5 | "description": "WITH (NOLOCK)", 6 | "body": "WITH (NOLOCK)", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/wt-b3c14629-861f-48e0-95ed-dbb2e5a3d185.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "b3c14629-861f-48e0-95ed-dbb2e5a3d185", 3 | "name": "wt", 4 | "prefix": "wt", 5 | "description": "WITH (TABLOCK)", 6 | "body": "WITH (TABLOCK)", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Snippets/xpfd-df4b3d19-aa14-43ad-8b27-7fd6963ec199.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "df4b3d19-aa14-43ad-8b27-7fd6963ec199", 3 | "name": "xpfd", 4 | "prefix": "xpfd", 5 | "description": "Retrieve free space on all fixed drives", 6 | "body": "EXEC master..xp_fixeddrives", 7 | "placeholders": [] 8 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Styles/Kevin Martin-b9530d2c-850d-46b0-b8b4-51a5899a376e.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "id": "b9530d2c-850d-46b0-b8b4-51a5899a376e", 4 | "name": "Kevin Martin" 5 | }, 6 | "lists": { 7 | "placeFirstItemOnNewLine": "always", 8 | "alignSubsequentItemsWithFirstItem": false, 9 | "alignItemsAcrossClauses": false, 10 | "alignAliases": true, 11 | "alignComments": true, 12 | "placeCommasBeforeItems": true, 13 | "addSpaceAfterComma": false 14 | }, 15 | "parentheses": { 16 | "parenthesisStyle": "expandedSplit", 17 | "indentParenthesesContents": true, 18 | "collapseShortParenthesisContents": true, 19 | "collapseParenthesesShorterThan": 55 20 | }, 21 | "casing": { 22 | "reservedKeywords": "uppercase", 23 | "builtInFunctions": "uppercase", 24 | "builtInDataTypes": "lowercase", 25 | "useObjectDefinitionCase": true 26 | }, 27 | "dml": { 28 | "addNewLineAfterDistinctAndTopClauses": true, 29 | "collapseShortStatements": true, 30 | "collapseStatementsShorterThan": 78, 31 | "collapseShortSubqueries": true, 32 | "collapseSubqueriesShorterThan": 78, 33 | "listItems": { 34 | "placeFromTableOnNewLine": "always", 35 | "placeWhereConditionOnNewLine": "always", 36 | "placeGroupByAndOrderByOnNewLine": "always" 37 | } 38 | }, 39 | "ddl": { 40 | "parenthesisStyle": "expandedSplit", 41 | "indentParenthesesContents": true, 42 | "alignDataTypesAndConstraints": true, 43 | "placeConstraintColumnsOnNewLines": "ifLongerOrMultipleColumns", 44 | "indentClauses": true, 45 | "placeFirstProcedureParameterOnNewLine": "always", 46 | "collapseShortStatements": true, 47 | "collapseStatementsShorterThan": 100 48 | }, 49 | "controlFlow": { 50 | "indentBeginAndEndKeywords": true, 51 | "collapseStatementsShorterThan": 120 52 | }, 53 | "cte": { 54 | "parenthesisStyle": "expandedSplit", 55 | "indentContents": true, 56 | "placeColumnsOnNewLine": true, 57 | "columnAlignment": "indented", 58 | "asAlignment": "rightAligned" 59 | }, 60 | "variables": { 61 | "placeAssignedValueOnNewLineIfLongerThanMaxLineLength": false 62 | }, 63 | "joinStatements": { 64 | "join": { 65 | "indentJoinTable": false 66 | }, 67 | "on": { 68 | "placeOnNewLine": false, 69 | "keywordAlignment": "indented" 70 | } 71 | }, 72 | "insertStatements": { 73 | "columns": { 74 | "parenthesisStyle": "expandedSplit", 75 | "placeSubsequentColumnsOnNewLines": "ifLongerThanMaxLineLength" 76 | }, 77 | "values": { 78 | "parenthesisStyle": "compactSimple", 79 | "indentContents": true, 80 | "placeSubsequentValuesOnNewLines": "ifLongerThanMaxLineLength" 81 | } 82 | }, 83 | "caseExpressions": { 84 | "placeExpressionOnNewLine": false, 85 | "placeFirstWhenOnNewLine": "ifInputExpression", 86 | "placeThenOnNewLine": true, 87 | "collapseShortCaseExpressions": true, 88 | "collapseCaseExpressionsShorterThan": 100 89 | }, 90 | "operators": { 91 | "comparison": { 92 | "align": true 93 | }, 94 | "andOr": {}, 95 | "between": { 96 | "placeOnNewLine": false 97 | }, 98 | "in": { 99 | "placeFirstValueOnNewLine": "ifLongerThanMaxLineLength" 100 | } 101 | } 102 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Styles/Team Collapsed-fcb648ec-57c1-48f9-a40f-d3e81de7b8de.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "id": "fcb648ec-57c1-48f9-a40f-d3e81de7b8de", 4 | "name": "Team Collapsed" 5 | }, 6 | "whitespace": { 7 | "wrapLongLines": false, 8 | "newLines": { 9 | "preserveExistingEmptyLinesAfterBatchSeparator": false 10 | } 11 | }, 12 | "lists": { 13 | "placeFirstItemOnNewLine": "always", 14 | "alignSubsequentItemsWithFirstItem": false, 15 | "alignItemsAcrossClauses": false, 16 | "alignComments": true 17 | }, 18 | "parentheses": { 19 | "parenthesisStyle": "expandedSplit", 20 | "indentParenthesesContents": true, 21 | "collapseShortParenthesisContents": true, 22 | "collapseParenthesesShorterThan": 75 23 | }, 24 | "casing": { 25 | "reservedKeywords": "uppercase", 26 | "builtInFunctions": "uppercase", 27 | "builtInDataTypes": "lowercase", 28 | "globalVariables": "uppercase", 29 | "useObjectDefinitionCase": true 30 | }, 31 | "dml": { 32 | "addNewLineAfterDistinctAndTopClauses": true, 33 | "collapseShortStatements": true, 34 | "collapseStatementsShorterThan": 78, 35 | "collapseShortSubqueries": true, 36 | "collapseSubqueriesShorterThan": 120 37 | }, 38 | "ddl": { 39 | "parenthesisStyle": "expandedToStatement", 40 | "indentParenthesesContents": true, 41 | "placeConstraintColumnsOnNewLines": "ifLongerOrMultipleColumns", 42 | "collapseShortStatements": true, 43 | "collapseStatementsShorterThan": 75 44 | }, 45 | "controlFlow": { 46 | "collapseStatementsShorterThan": 78 47 | }, 48 | "variables": { 49 | "alignDataTypesAndValues": false, 50 | "placeEqualsSignOnNewLine": true 51 | }, 52 | "joinStatements": { 53 | "join": { 54 | "indentJoinTable": false 55 | }, 56 | "on": { 57 | "keywordAlignment": "indented" 58 | } 59 | }, 60 | "insertStatements": { 61 | "values": { 62 | "parenthesisStyle": "expandedSplit", 63 | "indentContents": true, 64 | "placeSubsequentValuesOnNewLines": "always" 65 | } 66 | }, 67 | "caseExpressions": { 68 | "collapseCaseExpressionsShorterThan": 75 69 | }, 70 | "operators": { 71 | "andOr": {}, 72 | "between": { 73 | "placeOnNewLine": false 74 | }, 75 | "in": { 76 | "placeFirstValueOnNewLine": "never", 77 | "placeSubsequentValuesOnNewLines": "never" 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /Development Application Settings/Red Gate/SQL Prompt/Styles/Team Expanded-6d4cd025-b548-497f-bf21-3d5c64111b1f.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "id": "6d4cd025-b548-497f-bf21-3d5c64111b1f", 4 | "name": "Team Expanded" 5 | }, 6 | "whitespace": { 7 | "wrapLongLines": false 8 | }, 9 | "lists": { 10 | "placeFirstItemOnNewLine": "always", 11 | "alignSubsequentItemsWithFirstItem": false, 12 | "alignItemsAcrossClauses": false, 13 | "alignAliases": true, 14 | "alignComments": true, 15 | "placeCommasBeforeItems": true, 16 | "addSpaceAfterComma": false 17 | }, 18 | "parentheses": { 19 | "parenthesisStyle": "expandedSplit", 20 | "indentParenthesesContents": true, 21 | "collapseShortParenthesisContents": true, 22 | "collapseParenthesesShorterThan": 78 23 | }, 24 | "casing": { 25 | "reservedKeywords": "uppercase", 26 | "builtInFunctions": "uppercase", 27 | "builtInDataTypes": "lowercase", 28 | "useObjectDefinitionCase": true 29 | }, 30 | "dml": { 31 | "addNewLineAfterDistinctAndTopClauses": true, 32 | "collapseShortStatements": true, 33 | "collapseStatementsShorterThan": 78, 34 | "collapseShortSubqueries": true, 35 | "collapseSubqueriesShorterThan": 78, 36 | "listItems": { 37 | "placeFromTableOnNewLine": "always", 38 | "placeWhereConditionOnNewLine": "always", 39 | "placeGroupByAndOrderByOnNewLine": "always" 40 | } 41 | }, 42 | "ddl": { 43 | "parenthesisStyle": "expandedSplit", 44 | "indentParenthesesContents": true, 45 | "alignDataTypesAndConstraints": true, 46 | "placeConstraintColumnsOnNewLines": "ifLongerOrMultipleColumns", 47 | "indentClauses": true, 48 | "placeFirstProcedureParameterOnNewLine": "always", 49 | "collapseShortStatements": true, 50 | "collapseStatementsShorterThan": 100 51 | }, 52 | "controlFlow": { 53 | "indentBeginAndEndKeywords": true, 54 | "collapseStatementsShorterThan": 120 55 | }, 56 | "cte": { 57 | "parenthesisStyle": "expandedSplit", 58 | "indentContents": true, 59 | "placeColumnsOnNewLine": true, 60 | "columnAlignment": "indented", 61 | "asAlignment": "rightAligned" 62 | }, 63 | "variables": { 64 | "placeAssignedValueOnNewLineIfLongerThanMaxLineLength": false 65 | }, 66 | "joinStatements": { 67 | "join": { 68 | "indentJoinTable": false 69 | }, 70 | "on": { 71 | "keywordAlignment": "indented" 72 | } 73 | }, 74 | "insertStatements": { 75 | "columns": { 76 | "parenthesisStyle": "expandedSplit" 77 | }, 78 | "values": { 79 | "parenthesisStyle": "compactRightAligned", 80 | "indentContents": true, 81 | "placeSubsequentValuesOnNewLines": "always" 82 | } 83 | }, 84 | "caseExpressions": { 85 | "placeExpressionOnNewLine": false, 86 | "placeFirstWhenOnNewLine": "ifInputExpression", 87 | "placeThenOnNewLine": true, 88 | "collapseShortCaseExpressions": true, 89 | "collapseCaseExpressionsShorterThan": 100 90 | }, 91 | "operators": { 92 | "comparison": { 93 | "align": true 94 | }, 95 | "andOr": {}, 96 | "between": { 97 | "placeOnNewLine": false 98 | }, 99 | "in": { 100 | "placeFirstValueOnNewLine": "ifLongerThanMaxLineLength" 101 | } 102 | } 103 | } -------------------------------------------------------------------------------- /Images/Mixing_Data_Types_in_JOIN_or_WHERE_Clauses.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/8787a1a70ccd9933336cffaf98d6b3a92e117eec/Images/Mixing_Data_Types_in_JOIN_or_WHERE_Clauses.png -------------------------------------------------------------------------------- /Images/Non-SARGable Does Not Get Index Recommendation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/8787a1a70ccd9933336cffaf98d6b3a92e117eec/Images/Non-SARGable Does Not Get Index Recommendation.png -------------------------------------------------------------------------------- /Images/Using_a_Non-SARGable_Expression_in_a_WHERE_Clause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/8787a1a70ccd9933336cffaf98d6b3a92e117eec/Images/Using_a_Non-SARGable_Expression_in_a_WHERE_Clause.png -------------------------------------------------------------------------------- /Images/sp_Develop - Emergent Software - SQL Server Assess - GitHub Open Graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/8787a1a70ccd9933336cffaf98d6b3a92e117eec/Images/sp_Develop - Emergent Software - SQL Server Assess - GitHub Open Graph.png -------------------------------------------------------------------------------- /Images/sp_Develop - Emergent Software - SQL Server Assess - LinkedIn Profile Background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/8787a1a70ccd9933336cffaf98d6b3a92e117eec/Images/sp_Develop - Emergent Software - SQL Server Assess - LinkedIn Profile Background.png -------------------------------------------------------------------------------- /Images/sp_Develop - Emergent Software - SQL Server Assess - Twitch Profile Banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/8787a1a70ccd9933336cffaf98d6b3a92e117eec/Images/sp_Develop - Emergent Software - SQL Server Assess - Twitch Profile Banner.png -------------------------------------------------------------------------------- /Images/sp_Develop - Emergent Software - SQL Server Assess - Twitch Video Player Banner Offline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/8787a1a70ccd9933336cffaf98d6b3a92e117eec/Images/sp_Develop - Emergent Software - SQL Server Assess - Twitch Video Player Banner Offline.png -------------------------------------------------------------------------------- /Images/sp_Develop - Emergent Software - SQL Server Assess - Twitter Header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/8787a1a70ccd9933336cffaf98d6b3a92e117eec/Images/sp_Develop - Emergent Software - SQL Server Assess - Twitter Header.png -------------------------------------------------------------------------------- /Images/sp_Develop_Results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/8787a1a70ccd9933336cffaf98d6b3a92e117eec/Images/sp_Develop_Results.png -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright for portions of sp_Develop are held by Brent Ozar Unlimited as part of project SQL-Server-First-Responder-Kit and are provided under the MIT license: https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/ 4 | 5 | Copyright for portions of sp_Develop are held by Phil Factor (real name withheld) as part of project SQLCodeSmells https://github.com/Phil-Factor/SQLCodeSmells 6 | 7 | All other copyrights for sp_Develop are held by Emergent Software, LLC as described below. 8 | 9 | Copyright (c) 2022 Emergent Software, LLC 10 | 11 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sub-license, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SQL Server Development Assessment Overview 2 | 3 | The open source SQL Server Development Assessment project contains the [sp_Develop](https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/master/sp_Develop.sql) stored procedure. It can be used by database developers, software developers and for performing database code (smell) assessments to adhere to best practices. 4 | 5 | Visit the sp_Develop documentation website at https://emergentsoftware.github.io/SQL-Server-Development-Assessment/ 6 | 7 | There you will find the check findings with database development best practices. Install & usage instructions. Results & parameter explanations, How to skip checks. Develop app settings. Install the test database. 8 | 9 | ### Please connect with me (Kevin Martin) if you need assistance with sp_Develop or any of our [SQL Server consulting services](https://www.emergentsoftware.net/services/database/): 10 | 11 | - [Emergent Software](https://www.emergentsoftware.net) 12 | - [Kevin Martin on LinkedIn](https://www.linkedin.com/in/KevinMartinLink) 13 | - [Kevin Martin on Twitter](https://twitter.com/KevinMartinLink) 14 | - [Kevin Martin on GitHub](https://github.com/KevinMartinLink) 15 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Version 1.0 and greater are currently being supported with security updates. 6 | 7 | | Version | Supported | 8 | | ------- | ------------------ | 9 | | > 1.0.x | :white_check_mark: | 10 | | < 1.0 | :x: | 11 | 12 | ## Reporting a Vulnerability 13 | 14 | Create an bug report using the issues tab to reported vulnerability. 15 | -------------------------------------------------------------------------------- /Test Database/Custom Scripts/Post-Deployment/PostScript.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Use this Post-Deployment script to perform tasks after the deployment of the project. 3 | * Read more at https://www.red-gate.com/SOC7/post-deployment-script-help 4 | */ 5 | /* Create a table that we will delete so that we have an invalid object to test */ 6 | CREATE TABLE dbo.UseToExist ( 7 | UseToExistId INT IDENTITY(1, 1) NOT NULL 8 | ,UseToExistColumn VARCHAR(30) NULL CONSTRAINT UseToExist_UseToExistId PRIMARY KEY CLUSTERED (UseToExistId) 9 | ); 10 | GO 11 | 12 | CREATE VIEW dbo.InvalidObject 13 | AS 14 | SELECT UTE.UseToExistId, UTE.UseToExistColumn FROM dbo.UseToExist AS UTE; 15 | GO 16 | 17 | CREATE PROCEDURE dbo.InvalidObjectList 18 | AS 19 | BEGIN 20 | SET NOCOUNT ON; 21 | 22 | SELECT UTE.UseToExistId, UTE.UseToExistColumn FROM dbo.UseToExist AS UTE; 23 | END; 24 | GO 25 | 26 | DROP TABLE dbo.UseToExist; 27 | GO 28 | 29 | CREATE INDEX HypotheticalIndex_HypotheticalIndexValue 30 | ON dbo.HypotheticalIndex (HypotheticalIndexValue) 31 | WITH (DROP_EXISTING = ON, STATISTICS_ONLY=1); 32 | GO -------------------------------------------------------------------------------- /Test Database/Data/dbo.UnencryptedData_Data.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO [dbo].[UnencryptedData] ([UnencryptedDataId], [Password], [PasswordIsEncrypted], [PasswordSalt], [LastPasswordChangedDate], [PasswordConfigurationSettings], [PasswordComplexityPattern], [PasswordExpirationDate], [IsPasswordChangedFlag], [LastPasswordFailedDate], [MaxPasswordCharacters], [MinPasswordLength], [PasswordSpecialCharacterRequirement], [PasswordHistoryCount], [CreditCardId], [CreditCardNumber], [CreditCardApprovalCode], [CCN], [CreditCardToken], [SSN], [SocialSecurityNumber], [PassportNumber], [DLL], [DriverLicenseNumber], [LicenseCount]) VALUES (1, N'Passw0rd1!', N'0x9892C5339D13A94CC03384E609798F4E4688DACF95BB896FE60931255F054E20', 'bE3XiWw=', '2020-08-20', '', N'^[a-zA-Z]\w{3,14}$', '2021-08-20', 1, '2019-08-20', 100, 10, 1, 33, 553, '4111111111111111', '115213Vi29411', '5555555555554444', N'J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n', '555255864', N'555-25-5864', 223235245, 'MN2234223', N'WI2930840923', 1000) 2 | -------------------------------------------------------------------------------- /Test Database/Functions/DBA.fnPrefixNameTableValuedFunctionSkipMe.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | 6 | -- ============================================= 7 | -- Author: 8 | -- Create date: 9 | -- Description: 10 | -- ============================================= 11 | CREATE FUNCTION [DBA].[fnPrefixNameTableValuedFunctionSkipMe] 12 | ( 13 | -- Add the parameters for the function here 14 | @param1 INT 15 | ) 16 | RETURNS TABLE 17 | AS 18 | RETURN 19 | ( 20 | -- Add the SELECT statement with parameter references here 21 | SELECT @param1 AS ColumnName 22 | ) 23 | GO 24 | -------------------------------------------------------------------------------- /Test Database/Functions/DBA.fn_PrefixNameSkipMe.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | 6 | -- ============================================= 7 | -- Author: 8 | -- Create date: 9 | -- Description: 10 | -- ============================================= 11 | CREATE FUNCTION [DBA].[fn_PrefixNameSkipMe] 12 | ( 13 | @Param1 INT 14 | ) 15 | RETURNS INT 16 | AS 17 | BEGIN 18 | -- Declare the return variable here 19 | DECLARE @ResultVar INT 20 | 21 | -- Add the T-SQL statements to compute the return value here 22 | SET @ResultVar = 1 23 | 24 | -- Return the result of the function 25 | RETURN @ResultVar 26 | 27 | END 28 | GO 29 | -------------------------------------------------------------------------------- /Test Database/Functions/dbo.MulitStatement.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | CREATE FUNCTION [dbo].[MulitStatement] (@ParameterName1 AS INT, @ParameterName2 AS VARCHAR(50)) 6 | RETURNS @VariableName TABLE (ColumnName1 INT NOT NULL, ColumnName2 VARCHAR(50) NOT NULL) 7 | AS 8 | BEGIN 9 | -- Return the result of the function 10 | INSERT INTO 11 | @VariableName (ColumnName1, ColumnName2) 12 | SELECT ColumnName1 = @ParameterName1, ColumnName2 = @ParameterName2; 13 | RETURN; 14 | END; 15 | GO 16 | -------------------------------------------------------------------------------- /Test Database/Functions/dbo.NonInlineable.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | 6 | CREATE FUNCTION [dbo].[NonInlineable] (@Param1 INT) 7 | RETURNS DATETIME2 8 | AS 9 | BEGIN 10 | -- Declare the return variable here 11 | DECLARE @ResultVar DATETIME2(7); 12 | 13 | -- Add the T-SQL statements to compute the return value here 14 | SET @ResultVar = GETDATE(); 15 | 16 | -- Return the result of the function 17 | RETURN @ResultVar; 18 | 19 | END; 20 | GO 21 | -------------------------------------------------------------------------------- /Test Database/Functions/dbo.fnPrefixNameTableValuedFunction.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | -- ============================================= 6 | -- Author: 7 | -- Create date: 8 | -- Description: 9 | -- ============================================= 10 | CREATE FUNCTION [dbo].[fnPrefixNameTableValuedFunction] 11 | ( 12 | -- Add the parameters for the function here 13 | @param1 int 14 | ) 15 | RETURNS TABLE 16 | AS 17 | RETURN 18 | ( 19 | -- Add the SELECT statement with parameter references here 20 | SELECT @param1 AS ColumnName 21 | ) 22 | GO 23 | -------------------------------------------------------------------------------- /Test Database/Functions/dbo.fn_PrefixName.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | -- ============================================= 6 | -- Author: 7 | -- Create date: 8 | -- Description: 9 | -- ============================================= 10 | CREATE FUNCTION [dbo].[fn_PrefixName] 11 | ( 12 | @Param1 INT 13 | ) 14 | RETURNS INT 15 | AS 16 | BEGIN 17 | -- Declare the return variable here 18 | DECLARE @ResultVar int 19 | 20 | -- Add the T-SQL statements to compute the return value here 21 | SET @ResultVar = 1 22 | 23 | -- Return the result of the function 24 | RETURN @ResultVar 25 | 26 | END 27 | GO 28 | -------------------------------------------------------------------------------- /Test Database/RedGate.ssc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/8787a1a70ccd9933336cffaf98d6b3a92e117eec/Test Database/RedGate.ssc -------------------------------------------------------------------------------- /Test Database/RedGateDatabaseInfo.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | UTF8 4 | SQL_Latin1_General_CP1_CI_AS 5 | dbo 6 | dbo 7 | PRIMARY 8 | 15 9 | False 10 | Default 11 | 10485760 12 | de1f58fd-c0a2-4990-a972-f945cb49d3a6 13 | 14 | 15 | 16 | 17 |
Tables
18 | Stored Procedures 19 | Views 20 | Defaults 21 | Storage\Full Text Catalogs 22 | Functions 23 | Security\Roles 24 | Rules 25 | Security\Users 26 | Types\User-defined Data Types 27 | 28 | 29 | Database Triggers 30 | Assemblies 31 | Synonyms 32 | Types\XML Schema Collections 33 | Service Broker\Message Types 34 | Service Broker\Contracts 35 | Service Broker\Queues 36 | Service Broker\Services 37 | Service Broker\Routes 38 | Service Broker\Event Notifications 39 | Storage\Partition Schemes 40 | Storage\Partition Functions 41 | 42 | 43 | 44 | 45 | Security\Schemas 46 | Service Broker\Remote Service Bindings 47 | Security\Certificates 48 | Security\Symmetric Keys 49 | Security\Asymmetric Keys 50 | 51 | 52 | Storage\Full Text Stoplists 53 | Extended Properties 54 | Data 55 | Sequences 56 | Search Property Lists 57 | Security Policies 58 | External Resources\External File Formats 59 | External Resources\External Data Sources 60 | Tables\External Tables 61 | 62 | True 63 | 64 | 65 | 1 66 | dbo.UnencryptedData_Data.sql 67 | 68 | -------------------------------------------------------------------------------- /Test Database/Security/Schemas/DBA.sql: -------------------------------------------------------------------------------- 1 | CREATE SCHEMA [DBA] 2 | AUTHORIZATION [dbo] 3 | GO 4 | -------------------------------------------------------------------------------- /Test Database/Security/Schemas/Schema_Including_$pecial_Characters_in_Name.sql: -------------------------------------------------------------------------------- 1 | CREATE SCHEMA [Schema_Including_$pecial_Characters_in_Name] 2 | AUTHORIZATION [dbo] 3 | GO 4 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/DBA.spPrefixNameSkipMe.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | 6 | -- ============================================= 7 | -- Author: 8 | -- Create date: 9 | -- Description: 10 | -- ============================================= 11 | CREATE PROCEDURE [DBA].[spPrefixNameSkipMe] 12 | 13 | AS 14 | BEGIN 15 | -- SET NOCOUNT ON added to prevent extra result sets from 16 | -- interfering with SELECT statements. 17 | SET NOCOUNT ON; 18 | 19 | -- Insert statements for procedure here 20 | SELECT N.Number2020Id, N.TableNameContainsNumbers FROM dbo.Number2020 AS N 21 | END 22 | GO 23 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/dbo.DoNotLock1Get.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | CREATE PROCEDURE [dbo].[DoNotLock1Get] 6 | AS 7 | BEGIN 8 | SET NOCOUNT ON; 9 | 10 | SELECT 11 | N.NewspaperId, 12 | N.Name 13 | FROM 14 | dbo.Newspaper AS N WITH (NOLOCK); 15 | 16 | END; 17 | GO 18 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/dbo.DoNotLock2Get.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | 6 | CREATE PROCEDURE [dbo].[DoNotLock2Get] 7 | AS 8 | BEGIN 9 | SET NOCOUNT ON; 10 | 11 | SELECT 12 | N.NewspaperId, 13 | N.Name 14 | FROM 15 | dbo.Newspaper AS N WITH (NOWAIT,NOLOCK,INDEX(1)); 16 | 17 | END; 18 | GO 19 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/dbo.DoNotLock3Get.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | 6 | 7 | CREATE PROCEDURE [dbo].[DoNotLock3Get] 8 | AS 9 | BEGIN 10 | SET NOCOUNT ON; 11 | 12 | SELECT 13 | N.NewspaperId, 14 | N.Name 15 | FROM 16 | dbo.Newspaper AS N WITH (READUNCOMMITTED); 17 | 18 | END; 19 | GO 20 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/dbo.DoNotLock4Get.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | 6 | 7 | CREATE PROCEDURE [dbo].[DoNotLock4Get] 8 | AS 9 | BEGIN 10 | SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; 11 | SET NOCOUNT ON; 12 | 13 | SELECT N.NewspaperId, N.Name FROM dbo.Newspaper AS N; 14 | 15 | END; 16 | GO 17 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/dbo.HardcodedDatabaseNameReference.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | -- ============================================= 6 | -- Author: 7 | -- Create date: 8 | -- Description: 9 | -- ============================================= 10 | CREATE PROCEDURE [dbo].[HardcodedDatabaseNameReference] 11 | AS 12 | BEGIN 13 | SET NOCOUNT ON; 14 | 15 | SELECT 16 | WideId 17 | ,Column1 18 | ,Column2 19 | ,Column3 20 | ,Column4 21 | ,Column5 22 | ,Column6 23 | ,Column7 24 | ,Column8 25 | ,Column9 26 | ,Column10 27 | ,Column11 28 | ,Column12 29 | ,Column13 30 | ,Column14 31 | ,Column15 32 | ,Column16 33 | ,Column17 34 | ,Column18 35 | ,Column19 36 | ,Column20 37 | FROM 38 | spDevelop.dbo.Wide; 39 | END; 40 | GO 41 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/dbo.NoSetNocountUsed.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | CREATE PROCEDURE [dbo].[NoSetNocountUsed] 6 | AS 7 | BEGIN 8 | SELECT 1; 9 | END 10 | GO 11 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/dbo.SelectEverything.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | --SET QUOTED_IDENTIFIER ON|OFF 6 | --SET ANSI_NULLS ON|OFF 7 | /********************************************************************************************************************** 8 | ** Author: sa 9 | ** Created On: 8/9/2020 10 | ** Modified On: 8/9/2020 11 | ** Description: SELECT EVERYTHING 12 | **********************************************************************************************************************/ 13 | CREATE PROCEDURE [dbo].[SelectEverything] 14 | AS 15 | BEGIN 16 | SET NOCOUNT ON; 17 | 18 | SELECT * FROM dbo.NewspaperReader AS NR 19 | 20 | END 21 | GO 22 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/dbo.SelectEverything10.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | CREATE PROCEDURE [dbo].[SelectEverything10] 6 | AS 7 | BEGIN 8 | SET NOCOUNT ON; 9 | 10 | SELECT 3*4 FROM dbo.NewspaperReader AS NR; 11 | 12 | END; 13 | GO 14 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/dbo.SelectEverything2.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | CREATE PROCEDURE [dbo].[SelectEverything2] 6 | AS 7 | BEGIN 8 | SET NOCOUNT ON; 9 | 10 | SELECT * 11 | FROM dbo.NewspaperReader AS NR; 12 | 13 | END; 14 | GO 15 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/dbo.SelectEverything3.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | CREATE PROCEDURE [dbo].[SelectEverything3] 6 | AS 7 | BEGIN 8 | SET NOCOUNT ON; 9 | 10 | SELECT COUNT(*) 11 | FROM dbo.NewspaperReader AS NR; 12 | 13 | END; 14 | GO 15 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/dbo.SelectEverything4.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | CREATE PROCEDURE [dbo].[SelectEverything4] 6 | AS 7 | BEGIN 8 | SET NOCOUNT ON; 9 | 10 | SELECT 1 * 3 11 | FROM dbo.NewspaperReader AS NR; 12 | 13 | END; 14 | GO 15 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/dbo.SelectEverything5.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | CREATE PROCEDURE [dbo].[SelectEverything5] 6 | AS 7 | BEGIN 8 | SET NOCOUNT ON; 9 | 10 | IF EXISTS (SELECT * FROM dbo.NewspaperReader) BEGIN 11 | SELECT 1; 12 | END; 13 | 14 | END; 15 | GO 16 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/dbo.SelectEverything6.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | CREATE PROCEDURE [dbo].[SelectEverything6] 6 | AS 7 | BEGIN 8 | SET NOCOUNT ON; 9 | DECLARE @DeleteCount INT; 10 | 11 | SELECT @DeleteCount = COUNT(*) FROM dbo.NewspaperReader 12 | 13 | SELECT @DeleteCount 14 | 15 | END; 16 | GO 17 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/dbo.SelectEverything7.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | CREATE PROCEDURE [dbo].[SelectEverything7] 6 | AS 7 | BEGIN 8 | SET NOCOUNT ON; 9 | 10 | SELECT 11 | NewspaperReaderId 12 | ,NewspaperId 13 | ,ReaderId 14 | ,SubscriptionEndDate 15 | ,Math = 1 * 4 16 | FROM 17 | dbo.NewspaperReader; 18 | 19 | END; 20 | GO 21 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/dbo.SelectEverything8.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | CREATE PROCEDURE [dbo].[SelectEverything8] 6 | AS 7 | BEGIN 8 | SET NOCOUNT ON; 9 | 10 | SELECT NR.* FROM dbo.NewspaperReader AS NR; 11 | 12 | END; 13 | GO 14 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/dbo.SelectEverything9.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | CREATE PROCEDURE [dbo].[SelectEverything9] 6 | AS 7 | BEGIN 8 | SET NOCOUNT ON; 9 | DECLARE @Number1 INT = 2, @Number2 INT = 3 10 | 11 | SELECT @Number1 * @Number2 FROM dbo.NewspaperReader AS NR; 12 | 13 | END; 14 | GO 15 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/dbo.SelectEverythingWithIfExists.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | CREATE PROCEDURE [dbo].[SelectEverythingWithIfExists] 6 | AS 7 | BEGIN 8 | SET NOCOUNT ON; 9 | 10 | /* This should not be caught by CheckId: 23 */ 11 | IF EXISTS ( 12 | SELECT 13 | * 14 | FROM 15 | sys.objects 16 | ) 17 | BEGIN 18 | PRINT 'Stored procedure already exists'; 19 | END; 20 | 21 | END; 22 | GO 23 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/dbo.SetOptions.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | -- ============================================= 6 | -- Author: 7 | -- Create date: 8 | -- Description: 9 | -- ============================================= 10 | CREATE PROCEDURE [dbo].[SetOptions] 11 | AS 12 | BEGIN 13 | SET NOCOUNT ON; 14 | SET NOEXEC ON; 15 | SET QUOTED_IDENTIFIER OFF; 16 | SET ARITHABORT OFF; 17 | SET ANSI_DEFAULTS OFF; 18 | SET ANSI_NULLS OFF; 19 | SET ANSI_NULL_DFLT_ON OFF; 20 | SET ANSI_WARNINGS OFF; 21 | SET ANSI_PADDING OFF; 22 | SET NUMERIC_ROUNDABORT ON; 23 | SET CONCAT_NULL_YIELDS_NULL OFF; 24 | SET ROWCOUNT 100; 25 | SET XACT_ABORT ON; 26 | SET IMPLICIT_TRANSACTIONS ON; 27 | SET ARITHIGNORE OFF; 28 | SET LOCK_TIMEOUT 1; 29 | SET FMTONLY ON; 30 | --SET PARSEONLY OFF; 31 | 32 | SELECT 1; 33 | END; 34 | GO 35 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/dbo.spPrefixName.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | -- ============================================= 6 | -- Author: 7 | -- Create date: 8 | -- Description: 9 | -- ============================================= 10 | CREATE PROCEDURE [dbo].[spPrefixName] 11 | 12 | AS 13 | BEGIN 14 | -- SET NOCOUNT ON added to prevent extra result sets from 15 | -- interfering with SELECT statements. 16 | SET NOCOUNT ON; 17 | 18 | -- Insert statements for procedure here 19 | SELECT N.Number2020Id, N.TableNameContainsNumbers FROM dbo.Number2020 AS N 20 | END 21 | GO 22 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/dbo.sp_PrefixName.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | -- ============================================= 6 | -- Author: 7 | -- Create date: 8 | -- Description: 9 | -- ============================================= 10 | CREATE PROCEDURE [dbo].[sp_PrefixName] 11 | AS 12 | BEGIN 13 | -- SET NOCOUNT ON added to prevent extra result sets from 14 | -- interfering with SELECT statements. 15 | SET NOCOUNT ON; 16 | 17 | -- Insert statements for procedure here 18 | SELECT 1 19 | END 20 | GO 21 | -------------------------------------------------------------------------------- /Test Database/Stored Procedures/dbo.usp_PrefixName.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | -- ============================================= 6 | -- Author: 7 | -- Create date: 8 | -- Description: 9 | -- ============================================= 10 | CREATE PROCEDURE [dbo].[usp_PrefixName] 11 | AS 12 | BEGIN 13 | -- SET NOCOUNT ON added to prevent extra result sets from 14 | -- interfering with SELECT statements. 15 | SET NOCOUNT ON; 16 | 17 | -- Insert statements for procedure here 18 | SELECT 1 19 | END 20 | GO 21 | -------------------------------------------------------------------------------- /Test Database/Tables/DBA.DevelopCheckToSkip.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [DBA].[DevelopCheckToSkip] 2 | ( 3 | [DevelopCheckToSkipId] [int] NOT NULL IDENTITY(1, 1), 4 | [ServerName] [nvarchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 5 | [DatabaseName] [nvarchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 6 | [SchemaName] [nvarchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 7 | [ObjectName] [nvarchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 8 | [CheckId] [int] NULL 9 | ) ON [PRIMARY] 10 | GO 11 | ALTER TABLE [DBA].[DevelopCheckToSkip] ADD CONSTRAINT [DevelopCheckToSkip_DevelopCheckToSkipId] PRIMARY KEY CLUSTERED ([DevelopCheckToSkipId]) ON [PRIMARY] 12 | GO 13 | CREATE NONCLUSTERED INDEX [DevelopCheckToSkip_CheckId] ON [DBA].[DevelopCheckToSkip] ([CheckId]) ON [PRIMARY] 14 | GO 15 | CREATE NONCLUSTERED INDEX [DevelopCheckToSkip_DatabaseName] ON [DBA].[DevelopCheckToSkip] ([DatabaseName]) ON [PRIMARY] 16 | GO 17 | CREATE NONCLUSTERED INDEX [DevelopCheckToSkip_ObjectName] ON [DBA].[DevelopCheckToSkip] ([ObjectName]) ON [PRIMARY] 18 | GO 19 | CREATE NONCLUSTERED INDEX [DevelopCheckToSkip_SchemaName] ON [DBA].[DevelopCheckToSkip] ([SchemaName]) ON [PRIMARY] 20 | GO 21 | CREATE NONCLUSTERED INDEX [DevelopCheckToSkip_ServerName] ON [DBA].[DevelopCheckToSkip] ([ServerName]) ON [PRIMARY] 22 | GO 23 | -------------------------------------------------------------------------------- /Test Database/Tables/DBA.IDPrimaryKeyColumnNameSkipMe.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [DBA].[IDPrimaryKeyColumnNameSkipMe] 2 | ( 3 | [ID] [int] NOT NULL 4 | ) ON [PRIMARY] 5 | GO 6 | ALTER TABLE [DBA].[IDPrimaryKeyColumnNameSkipMe] ADD CONSTRAINT [PK_IDPrimaryKeyColumnName] PRIMARY KEY CLUSTERED ([ID]) ON [PRIMARY] 7 | GO 8 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.(ContainsIllegalCharacters).sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[(ContainsIllegalCharacters)] 2 | ( 3 | [(ContainsIllegalCharacters)Id] [int] NOT NULL 4 | ) ON [PRIMARY] 5 | GO 6 | ALTER TABLE [dbo].[(ContainsIllegalCharacters)] ADD CONSTRAINT [PK_(ContainsIllegalCharacters)] PRIMARY KEY CLUSTERED ([(ContainsIllegalCharacters)Id]) ON [PRIMARY] 7 | GO 8 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.1StartsWithANumber.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[1StartsWithANumber] 2 | ( 3 | [1StartsWithANumberId] [int] NOT NULL 4 | ) ON [PRIMARY] 5 | GO 6 | ALTER TABLE [dbo].[1StartsWithANumber] ADD CONSTRAINT [PK_1StartsWithANumber] PRIMARY KEY CLUSTERED ([1StartsWithANumberId]) ON [PRIMARY] 7 | GO 8 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.ColumnCollationDifferent.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[ColumnCollationDifferent] 2 | ( 3 | [ColumnCollationDifferentId] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, 4 | [DifferentCollationThanDatabase] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CS_AS NULL 5 | ) ON [PRIMARY] 6 | GO 7 | ALTER TABLE [dbo].[ColumnCollationDifferent] ADD CONSTRAINT [PK_ColumnCollationDifferent] PRIMARY KEY CLUSTERED ([ColumnCollationDifferentId]) ON [PRIMARY] 8 | GO 9 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.ColumnSameAsTable.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[ColumnSameAsTable] 2 | ( 3 | [ColumnSameAsTable] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL 4 | ) ON [PRIMARY] 5 | GO 6 | ALTER TABLE [dbo].[ColumnSameAsTable] ADD CONSTRAINT [PK_ColumnSameAsTable] PRIMARY KEY CLUSTERED ([ColumnSameAsTable]) ON [PRIMARY] 7 | GO 8 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.DataType.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[DataType] 2 | ( 3 | [DataTypeId] [int] NOT NULL, 4 | [UnitPriceTotal] [money] NULL, 5 | [UnitPrice] [smallmoney] NULL, 6 | [ProductDescription] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 7 | [ProductDescriptionInternational] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 8 | [LineAmount] [float] NULL, 9 | [LineTotal] [real] NULL, 10 | [ProfileInformation] [sql_variant] NULL 11 | ) ON [PRIMARY] 12 | GO 13 | ALTER TABLE [dbo].[DataType] ADD CONSTRAINT [PK_DataType] PRIMARY KEY CLUSTERED ([DataTypeId]) ON [PRIMARY] 14 | GO 15 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.DisabledIndex.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[DisabledIndex] 2 | ( 3 | [DisabledIndexId] [int] NOT NULL, 4 | [SomeValue] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 5 | [AnotherValue] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 6 | ) ON [PRIMARY] 7 | GO 8 | ALTER TABLE [dbo].[DisabledIndex] ADD CONSTRAINT [PK_DisabledIndex] PRIMARY KEY CLUSTERED ([DisabledIndexId]) ON [PRIMARY] 9 | GO 10 | CREATE NONCLUSTERED INDEX [DisabledIndex_AnotherValue] ON [dbo].[DisabledIndex] ([AnotherValue]) INCLUDE ([SomeValue]) ON [PRIMARY] 11 | GO 12 | ALTER INDEX [DisabledIndex_AnotherValue] ON [dbo].[DisabledIndex] DISABLE 13 | GO 14 | CREATE NONCLUSTERED INDEX [DisabledIndex_SomeValue] ON [dbo].[DisabledIndex] ([SomeValue]) ON [PRIMARY] 15 | GO 16 | ALTER INDEX [DisabledIndex_SomeValue] ON [dbo].[DisabledIndex] DISABLE 17 | GO 18 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.FalsePositiveStatus.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[FalsePositiveStatus] 2 | ( 3 | [FalsePositiveStatusId] [int] NOT NULL 4 | ) ON [PRIMARY] 5 | GO 6 | ALTER TABLE [dbo].[FalsePositiveStatus] ADD CONSTRAINT [PK_FalsePositiveStatus] PRIMARY KEY CLUSTERED ([FalsePositiveStatusId]) ON [PRIMARY] 7 | GO 8 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.ForeignKeyMissing.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[ForeignKeyMissing] 2 | ( 3 | [ForeignKeyMissingId] [int] NOT NULL IDENTITY(1, 1), 4 | [SomeKindOfId] [int] NULL 5 | ) ON [PRIMARY] 6 | GO 7 | ALTER TABLE [dbo].[ForeignKeyMissing] ADD CONSTRAINT [PK_ForeignKeyMissing] PRIMARY KEY CLUSTERED ([ForeignKeyMissingId]) ON [PRIMARY] 8 | GO 9 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.GenericOrClassWord.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[GenericOrClassWord] 2 | ( 3 | [GenericOrClassWordId] [int] NOT NULL IDENTITY(1, 1), 4 | [Name] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 5 | [Description] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 6 | [Comment] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 7 | [Code] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 8 | [Type] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 9 | [Status] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 10 | [Date] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 11 | [Time] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 12 | [Key] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 13 | [Value] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 14 | [Term] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 15 | [Class] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 16 | [Style] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 17 | [Segment] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 18 | [Default] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 19 | [Primary] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 20 | [Deleted] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 21 | [Active] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 22 | [Inactive] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 23 | [Permission] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 24 | [Locked] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 25 | [Number] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 26 | [Amount] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 27 | [Total] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 28 | [Quantity] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 29 | [Weight] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 30 | [Percent] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 31 | [Rate] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 32 | [Cost] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 33 | [Price] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 34 | [Balance] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 35 | [Average] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 36 | [Discount] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 37 | [Limit] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 38 | [Due] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 39 | [Fee] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 40 | [Fine] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 41 | [Stamp] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 42 | [Flag] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 43 | [Slug] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 44 | [Level] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 45 | [URL] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 46 | [Email] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 47 | [Address] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 48 | [Subject] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 49 | [Body] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 50 | [Alias] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 51 | [State] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 52 | [Format] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 53 | [Group] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 54 | ) ON [PRIMARY] 55 | GO 56 | ALTER TABLE [dbo].[GenericOrClassWord] ADD CONSTRAINT [PK_GenericOrClassWord] PRIMARY KEY CLUSTERED ([GenericOrClassWordId]) ON [PRIMARY] 57 | GO 58 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.HypotheticalIndex.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[HypotheticalIndex] 2 | ( 3 | [HypotheticalIndexId] [int] NOT NULL, 4 | [HypotheticalIndexValue] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 5 | ) ON [PRIMARY] 6 | GO 7 | ALTER TABLE [dbo].[HypotheticalIndex] ADD CONSTRAINT [PK_HypotheticalIndex] PRIMARY KEY CLUSTERED ([HypotheticalIndexId]) ON [PRIMARY] 8 | GO 9 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.IDPrimaryKeyColumnName.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[IDPrimaryKeyColumnName] 2 | ( 3 | [ID] [int] NOT NULL 4 | ) ON [PRIMARY] 5 | GO 6 | ALTER TABLE [dbo].[IDPrimaryKeyColumnName] ADD CONSTRAINT [PK_IDPrimaryKeyColumnName] PRIMARY KEY CLUSTERED ([ID]) ON [PRIMARY] 7 | GO 8 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.LowIndexFillFactor.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[LowIndexFillFactor] 2 | ( 3 | [LowIndexFillFactorId] [int] NOT NULL, 4 | [Below80PercentFillFactor] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 5 | [Above80PercentFillFactor] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 6 | ) ON [PRIMARY] 7 | GO 8 | ALTER TABLE [dbo].[LowIndexFillFactor] ADD CONSTRAINT [PK_LowIndexFillFactor] PRIMARY KEY CLUSTERED ([LowIndexFillFactorId]) ON [PRIMARY] 9 | GO 10 | CREATE NONCLUSTERED INDEX [LowIndexFillFactor_Above80PercentFillFactor] ON [dbo].[LowIndexFillFactor] ([Above80PercentFillFactor]) WITH (FILLFACTOR=85) ON [PRIMARY] 11 | GO 12 | CREATE NONCLUSTERED INDEX [LowIndexFillFactor_98PercentFillFactor] ON [dbo].[LowIndexFillFactor] ([Above80PercentFillFactor]) INCLUDE ([Below80PercentFillFactor]) WITH (FILLFACTOR=98) ON [PRIMARY] 13 | GO 14 | CREATE NONCLUSTERED INDEX [LowIndexFillFactor_Below80PercentFillFactor] ON [dbo].[LowIndexFillFactor] ([Below80PercentFillFactor]) WITH (FILLFACTOR=75) ON [PRIMARY] 15 | GO 16 | CREATE NONCLUSTERED INDEX [LowIndexFillFactor_2PercentFillFactor] ON [dbo].[LowIndexFillFactor] ([Below80PercentFillFactor], [Above80PercentFillFactor]) INCLUDE ([LowIndexFillFactorId]) WITH (FILLFACTOR=2) ON [PRIMARY] 17 | GO 18 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.NamingForeignKeyRelationship.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[NamingForeignKeyRelationship] 2 | ( 3 | [NamingForeignKeyRelationshipId] [int] NOT NULL IDENTITY(1, 1), 4 | [GenericOrClassWordId] [int] NOT NULL 5 | ) ON [PRIMARY] 6 | GO 7 | ALTER TABLE [dbo].[NamingForeignKeyRelationship] ADD CONSTRAINT [PK_NamingForeignKeyRelationship] PRIMARY KEY CLUSTERED ([NamingForeignKeyRelationshipId]) ON [PRIMARY] 8 | GO 9 | ALTER TABLE [dbo].[NamingForeignKeyRelationship] ADD CONSTRAINT [FK_NamingForeignKeyRelationship_GenericOrClassWord] FOREIGN KEY ([GenericOrClassWordId]) REFERENCES [dbo].[GenericOrClassWord] ([GenericOrClassWordId]) 10 | GO 11 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.Newspaper.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[Newspaper] 2 | ( 3 | [NewspaperId] [int] NOT NULL, 4 | [Name] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 5 | ) ON [PRIMARY] 6 | GO 7 | ALTER TABLE [dbo].[Newspaper] ADD CONSTRAINT [PK_Newspaper] PRIMARY KEY CLUSTERED ([NewspaperId]) ON [PRIMARY] 8 | GO 9 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.NewspaperReader.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[NewspaperReader] 2 | ( 3 | [NewspaperReaderId] [int] NOT NULL, 4 | [NewspaperId] [int] NOT NULL, 5 | [ReaderId] [int] NOT NULL, 6 | [SubscriptionEndDate] [date] NOT NULL 7 | ) ON [PRIMARY] 8 | GO 9 | ALTER TABLE [dbo].[NewspaperReader] ADD CONSTRAINT [PK_NewspaperReader] PRIMARY KEY CLUSTERED ([NewspaperReaderId]) ON [PRIMARY] 10 | GO 11 | ALTER TABLE [dbo].[NewspaperReader] ADD CONSTRAINT [FK_NewspaperReader_Newspaper] FOREIGN KEY ([NewspaperId]) REFERENCES [dbo].[Newspaper] ([NewspaperId]) 12 | GO 13 | ALTER TABLE [dbo].[NewspaperReader] ADD CONSTRAINT [FK_NewspaperReader_Reader] FOREIGN KEY ([ReaderId]) REFERENCES [dbo].[Reader] ([ReaderId]) 14 | GO 15 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.NoPrimaryKey.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[NoPrimaryKey] 2 | ( 3 | [NoPKFoundHere] [int] NULL 4 | ) ON [PRIMARY] 5 | GO 6 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.Number2020.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[Number2020] 2 | ( 3 | [Number2020Id] [int] NOT NULL, 4 | [TableNameContainsNumbers] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 5 | ) ON [PRIMARY] 6 | GO 7 | ALTER TABLE [dbo].[Number2020] ADD CONSTRAINT [PK_Number2020] PRIMARY KEY CLUSTERED ([Number2020Id]) ON [PRIMARY] 8 | GO 9 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.Procedure.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[Procedure] 2 | ( 3 | [ProcedureId] [int] NOT NULL, 4 | [ReservedTableName] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 5 | ) ON [PRIMARY] 6 | GO 7 | ALTER TABLE [dbo].[Procedure] ADD CONSTRAINT [PK_Procedure] PRIMARY KEY CLUSTERED ([ProcedureId]) ON [PRIMARY] 8 | GO 9 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.Reader.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[Reader] 2 | ( 3 | [ReaderId] [int] NOT NULL, 4 | [Name] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 5 | ) ON [PRIMARY] 6 | GO 7 | ALTER TABLE [dbo].[Reader] ADD CONSTRAINT [PK_Reader] PRIMARY KEY CLUSTERED ([ReaderId]) ON [PRIMARY] 8 | GO 9 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.SelectEverythingTrigger.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[SelectEverythingTrigger] 2 | ( 3 | [SelectEverythingTriggerId] [int] NOT NULL 4 | ) ON [PRIMARY] 5 | GO 6 | SET QUOTED_IDENTIFIER ON 7 | GO 8 | SET ANSI_NULLS ON 9 | GO 10 | CREATE TRIGGER [dbo].[SelectEverythingTriggerAfter] 11 | ON [dbo].[SelectEverythingTrigger] 12 | AFTER INSERT 13 | AS 14 | BEGIN 15 | SET NOCOUNT ON; 16 | 17 | SELECT * FROM dbo.SelectEverythingTrigger 18 | 19 | END 20 | GO 21 | ALTER TABLE [dbo].[SelectEverythingTrigger] ADD CONSTRAINT [PK_SelectEverythingTrigger] PRIMARY KEY CLUSTERED ([SelectEverythingTriggerId]) ON [PRIMARY] 22 | GO 23 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.TemporalTable.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[TemporalTable_history] 2 | ( 3 | [TemporalTableId] [int] NOT NULL, 4 | [SomeTemporalValue] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 5 | [RowValidFromTime] [datetime2] NOT NULL, 6 | [RowValidToTime] [datetime2] NOT NULL 7 | ) ON [PRIMARY] 8 | GO 9 | CREATE CLUSTERED INDEX [ix_TemporalTable_history] ON [dbo].[TemporalTable_history] ([RowValidToTime], [RowValidFromTime]) ON [PRIMARY] 10 | GO 11 | CREATE TABLE [dbo].[TemporalTable] 12 | ( 13 | [TemporalTableId] [int] NOT NULL IDENTITY(1, 1), 14 | [SomeTemporalValue] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 15 | [RowValidFromTime] [datetime2] GENERATED ALWAYS AS ROW START NOT NULL CONSTRAINT [Account_AuditFromUtc_Default] DEFAULT (sysutcdatetime()), 16 | [RowValidToTime] [datetime2] GENERATED ALWAYS AS ROW END NOT NULL CONSTRAINT [Account_AuditToUtc_Default] DEFAULT ('9999-12-31 23:59:59.9999999'), 17 | PERIOD FOR SYSTEM_TIME (RowValidFromTime, RowValidToTime), 18 | CONSTRAINT [DBO_TemporalTable_TemporalTableId] PRIMARY KEY CLUSTERED ([TemporalTableId]) ON [PRIMARY] 19 | ) ON [PRIMARY] 20 | WITH 21 | ( 22 | SYSTEM_VERSIONING = ON (HISTORY_TABLE = [dbo].[TemporalTable_history]) 23 | ) 24 | GO 25 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.TriggerUse.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[TriggerUse] 2 | ( 3 | [TriggerId] [int] NOT NULL, 4 | [SomeValue] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 5 | ) ON [PRIMARY] 6 | GO 7 | SET QUOTED_IDENTIFIER ON 8 | GO 9 | SET ANSI_NULLS ON 10 | GO 11 | -- ============================================= 12 | -- Author: 13 | -- Create date: 14 | -- Description: 15 | -- ============================================= 16 | CREATE TRIGGER [dbo].[Reminder1] 17 | ON [dbo].[TriggerUse] 18 | AFTER INSERT,UPDATE 19 | AS 20 | BEGIN 21 | -- SET NOCOUNT ON added to prevent extra result sets from 22 | -- interfering with SELECT statements. 23 | SET NOCOUNT ON; 24 | 25 | RAISERROR ('Notify Customer Relations', 16, 10) 26 | 27 | END 28 | GO 29 | SET QUOTED_IDENTIFIER ON 30 | GO 31 | SET ANSI_NULLS ON 32 | GO 33 | 34 | -- ============================================= 35 | -- Author: 36 | -- Create date: 37 | -- Description: 38 | -- ============================================= 39 | CREATE TRIGGER [dbo].[tr_LowCredit] 40 | ON [dbo].[TriggerUse] 41 | AFTER INSERT 42 | AS 43 | IF (ROWCOUNT_BIG() = 0) RETURN; 44 | IF EXISTS ( 45 | SELECT 1 WHERE 1=2 46 | ) 47 | BEGIN 48 | RAISERROR('A vendor''s credit rating is too low to accept new purchase orders.', 16, 1); 49 | ROLLBACK TRANSACTION; 50 | RETURN; 51 | END; 52 | GO 53 | SET QUOTED_IDENTIFIER ON 54 | GO 55 | SET ANSI_NULLS ON 56 | GO 57 | 58 | -- ============================================= 59 | -- Author: 60 | -- Create date: 61 | -- Description: 62 | -- ============================================= 63 | CREATE TRIGGER [dbo].[trReminder2] 64 | ON [dbo].[TriggerUse] 65 | AFTER INSERT, UPDATE 66 | AS 67 | BEGIN 68 | -- SET NOCOUNT ON added to prevent extra result sets from 69 | -- interfering with SELECT statements. 70 | SET NOCOUNT ON; 71 | 72 | RAISERROR('Notify Vendor Relations', 16, 10); 73 | 74 | END; 75 | GO 76 | ALTER TABLE [dbo].[TriggerUse] ADD CONSTRAINT [PK_TriggerUse] PRIMARY KEY CLUSTERED ([TriggerId]) ON [PRIMARY] 77 | GO 78 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.UNIQUEIDENTIFIERClusteredIndex.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[UNIQUEIDENTIFIERClusteredIndex] 2 | ( 3 | [GUID] [uniqueidentifier] NOT NULL 4 | ) ON [PRIMARY] 5 | GO 6 | ALTER TABLE [dbo].[UNIQUEIDENTIFIERClusteredIndex] ADD CONSTRAINT [PK_UNIQUEIDENTIFIERClusteredIndex] PRIMARY KEY CLUSTERED ([GUID]) ON [PRIMARY] 7 | GO 8 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.UnderScore_Name.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[UnderScore_Name] 2 | ( 3 | [UnderScore_NameId] [int] NOT NULL 4 | ) ON [PRIMARY] 5 | GO 6 | ALTER TABLE [dbo].[UnderScore_Name] ADD CONSTRAINT [PK_UnderScore_Name] PRIMARY KEY CLUSTERED ([UnderScore_NameId]) ON [PRIMARY] 7 | GO 8 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.UnencryptedData.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[UnencryptedData] 2 | ( 3 | [UnencryptedDataId] [int] NOT NULL, 4 | [Password] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 5 | [PasswordIsEncrypted] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 6 | [PasswordSalt] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 7 | [LastPasswordChangedDate] [date] NULL, 8 | [PasswordConfigurationSettings] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 9 | [PasswordComplexityPattern] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 10 | [PasswordExpirationDate] [date] NULL, 11 | [IsPasswordChangedFlag] [bit] NULL, 12 | [LastPasswordFailedDate] [date] NULL, 13 | [MaxPasswordCharacters] [int] NULL, 14 | [MinPasswordLength] [int] NULL, 15 | [PasswordSpecialCharacterRequirement] [bit] NULL, 16 | [PasswordHistoryCount] [int] NULL, 17 | [CreditCardId] [int] NULL, 18 | [CreditCardNumber] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 19 | [CreditCardApprovalCode] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 20 | [CCN] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 21 | [CreditCardToken] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 22 | [SSN] [char] (9) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 23 | [SocialSecurityNumber] [nchar] (11) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 24 | [PassportNumber] [int] NULL, 25 | [DLL] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 26 | [DriverLicenseNumber] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 27 | [LicenseCount] [bigint] NULL 28 | ) ON [PRIMARY] 29 | GO 30 | ALTER TABLE [dbo].[UnencryptedData] ADD CONSTRAINT [PK_UnencryptedData] PRIMARY KEY CLUSTERED ([UnencryptedDataId]) ON [PRIMARY] 31 | GO 32 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.UniqueConstraint.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[UniqueConstraint] 2 | ( 3 | [ColumnName] [char] (11) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL 4 | ) ON [PRIMARY] 5 | GO 6 | ALTER TABLE [dbo].[UniqueConstraint] ADD CONSTRAINT [AK_UniqueConstraint_ColumnName] UNIQUE NONCLUSTERED ([ColumnName]) ON [PRIMARY] 7 | GO 8 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.Untrusted.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[Untrusted] 2 | ( 3 | [UntrustedId] [int] NULL, 4 | [Reader] [int] NULL, 5 | [RegularPrice] [decimal] (18, 4) NULL 6 | ) ON [PRIMARY] 7 | GO 8 | ALTER TABLE [dbo].[Untrusted] WITH NOCHECK ADD CONSTRAINT [Untrusted_RegularPrice_Maximum] CHECK (([RegularPrice]<(1000))) 9 | GO 10 | ALTER TABLE [dbo].[Untrusted] WITH NOCHECK ADD CONSTRAINT [Untrusted_RegularPrice_Minimum] CHECK (([RegularPrice]>(0))) 11 | GO 12 | ALTER TABLE [dbo].[Untrusted] NOCHECK CONSTRAINT [Untrusted_RegularPrice_Maximum] 13 | GO 14 | ALTER TABLE [dbo].[Untrusted] WITH NOCHECK ADD CONSTRAINT [Untrusted_Reader] FOREIGN KEY ([UntrustedId]) REFERENCES [dbo].[Reader] ([ReaderId]) 15 | GO 16 | ALTER TABLE [dbo].[Untrusted] NOCHECK CONSTRAINT [Untrusted_Reader] 17 | GO 18 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.Users.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[Users] 2 | ( 3 | [Id] [int] NOT NULL IDENTITY(1, 1), 4 | [First] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, 5 | [Last] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL 6 | ) ON [PRIMARY] 7 | GO 8 | ALTER TABLE [dbo].[Users] ADD CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED ([Id]) ON [PRIMARY] 9 | GO 10 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.Wide.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[Wide] 2 | ( 3 | [WideId] [int] NOT NULL, 4 | [Column1] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 5 | [Column2] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 6 | [Column3] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 7 | [Column4] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 8 | [Column5] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 9 | [Column6] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 10 | [Column7] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 11 | [Column8] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 12 | [Column9] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 13 | [Column10] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 14 | [Column11] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 15 | [Column12] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 16 | [Column13] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 17 | [Column14] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 18 | [Column15] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 19 | [Column16] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 20 | [Column17] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 21 | [Column18] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 22 | [Column19] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 23 | [Column20] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 24 | ) ON [PRIMARY] 25 | GO 26 | ALTER TABLE [dbo].[Wide] ADD CONSTRAINT [PK_Wide] PRIMARY KEY CLUSTERED ([WideId]) ON [PRIMARY] 27 | GO 28 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.tStore.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[tStore] 2 | ( 3 | [tStoreId] [int] NOT NULL, 4 | [DiscountAmount] [money] NULL, 5 | [Col_PrefixColumn] [nchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 6 | [u_PrefixColumn] [int] NULL 7 | ) ON [PRIMARY] 8 | GO 9 | ALTER TABLE [dbo].[tStore] ADD CONSTRAINT [PK_tStore] PRIMARY KEY CLUSTERED ([tStoreId]) ON [PRIMARY] 10 | GO 11 | -------------------------------------------------------------------------------- /Test Database/Tables/dbo.tblPhone.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[tblPhone] 2 | ( 3 | [ID] [uniqueidentifier] NOT NULL, 4 | [Phone Number] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 5 | [fld_PrefixColumn] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 6 | [c_PrefixColumn] [bit] NULL 7 | ) ON [PRIMARY] 8 | GO 9 | ALTER TABLE [dbo].[tblPhone] ADD CONSTRAINT [PK_ID] PRIMARY KEY NONCLUSTERED ([ID]) ON [PRIMARY] 10 | GO 11 | -------------------------------------------------------------------------------- /Test Database/Types/User-defined Data Types/dbo.SSN.sql: -------------------------------------------------------------------------------- 1 | CREATE TYPE [dbo].[SSN] FROM varchar (11) NOT NULL 2 | GO 3 | -------------------------------------------------------------------------------- /Test Database/Types/User-defined Data Types/dbo.udPhone.sql: -------------------------------------------------------------------------------- 1 | CREATE TYPE [dbo].[udPhone] FROM varchar (12) NOT NULL 2 | GO 3 | -------------------------------------------------------------------------------- /Test Database/Types/User-defined Data Types/dbo.ud_Price.sql: -------------------------------------------------------------------------------- 1 | CREATE TYPE [dbo].[ud_Price] FROM money NOT NULL 2 | GO 3 | -------------------------------------------------------------------------------- /Test Database/Views/DBA.vPhoneSkipMe.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | 6 | CREATE VIEW [DBA].[vPhoneSkipMe] 7 | AS 8 | SELECT ID, [Phone Number] 9 | FROM dbo.tblPhone 10 | GO 11 | EXEC sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00] 12 | Begin DesignProperties = 13 | Begin PaneConfigurations = 14 | Begin PaneConfiguration = 0 15 | NumPanes = 4 16 | Configuration = "(H (1[40] 4[20] 2[20] 3) )" 17 | End 18 | Begin PaneConfiguration = 1 19 | NumPanes = 3 20 | Configuration = "(H (1 [50] 4 [25] 3))" 21 | End 22 | Begin PaneConfiguration = 2 23 | NumPanes = 3 24 | Configuration = "(H (1 [50] 2 [25] 3))" 25 | End 26 | Begin PaneConfiguration = 3 27 | NumPanes = 3 28 | Configuration = "(H (4 [30] 2 [40] 3))" 29 | End 30 | Begin PaneConfiguration = 4 31 | NumPanes = 2 32 | Configuration = "(H (1 [56] 3))" 33 | End 34 | Begin PaneConfiguration = 5 35 | NumPanes = 2 36 | Configuration = "(H (2 [66] 3))" 37 | End 38 | Begin PaneConfiguration = 6 39 | NumPanes = 2 40 | Configuration = "(H (4 [50] 3))" 41 | End 42 | Begin PaneConfiguration = 7 43 | NumPanes = 1 44 | Configuration = "(V (3))" 45 | End 46 | Begin PaneConfiguration = 8 47 | NumPanes = 3 48 | Configuration = "(H (1[56] 4[18] 2) )" 49 | End 50 | Begin PaneConfiguration = 9 51 | NumPanes = 2 52 | Configuration = "(H (1 [75] 4))" 53 | End 54 | Begin PaneConfiguration = 10 55 | NumPanes = 2 56 | Configuration = "(H (1[66] 2) )" 57 | End 58 | Begin PaneConfiguration = 11 59 | NumPanes = 2 60 | Configuration = "(H (4 [60] 2))" 61 | End 62 | Begin PaneConfiguration = 12 63 | NumPanes = 1 64 | Configuration = "(H (1) )" 65 | End 66 | Begin PaneConfiguration = 13 67 | NumPanes = 1 68 | Configuration = "(V (4))" 69 | End 70 | Begin PaneConfiguration = 14 71 | NumPanes = 1 72 | Configuration = "(V (2))" 73 | End 74 | ActivePaneConfig = 0 75 | End 76 | Begin DiagramPane = 77 | Begin Origin = 78 | Top = 0 79 | Left = 0 80 | End 81 | Begin Tables = 82 | Begin Table = "tblPhone" 83 | Begin Extent = 84 | Top = 6 85 | Left = 38 86 | Bottom = 117 87 | Right = 226 88 | End 89 | DisplayFlags = 280 90 | TopColumn = 0 91 | End 92 | End 93 | End 94 | Begin SQLPane = 95 | End 96 | Begin DataPane = 97 | Begin ParameterDefaults = "" 98 | End 99 | End 100 | Begin CriteriaPane = 101 | Begin ColumnWidths = 11 102 | Column = 1440 103 | Alias = 900 104 | Table = 1170 105 | Output = 720 106 | Append = 1400 107 | NewValue = 1170 108 | SortType = 1350 109 | SortOrder = 1410 110 | GroupBy = 1350 111 | Filter = 1350 112 | Or = 1350 113 | Or = 1350 114 | Or = 1350 115 | End 116 | End 117 | End 118 | ', 'SCHEMA', N'DBA', 'VIEW', N'vPhoneSkipMe', NULL, NULL 119 | GO 120 | DECLARE @xp int 121 | SELECT @xp=1 122 | EXEC sp_addextendedproperty N'MS_DiagramPaneCount', @xp, 'SCHEMA', N'DBA', 'VIEW', N'vPhoneSkipMe', NULL, NULL 123 | GO 124 | -------------------------------------------------------------------------------- /Test Database/Views/dbo.vHardcodedDatabaseNameReference.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | 6 | 7 | 8 | CREATE VIEW [dbo].[vHardcodedDatabaseNameReference] 9 | AS 10 | SELECT Id, First, Last 11 | FROM spDevelop.dbo.Users 12 | GO 13 | -------------------------------------------------------------------------------- /Test Database/Views/dbo.vPhone.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | CREATE VIEW [dbo].[vPhone] 6 | AS 7 | SELECT ID, [Phone Number] 8 | FROM dbo.tblPhone 9 | GO 10 | EXEC sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00] 11 | Begin DesignProperties = 12 | Begin PaneConfigurations = 13 | Begin PaneConfiguration = 0 14 | NumPanes = 4 15 | Configuration = "(H (1[40] 4[20] 2[20] 3) )" 16 | End 17 | Begin PaneConfiguration = 1 18 | NumPanes = 3 19 | Configuration = "(H (1 [50] 4 [25] 3))" 20 | End 21 | Begin PaneConfiguration = 2 22 | NumPanes = 3 23 | Configuration = "(H (1 [50] 2 [25] 3))" 24 | End 25 | Begin PaneConfiguration = 3 26 | NumPanes = 3 27 | Configuration = "(H (4 [30] 2 [40] 3))" 28 | End 29 | Begin PaneConfiguration = 4 30 | NumPanes = 2 31 | Configuration = "(H (1 [56] 3))" 32 | End 33 | Begin PaneConfiguration = 5 34 | NumPanes = 2 35 | Configuration = "(H (2 [66] 3))" 36 | End 37 | Begin PaneConfiguration = 6 38 | NumPanes = 2 39 | Configuration = "(H (4 [50] 3))" 40 | End 41 | Begin PaneConfiguration = 7 42 | NumPanes = 1 43 | Configuration = "(V (3))" 44 | End 45 | Begin PaneConfiguration = 8 46 | NumPanes = 3 47 | Configuration = "(H (1[56] 4[18] 2) )" 48 | End 49 | Begin PaneConfiguration = 9 50 | NumPanes = 2 51 | Configuration = "(H (1 [75] 4))" 52 | End 53 | Begin PaneConfiguration = 10 54 | NumPanes = 2 55 | Configuration = "(H (1[66] 2) )" 56 | End 57 | Begin PaneConfiguration = 11 58 | NumPanes = 2 59 | Configuration = "(H (4 [60] 2))" 60 | End 61 | Begin PaneConfiguration = 12 62 | NumPanes = 1 63 | Configuration = "(H (1) )" 64 | End 65 | Begin PaneConfiguration = 13 66 | NumPanes = 1 67 | Configuration = "(V (4))" 68 | End 69 | Begin PaneConfiguration = 14 70 | NumPanes = 1 71 | Configuration = "(V (2))" 72 | End 73 | ActivePaneConfig = 0 74 | End 75 | Begin DiagramPane = 76 | Begin Origin = 77 | Top = 0 78 | Left = 0 79 | End 80 | Begin Tables = 81 | Begin Table = "tblPhone" 82 | Begin Extent = 83 | Top = 6 84 | Left = 38 85 | Bottom = 117 86 | Right = 226 87 | End 88 | DisplayFlags = 280 89 | TopColumn = 0 90 | End 91 | End 92 | End 93 | Begin SQLPane = 94 | End 95 | Begin DataPane = 96 | Begin ParameterDefaults = "" 97 | End 98 | End 99 | Begin CriteriaPane = 100 | Begin ColumnWidths = 11 101 | Column = 1440 102 | Alias = 900 103 | Table = 1170 104 | Output = 720 105 | Append = 1400 106 | NewValue = 1170 107 | SortType = 1350 108 | SortOrder = 1410 109 | GroupBy = 1350 110 | Filter = 1350 111 | Or = 1350 112 | Or = 1350 113 | Or = 1350 114 | End 115 | End 116 | End 117 | ', 'SCHEMA', N'dbo', 'VIEW', N'vPhone', NULL, NULL 118 | GO 119 | DECLARE @xp int 120 | SELECT @xp=1 121 | EXEC sp_addextendedproperty N'MS_DiagramPaneCount', @xp, 'SCHEMA', N'dbo', 'VIEW', N'vPhone', NULL, NULL 122 | GO 123 | -------------------------------------------------------------------------------- /Test Database/Views/dbo.vwPhones.sql: -------------------------------------------------------------------------------- 1 | SET QUOTED_IDENTIFIER ON 2 | GO 3 | SET ANSI_NULLS ON 4 | GO 5 | CREATE VIEW [dbo].[vwPhones] 6 | AS 7 | SELECT ID, [Phone Number] 8 | FROM dbo.tblPhone 9 | GO 10 | EXEC sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00] 11 | Begin DesignProperties = 12 | Begin PaneConfigurations = 13 | Begin PaneConfiguration = 0 14 | NumPanes = 4 15 | Configuration = "(H (1[40] 4[20] 2[20] 3) )" 16 | End 17 | Begin PaneConfiguration = 1 18 | NumPanes = 3 19 | Configuration = "(H (1 [50] 4 [25] 3))" 20 | End 21 | Begin PaneConfiguration = 2 22 | NumPanes = 3 23 | Configuration = "(H (1 [50] 2 [25] 3))" 24 | End 25 | Begin PaneConfiguration = 3 26 | NumPanes = 3 27 | Configuration = "(H (4 [30] 2 [40] 3))" 28 | End 29 | Begin PaneConfiguration = 4 30 | NumPanes = 2 31 | Configuration = "(H (1 [56] 3))" 32 | End 33 | Begin PaneConfiguration = 5 34 | NumPanes = 2 35 | Configuration = "(H (2 [66] 3))" 36 | End 37 | Begin PaneConfiguration = 6 38 | NumPanes = 2 39 | Configuration = "(H (4 [50] 3))" 40 | End 41 | Begin PaneConfiguration = 7 42 | NumPanes = 1 43 | Configuration = "(V (3))" 44 | End 45 | Begin PaneConfiguration = 8 46 | NumPanes = 3 47 | Configuration = "(H (1[56] 4[18] 2) )" 48 | End 49 | Begin PaneConfiguration = 9 50 | NumPanes = 2 51 | Configuration = "(H (1 [75] 4))" 52 | End 53 | Begin PaneConfiguration = 10 54 | NumPanes = 2 55 | Configuration = "(H (1[66] 2) )" 56 | End 57 | Begin PaneConfiguration = 11 58 | NumPanes = 2 59 | Configuration = "(H (4 [60] 2))" 60 | End 61 | Begin PaneConfiguration = 12 62 | NumPanes = 1 63 | Configuration = "(H (1) )" 64 | End 65 | Begin PaneConfiguration = 13 66 | NumPanes = 1 67 | Configuration = "(V (4))" 68 | End 69 | Begin PaneConfiguration = 14 70 | NumPanes = 1 71 | Configuration = "(V (2))" 72 | End 73 | ActivePaneConfig = 0 74 | End 75 | Begin DiagramPane = 76 | Begin Origin = 77 | Top = 0 78 | Left = 0 79 | End 80 | Begin Tables = 81 | Begin Table = "tblPhone" 82 | Begin Extent = 83 | Top = 6 84 | Left = 38 85 | Bottom = 117 86 | Right = 226 87 | End 88 | DisplayFlags = 280 89 | TopColumn = 0 90 | End 91 | End 92 | End 93 | Begin SQLPane = 94 | End 95 | Begin DataPane = 96 | Begin ParameterDefaults = "" 97 | End 98 | End 99 | Begin CriteriaPane = 100 | Begin ColumnWidths = 11 101 | Column = 1440 102 | Alias = 900 103 | Table = 1170 104 | Output = 720 105 | Append = 1400 106 | NewValue = 1170 107 | SortType = 1350 108 | SortOrder = 1410 109 | GroupBy = 1350 110 | Filter = 1350 111 | Or = 1350 112 | Or = 1350 113 | Or = 1350 114 | End 115 | End 116 | End 117 | ', 'SCHEMA', N'dbo', 'VIEW', N'vwPhones', NULL, NULL 118 | GO 119 | DECLARE @xp int 120 | SELECT @xp=1 121 | EXEC sp_addextendedproperty N'MS_DiagramPaneCount', @xp, 'SCHEMA', N'dbo', 'VIEW', N'vwPhones', NULL, NULL 122 | GO 123 | -------------------------------------------------------------------------------- /docs/Contact.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Contact 3 | permalink: contact 4 | nav_order: 10 5 | layout: default 6 | --- 7 | 8 | Please connect with me (Kevin Martin) if you need assistance with sp_Develop or any of our [SQL Server consulting services](https://www.emergentsoftware.net/services/database/): 9 | 10 | - [Emergent Software](https://www.emergentsoftware.net) 11 | - [Kevin Martin on LinkedIn](https://www.linkedin.com/in/KevinMartinTech) 12 | - [Kevin Martin on Twitter](https://twitter.com/KevinMartinTech) 13 | - [Kevin Martin on GitHub](https://github.com/KevinMartinTech) -------------------------------------------------------------------------------- /docs/DevelopmentAppSettings.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Development App Settings 3 | permalink: development-app-settings 4 | nav_order: 8 5 | layout: default 6 | --- 7 | 8 | # Configure Development Application Settings 9 | 10 | Included in this project are settings you can use for database development. Using the same set of settings across a team will helps ensure consistent development patterns. 11 | 12 | ## SQL Server Management Studio 13 | 14 | The settings are located in the project "[\SQL-Server-Assess\Development Application Settings\Microsoft\SQL Server Management Studio\General Settings](https://github.com/EmergentSoftware/SQL-Server-Development-Assessment/tree/master/Development%20Application%20Settings/Microsoft/SQL%20Server%20Management%20Studio/General%20Settings)" 15 | 16 | 1. Cloned or forked the repo 17 | 2. In SQL Server Management Studio navigate to "Tools > Options > Environment > Import and Export Settings" 18 | 3. Check "Use team settings file" and browse to "..\SQL-Server-Assess\Development Application Settings\Microsoft\SQL Server Management Studio\General Settings\SSMS.vssettings" 19 | 4. Click the "OK" button 20 | 21 | ## Redgate SQL Server Prompt 22 | 23 | The settings are located in the project "[\SQL-Server-Assess\Development Application Settings\Red Gate\SQL Prompt](https://github.com/EmergentSoftware/SQL-Server-Development-Assessment/tree/master/Development%20Application%20Settings/Red%20Gate/SQL%20Prompt)" 24 | 25 | 1. Cloned or forked the repo 26 | 2. Follow [these directions](https://documentation.red-gate.com/sp/managing-sql-prompt-behavior/sharing-your-settings) 27 | 28 | [Browse the check findings](findings){: .btn .btn-purple } 29 | [View on GitHub](https://github.com/EmergentSoftware/SQL-Server-Development-Assessment){: .btn } 30 | 31 | --- 32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
-------------------------------------------------------------------------------- /docs/Images/JOIN_Elimination_NOT_NULL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/8787a1a70ccd9933336cffaf98d6b3a92e117eec/docs/Images/JOIN_Elimination_NOT_NULL.png -------------------------------------------------------------------------------- /docs/Images/JOIN_Elimination_NULL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/8787a1a70ccd9933336cffaf98d6b3a92e117eec/docs/Images/JOIN_Elimination_NULL.png -------------------------------------------------------------------------------- /docs/Images/Mixing_Data_Types_in_JOIN_or_WHERE_Clauses.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/8787a1a70ccd9933336cffaf98d6b3a92e117eec/docs/Images/Mixing_Data_Types_in_JOIN_or_WHERE_Clauses.png -------------------------------------------------------------------------------- /docs/Images/Non-SARGable_Does_Not_Get_Index_Recommendation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/8787a1a70ccd9933336cffaf98d6b3a92e117eec/docs/Images/Non-SARGable_Does_Not_Get_Index_Recommendation.png -------------------------------------------------------------------------------- /docs/Images/Not_Using_Location_Comment_Statement_Parent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/8787a1a70ccd9933336cffaf98d6b3a92e117eec/docs/Images/Not_Using_Location_Comment_Statement_Parent.png -------------------------------------------------------------------------------- /docs/Images/UNIQUEIDENTIFIER_For_Primary_Key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/8787a1a70ccd9933336cffaf98d6b3a92e117eec/docs/Images/UNIQUEIDENTIFIER_For_Primary_Key.png -------------------------------------------------------------------------------- /docs/Images/Using_a_Non-SARGable_Expression_in_a_WHERE_Clause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/8787a1a70ccd9933336cffaf98d6b3a92e117eec/docs/Images/Using_a_Non-SARGable_Expression_in_a_WHERE_Clause.png -------------------------------------------------------------------------------- /docs/Images/sp_Develop_Results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/8787a1a70ccd9933336cffaf98d6b3a92e117eec/docs/Images/sp_Develop_Results.png -------------------------------------------------------------------------------- /docs/InstallInstruction.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Install Instructions 3 | permalink: install-instructions 4 | nav_order: 2 5 | layout: default 6 | --- 7 | 8 | # sp_Develop Install Instructions 9 | 10 | Download a copy of the stored procedure [sp_Develop](https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/master/sp_Develop.sql). Execute the stored procedure to create it on your SQL Server. 11 | 12 | It is recommend installing the [sp_Develop](https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/master/sp_Develop.sql) stored procedures in the master database for full SQL Servers, but if you want to use another one, that's totally fine. 13 | 14 | On Azure SQL Server you will need to install the [sp_Develop](https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/master/sp_Develop.sql) stored procedure in the user database. 15 | 16 | [How to run sp_Develop](usage-instructions){: .btn .btn-purple } 17 | [View on GitHub](https://github.com/EmergentSoftware/SQL-Server-Development-Assessment){: .btn } -------------------------------------------------------------------------------- /docs/ParameterExplanations.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Parameter Explanations 3 | permalink: parameter-explanations 4 | nav_order: 5 5 | layout: default 6 | --- 7 | 8 | # sp_Develop Parameter Explanations 9 | 10 | While you can run [sp_Develop](https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/master/sp_Develop.sql) without any parameters there is more you can do with additional parameters. 11 | 12 | |Parameter|Details| 13 | |--|--| 14 | |@DatabaseName|Defaults to current DB if not specified| 15 | |@GetAllDatabases|When = 1, runs checks across all the databases on the server instead of just your current database context. Does not work on Azure SQL Server.| 16 | |@BringThePain |If you’ve got more than 50 databases on the server, this only works if you also pass in @BringThePain = 1, because it’s gonna be slow.| 17 | |@SkipCheckServer|The linked server name that stores the skip checks| 18 | |@SkipCheckDatabase|The database that stores the skip checks| 19 | |@SkipCheckSchema|The schema for the skip check table, when you pass in a value the SkipCheckTSQL column will be used| 20 | |@SkipCheckTable|The table that stores the skip checks, when you pass in a value the SkipCheckTSQL column will be used| 21 | |@OutputType|TABLE = table
COUNT = row with number found
MARKDOWN = bulleted list
XML = table output as XML
NONE = none| 22 | |@ShowSummary|When = 1, a summary result set is outputted displaying a count of the findings based on the finding group and finding.| 23 | |@PriorityOrHigher|When you specify [Critical, High, Medium, Low] for a value the result set will only findings with the matching priority level or higher.| 24 | |@RunCheckIds|Specify a comma delimited list of CheckIds like 1,2,3 if you only need a limited number of checks to run.| 25 | |@Debug|When = 1, we print out messages of what we're doing in the messages tab of SQL Server Management Studio. When 2, we print out the dynamic SQL query of the check.| 26 | |@Version|Output variable to check the version number.| 27 | |@VersionDate|Output variable to check the version date.| 28 | |@VersionCheckMode|Will set the version output variables and return without running the stored procedure.| 29 | 30 | [Why you would want to skip checks](how-to-skip-checks){: .btn .btn-purple } 31 | [View on GitHub](https://github.com/EmergentSoftware/SQL-Server-Development-Assessment){: .btn } -------------------------------------------------------------------------------- /docs/ResultsExplanations.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Results Explanations 3 | permalink: results-explanations 4 | nav_order: 4 5 | layout: default 6 | --- 7 | 8 | # sp_Develop Results Explanations 9 | 10 | After running [sp_Develop](https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/master/sp_Develop.sql) the 'Results' tab will contain the findings for the best practice DBA development checks. 11 | 12 | ![sp_Develop Results](Images/sp_Develop_Results.png) 13 | 14 | The findings results are order by DatabaseName, SchemaName, ObjectName, ObjectType, FindingGroup, Finding. This allows you to review all the checks for an object at the same time. 15 | 16 | ## Column Results Details 17 | 18 | |Column Name|Details| 19 | |--|--| 20 | |Priority|Critical, High, Medium, Low| 21 | |DatabaseName|Can be run for multiple databases so this will show you the database with the potential issue| 22 | |SchemaName|This is the schema for the object that might have an issue| 23 | |ObjectName|This can be anything from user tables, views stored procedures, functions, …| 24 | |FindingGroup|The high-level grouping for the check
- Naming Conventions
- Table Conventions
- Data Type Conventions
- SQL Code Development
- Data Issue
- Configuration Issue
- Running Issues| 25 | |Finding|The specific potential issue we the check is looking for| 26 | |Details|Additional details about the potential issue. This does not go into in-depth details of the potential issue but should give you a heads up of what to look for| 27 | |URL|Copy and paste this link into a browser to view the write up for the potential issue| 28 | |SkipCheckTSQL|In this column you will find a generated TSQL script INSERT | 29 | |PriorityNumber|The lower the number the more severe the potential issue is to address| 30 | |CheckId|Every check is uniquely numbered| 31 | 32 | [What other parameters can be used](parameter-explanations){: .btn .btn-purple } 33 | [View on GitHub](https://github.com/EmergentSoftware/SQL-Server-Development-Assessment){: .btn } 34 | -------------------------------------------------------------------------------- /docs/TestDatabaseInstall.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Test Database Install 3 | permalink: test-database-install 4 | nav_order: 7 5 | layout: default 6 | --- 7 | 8 | # Test Database Install 9 | 10 | The [Test Database](https://github.com/EmergentSoftware/SQL-Server-Development-Assessment/tree/master/Test%20Database) folder contains the RedGate SQL Source Control. Use this database for creating and testing checks. If you are not going to be developing [sp_Develop](https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/master/sp_Develop.sql) checks you can skip this page. 11 | 12 | SQL Server 2008+ is supported. You can script out the test database and downgrade schema features like `DATETIME2` that is not supported. SQL Server Developer editions are now free, go [download](https://www.microsoft.com/en-us/sql-server/sql-server-downloads) and install the latest version for development. 13 | 14 | ## Quick Steps to Setup and Use: 15 | 16 | 1. Create new database 'spDevelopTest' and select in Object Browser 17 | 2. Open Redgate SQL Source Control in SQL Server Management Studio 18 | 3. Click 'Setup' tab 19 | 4. Select 'Link to my source control system' and click 'Next' 20 | 5. Browser to '..\Test Database' cloned folder and click 'Link' 21 | 6. Click 'Get latest' tab 22 | 7. Pull or refresh if required and click 'Apply changes' button 23 | 8. Develop objects to use when you create a new check 24 | 9. Click 'Commit' tab 25 | 10. Select objects to be pulled back into the branch, add comment, click the 'Commit' button and click the 'Push' button 26 | 11. **Note:** there are exclude filters setup for invalid objects created in the post script. Do not check these objects back into the branch. 27 | 28 | 29 | ## Redgate SQL Source Control Documentation 30 | 31 | - [Getting Started ](https://documentation.red-gate.com/soc7/getting-started) 32 | - [Link to Git](https://documentation.red-gate.com/soc7/linking-to-source-control/link-to-git) 33 | 34 | [Sharing development app settings](development-app-settings){: .btn .btn-purple } 35 | [View on GitHub](https://github.com/EmergentSoftware/SQL-Server-Development-Assessment){: .btn } -------------------------------------------------------------------------------- /docs/UsageInstructions.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Usage Instructions 3 | permalink: usage-instructions 4 | nav_order: 3 5 | layout: default 6 | --- 7 | 8 | # sp_Develop Usage Instructions 9 | 10 | After installing the [sp_Develop](https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/master/sp_Develop.sql) stored procedure, open SQL Server Management Studio and run in the database you wish to check for database development best practices. 11 | 12 | ```sql 13 | EXECUTE dbo.sp_Develop; 14 | ``` 15 | 16 | That's the bare minimum you need to run the best practice checks! 17 | 18 | If you are new to sp_Develop, it is recommended you start with the SQL statement below to limit the number of findings. 19 | 20 | ```sql 21 | EXECUTE dbo.sp_Develop @PriorityOrHigher = 'High'; 22 | ``` 23 | 24 | Visit [Parameter Explanations for more options](parameter-explanations) 25 | 26 | [What the results mean](results-explanations){: .btn .btn-purple } 27 | [View on GitHub](https://github.com/EmergentSoftware/SQL-Server-Development-Assessment){: .btn } -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | title: "sp_Develop" 2 | description: "sp_Develop can be used by database developers, software developers and for performing database code (smell) reviews." 3 | remote_theme: "pmarsceill/just-the-docs" 4 | color_scheme: "light" 5 | search_enabled: "true" 6 | baseurl: "/SQL-Server-Development-Assessment" 7 | url: "https://emergentsoftware.github.io" 8 | 9 | 10 | 11 | # Enable or disable heading anchors 12 | heading_anchors: "true" 13 | 14 | 15 | # Aux links for the upper right navigation 16 | aux_links: 17 | "sp_Develop on GitHub": 18 | - "//github.com/EmergentSoftware/SQL-Server-Development-Assessment" 19 | 20 | 21 | 22 | # Footer content 23 | # appears at the bottom of every page's main content 24 | 25 | # Back to top link 26 | back_to_top: "true" 27 | back_to_top_text: "Back to top" 28 | 29 | footer_content: "Copyright © 2020-2022 Emergent Software, LLC. Distributed by an MIT license." 30 | 31 | # Footer last edited timestamp 32 | last_edit_timestamp: true # show or hide edit time - page must have `last_modified_date` defined in the frontmatter 33 | last_edit_time_format: "%b %e %Y at %I:%M %p" # uses ruby's time format: https://ruby-doc.org/stdlib-2.7.0/libdoc/time/rdoc/Time.html 34 | 35 | # Footer "Edit this page on GitHub" link text 36 | gh_edit_link: true # show or hide edit this page link 37 | gh_edit_link_text: "Edit this page on GitHub" 38 | gh_edit_repository: "https://github.com/EmergentSoftware/SQL-Server-Development-Assessment" # the github URL for your repo 39 | gh_edit_branch: "master" # the branch that your docs is served from 40 | gh_edit_source: docs # the source that your files originate from 41 | gh_edit_view_mode: "tree" # "tree" or "edit" if you want the user to jump into the editor immediately 42 | 43 | 44 | # Google Analytics Tracking (optional) 45 | ga_tracking: G-Y3VRXTG8JR 46 | ga_tracking_anonymize_ip: false # Use GDPR compliant Google Analytics settings (true by default) 47 | -------------------------------------------------------------------------------- /docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/8787a1a70ccd9933336cffaf98d6b3a92e117eec/docs/favicon.ico -------------------------------------------------------------------------------- /docs/findings/CurrentHighCheckId.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Current High Check Id 3 | permalink: best-practices-and-potential-findings/current-high-check-id 4 | parent: Best Practices & Potential Findings 5 | nav_order: 99 6 | layout: default 7 | --- 8 | 9 | # Current High Check Id 10 | 11 | If you want to add a new check, use this number then add +1 for the next one. 12 | 13 | **Next Check Id:** 161 14 | 15 | [Back to top](#top) 16 | 17 | --- 18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
-------------------------------------------------------------------------------- /docs/findings/DataIssues.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Data Issues 3 | permalink: best-practices-and-potential-findings/data-issues 4 | parent: Best Practices & Potential Findings 5 | nav_order: 5 6 | layout: default 7 | --- 8 | 9 | # Data Issues 10 | {: .no_toc } 11 | Checks for data issues. 12 | 13 | --- 14 | 15 |
16 | 17 | Table of contents 18 | 19 | {: .text-delta } 20 | 1. TOC 21 | {:toc} 22 |
23 | 24 | [Back to top](#top) 25 | 26 | --- 27 | 28 | 29 | 30 | ## Using Placeholder Rows 31 | **Check Id:** 60 [Not implemented yet. Click here to add the issue if you want to develop and create a pull request.](https://github.com/EmergentSoftware/SQL-Server-Development-Assessment/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=Using+Placeholder+Rows) 32 | 33 | A placeholder is an empty row/record that is created to hold the place of possible future data in the row that may or may not be necessary. 34 | 35 | While placeholder rows do not violate database normalization rules, it is not considered a best practice to create "empty" rows. Row data should only be created when it is materialized. If the row data does not exists, it should not be inserted. If the row data is removed, the row should be hard or soft deleted. Empty rows are not free, there is overhead space allocated with placeholder rows, which can impact performance. 36 | 37 | Having the unnecessary placeholder rows can muddy queries that now would need to include ```IS NOT NULL``` or ```LEN(PhoneNumber) > 0``` to exclude these placeholder rows on other queries. 38 | 39 | [Back to top](#top) 40 | 41 | --- 42 | 43 | 44 | 45 | ## Data Should be Encrypted if Compliance Dictates 46 | **Potential Finding:** Unencrypted Data
47 | **Check Id:** 27 48 | 49 | The table column returned for this check might have unencrypted data that you might want to have encrypted for best practices or industry specific compliance. You will need to determine if the data needs to be protected at rest, in transit or both. 50 | 51 | **With SQL Server you have a couple choices to implement hashing or encryption** 52 | 53 | - [SQL Server Always Encrypt](https://docs.microsoft.com/en-us/sql/relational-databases/security/encryption/always-encrypted-database-engine) 54 | - [SQL Server Transparent Data Encryption (TDE)](https://docs.microsoft.com/en-us/sql/relational-databases/security/encryption/transparent-data-encryption) 55 | - You could develop your own or utilize a development framework pattern to implement a custom one-way hashing, hashing with salting or encryption using AES-128, AES-192, AES-256. 56 | 57 | 58 | [Back to top](#top) 59 | 60 | --- 61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
-------------------------------------------------------------------------------- /docs/findings/Index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Best Practices & Potential Findings 3 | permalink: best-practices-and-potential-findings 4 | nav_order: 9 5 | has_children: true 6 | layout: default 7 | --- 8 |
9 | # Best Practices & Potential Findings 10 | 11 | The sections below are where you will find the details for each of the checks performed in [sp_Develop](https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/master/sp_Develop.sql). 12 | 13 | Feel free to browse the finding groupings. There are best practices that do not have a check created yet. 14 | 15 | some best practices might not have potential findings that sp_Develop can detect and some might have more than one 16 | 17 | Please consider [Contributing to the SQL Server Assess](https://github.com/EmergentSoftware/SQL-Server-Development-Assessment/blob/master/CONTRIBUTING.md) project. -------------------------------------------------------------------------------- /docs/findings/RunningIssues.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Running Issues 3 | permalink: best-practices-and-potential-findings/running-issues 4 | parent: Best Practices & Potential Findings 5 | nav_order: 7 6 | layout: default 7 | --- 8 | 9 | # Running Issues 10 | {: .no_toc } 11 | These are some issues you might run into when running [sp_Develop](https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/master/sp_Develop.sql). 12 | 13 | --- 14 | 15 |
16 | 17 | Table of contents 18 | 19 | {: .text-delta } 20 | 1. TOC 21 | {:toc} 22 |
23 | 24 | [Back to top](#top) 25 | 26 | --- 27 | 28 | 29 | 30 | ## Some Checks Skipped 31 | **Check Id:** 26 32 | 33 | We skipped some checks that are not currently possible, relevant, or practical for the SQL Server [sp_Develop](https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/master/sp_Develop.sql) is running against. This could be due to the SQL Server version/edition or the database compatibility level. 34 | 35 | 36 | [Back to top](#top) 37 | 38 | --- 39 | 40 | 41 | 42 | ## sp_Develop is Over 6 Months Old 43 | **Check Id:** 16 44 | 45 | There most likely been some new checks and fixes performed within the last 6 months - time to go download the current [sp_Develop](https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/master/sp_Develop.sql). 46 | 47 | 48 | [Back to top](#top) 49 | 50 | --- 51 | 52 | 53 | 54 | ## Ran on a Non-Readable Availability Group Secondary Databases 55 | **Check Id:** 17 56 | 57 | You are running this on an AG secondary, and some of your databases are configured as non-readable when this is a secondary node. To analyze those databases, run [sp_Develop](https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/master/sp_Develop.sql) on the primary, or on a readable secondary. 58 | 59 | 60 | [Back to top](#top) 61 | 62 | --- 63 | 64 | 65 | 66 | ## Ran Against 50+ Databases Without @BringThePain = 1 67 | **Check Id:** 18 68 | 69 | Running [sp_Develop](https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/master/sp_Develop.sql) on a server with 50+ databases may cause temporary insanity for the server and/or user. If you're sure you want to do this, run again with the parameter @BringThePain = 1. 70 | 71 | [Back to top](#top) 72 | 73 | --- 74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
-------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Home 3 | permalink: / 4 | nav_order: 1 5 | layout: default 6 | --- 7 | 8 | # SQL Server Development Assessment Overview 9 | The open source SQL Server Development Assessment project contains the [sp_Develop](https://raw.githubusercontent.com/EmergentSoftware/SQL-Server-Development-Assessment/master/sp_Develop.sql) stored procedure. It can be used by database developers, software developers and for performing database code (smell) assessments to adhere to best practices. 10 | 11 | **NOTE:** not all checks have been developed. Browse the [Findings](findings) to discover other helpful database development best practices. Use the site search to find best practices super quick! 12 | 13 | You can use the link in the [results tab](results-explanations) to navigate to the [Findings](findings) specific check details. Also, feel free to read through the sections as there might not be a check created yet to incorporate other best practices in your development. 14 | 15 | sp_Develop runs on SQL Server 2005, 2008, 2008 R2, 2012, 2014,2016, 2017, 2019, Azure SQL Server 16 | 17 | Please consider [Contributing to the SQL Server Development Assessment](https://github.com/EmergentSoftware/SQL-Server-Development-Assessment/blob/master/CONTRIBUTING.md) project. 18 | 19 | [Get started now and install](install-instructions){: .btn .btn-purple } 20 | [View on GitHub](https://github.com/EmergentSoftware/SQL-Server-Development-Assessment){: .btn } --------------------------------------------------------------------------------