Questions tagged [tsql]
27 questions
230
votes
19 answers
Why is naming a table's Primary Key column "Id" considered bad practice?
My t-sql teacher told us that naming our PK column "Id" is considered bad practice without any further explanations.
Why is naming a table PK column "Id" is considered bad practice?

Jean-Philippe Leclerc
- 846
- 2
- 8
- 10
60
votes
24 answers
How can I explain the difference between NULL and zero?
Working on a problem that uses the percent change formula:
percent change = 100 * [(new value - old value) / old value]
How would I explain the difference if new value or old value = NULL, rather than 0 to someone who might not be a programmer?
My…

O.O
- 668
- 1
- 9
- 15
9
votes
3 answers
How do you handle constantly changing database dimensions?
For the last two months or so I have been looking for solutions or practices to handle release management within databases. I'm looking for what people view as the best process for handling this.
We have 3 environments for our…

judda
- 193
- 5
7
votes
4 answers
Should I Do Calculations in T-SQL or Program?
I am creating a stored procedure that is logging some data. The data ultimately needs to end up in 2 tables. The incoming data is coming from a JSON string containing 15 parameters, and the data is then logged to the database using the stored…

jwatts1980
- 325
- 3
- 10
5
votes
3 answers
Combine union with distinct
Situation: I need distinct results from two tables, that both have duplicates.
I would like to know if I should combine UNION and DISTINCT.
Example 1 - Only use distinct
SELECT DistinctValue
FROM Table1
UNION
SELECT DistinctValue
FROM…

annemartijn
- 225
- 1
- 2
- 8
4
votes
2 answers
Why are triggers seen as a last resort to solve multiple paths in cascading deletes?
There is a problem using ON DELETE CASCADE on foreign keys in a SQL database if there are multiple paths from the root foreign key to the leaf. The way around this seems to be to replace the ON DELETE CASCADEs with INSTEAD OF DELETE…

dumbledad
- 317
- 1
- 2
- 12
4
votes
5 answers
I feel unprepared to start my first job out of college... how can I improve?
I just graduated from university with a degree in Computer Science/Engineering and was fortunate enough to land a job working in the pharmaceutical industry as a developer. My title is System Developer I, which will require the following skills:
0-3…

Evan Williams
- 57
- 1
- 2
4
votes
1 answer
Is there another name for Sql Azure's programming language?
According to this page on MSDN the sql language used on Sql Azure is called transact-sql (the same as on sql server). But is this the only way to refer to programming on Sql Azure?
The Sql Azure variant of transact-sql doesn't support a bunch of…

amelvin
- 1,525
- 1
- 11
- 19
4
votes
2 answers
Bill of materials database design in EF codefirst?
I'm having trouble generating a proper database design for bill of materials in EF Code-first
I just need a general structure then ill add additional fields
So i need to have a Product that is assembled from other Products which are assemblies of…
Seeker
4
votes
3 answers
How to reach to the advanced level in SQL?
I think I have a good grasp of SQL and the most features it has, but sometimes when I've done some more advanced Reporting Services a fellow developer has helped me with some stuff and when I open some existing procedures in T-SQL I understand that…

marko
- 1,103
- 2
- 11
- 18
3
votes
4 answers
Unit testing Systems with Logic Tightly Coupled with Data
I understand there are many questions in this site revolving around the same concept, but I could not get a precise answer for my case.
Problem
I am handling an ERP System, with code base in both:
VB.NET/ASP Forms for the user interface portion of…

A.Rashad
- 594
- 3
- 19
3
votes
1 answer
T-SQL Development debate, which is the correct approach
The company I work at uses stored procedures (and a home-grown ORM) exclusively for all database interaction, selects, updates, deletes.
We have numerous procs that will insert and/or update and/or delete from tables.
When it's required to…

ganders
- 411
- 2
- 5
- 18
3
votes
2 answers
An algorithm that spreads similar items across a list
I need an algorithm that distributes same items across a list, so maximizing the distance between occurrences.
E.g.
I have a list of 15 items:
{a,b,c,c,c,d,e,f,f,f,g,h,h,i,j}
The algorithm should reorder these in such a way that all the duplicates…

Robert van Dijk
- 41
- 3
3
votes
1 answer
How can I improve quality on SQL reports?
I've recently ran into some issues where some reports were not generating the proper results. We already have a QA department that reviews the reports and then our business owners review them as well; this hasn't prevented the issue.
I'm trying to…

UnhandledExcepSean
- 153
- 5
2
votes
5 answers
Architecture strategies for a complex competition scoring system
Competition description:
There are about 10 teams competing against each other over a 6-week period.
Each team's total score (out of a 1000 total available points) is based on the total of its scores in about 25,000 different scoring elements.
Most…

MikeWazz
- 51
- 2