sql
TSQL - Get Index By Table Name + Column Name
· ☕ 1 min read
Below SQL code will find an index name that corresponds to the given table name and column name pair, and only include those indices with one column (exclude composite indices). Indices can be changed / added / removed by a DBA without impact to the application (part of DB tuning), so it’s best not to assume their naming in an application deployment script. This can be useful to remove / replace certain indices without relying on index name.

Cannot open .SQL file in Visual Studio 2010
· ☕ 1 min read
Environment hangs, completely at times, or just for several seconds. If it resumes after hanging, you are able to close the tab where this .SQL file would show up. In any case, you cannot see or edit anything in there, seeing this Visual Studio 2010 branded blue background all over the contents area.

MS SQL Server 2008 R2 error log growing rapidly
· ☕ 1 min read
MS SQL server 2008 R2 was spamming the error log with the following two messages (got around 50GB of them in 4 days). An exception occurred while enqueueing a message in the target queue. Error 15517, State 1. Cannot execute as the database principal because the principal "dbo" does not exist, this type of principal cannot be impersonated, or you do not have permission.

MS SQL drop column with default constraint
· ☕ 1 min read
The following MS SQL script will generate MS SQL statements to drop a list of columns with default constraint for a certain table. Need to change table_name and list of columns, as applicable. Statements will be generated only if required.

Oracle ALTER SEQUENCE - START WITH not working?
· ☕ 1 min read
I googled over many websites explaining the error code and suggesting you do not change it. What if you really need to? One approach is to call NEXTVAL as many times to shift the sequence, so that it starts with your START WITH number (<SW>). A better one is to change INCREMENT BY to a certain value instead, then do NEXTVAL and revert INCREMENT BY.

SQL Reporting Services - Fix Border Thickness
· ☕ 1 min read
When the report is rendered on the screen in preview mode, it looks okay. However, when it is saved to PDF and/or printed, table borders might have slightly different thickness depending on relative location on the sheet. I believe this issue is related to DPI scaling.