We changed our privacy policy. Read more.

Hot answers tagged

1

If the post_id is unique, why not make it a primary key? Sometimes it is justified to have an internally-controlled primary key like id but here the justification is unclear. One catch is that if the two forums are from different websites, their ID sequences will be different and you don't have a choice but to maintain your own primary keys. Transact-SQL ...


1

Aside from the indexes (which is important), you can improve the query by storing the username in a variable and adding the username condition in the join, which would simplify the query and improve the join performance : CREATE Function [compliance].[fn_AllowActivity] (@ActivityID sysname) RETURNS TABLE WITH schemabinding AS DECLARE @UserName VARCHAR(...


1

serial / bigserial are deprecated and you should instead use a generated always as identity clause on an integer-type column. It looks like you're storing a plaintext password. No, please, no. You need to read about password hashing and salting in general, and then the PostgreSQL crypto support routines. The string undefined is not a good way to represent a ...


1

Your SQL function would only covers 1-day holiday, how about multi-day holidays like Memorial Day, Thanksgiving ..etc.? To cover them, you will need to get the maximum total holidays in your company, and use that number to your query. For example, say your company's holidays are usually 1-3 days, and only one holiday that is 9-day holiday. Then, what you can ...


1

The current query would get all databases except system databases, ignoring the current owners. What I prefer is to include the owner in the filter as well, so it'll always have the databases with different owner than sa. here is a suggested revision : SELECT db.name FROM sys.databases db LEFT JOIN sys.server_principals sp ON sp.sid = db.owner_sid WHERE ...


1

It looks like you are trying to get the cost of a work order including its children, if it has any, by joining from workorder nt to your in-line view t where nt.wonum = t.parent. Are you aware that there is a wogroup column on workorder whose value is the same as wonum for non-task work orders and the same as parent on task work orders? So, you could remove ...


Only top voted, non community-wiki answers of a minimum length are eligible