Skip to content
Advertisement

Tag: .net

SQL query with dynamic parameters

I tried to get some data from DB. I need get account information from my table – this type of information will depend on User. If he/she will insert account type = 1 -> he will get this information. How could I create query if it will depend on user: for example user could choose one or more account types

SQL Query to remove duplicated data and take single column sum

I have the following table resulted from but now I want to remove the repeated rows except the Sum of ‘TotalBill’. Answer Use GROUP BY: Note that for the billing date, the two “duplicate” records you have highlighted have different dates. It is not clear which date, if any, you want to report here. I have omitted this column.

Identity column as part of primary key

Suppose, I have a composite primary key that consists of 3 columns: [ShardKey], [SiteId] and [ServiceId]. Column [ServiceId] is an identity column and should start from 1 for a new combination of [ShardKey] and [SiteId], but SQL server fails – the column [ServiceId] never starts from 1, it just increments its value no matter what the primary key is. I

Advertisement