I am trying to add a new column to an existing table in SQL Server. I want this new column’s value to be determined based on the contents of two existing columns within the table. For example there is one column called manufacturer and another called Vendor. When the contents of these two columns are th…
Tag: sql-server
Counting totals on two separate SQL tables
I have two (identical for this purpose) tables ToDoList DoneList I’m trying to get a count from each of these per [ItemBatch] but not sure if that’s actually possible in one query? Separately I’d just do and assign to variables in the front-end so I could get the following: Is there a query …
‘Procedure Has Too Many Arguments’ Error Although I Have Only Two
I checked the other posts related to this problem but could not find any answers. I have a post action method for my hotel api and in the Hotel Repository I have this CreateHotel method below. I just enter two arguments and there’s two arguments in the stored procedure too but I get this error: System.D…
Create date table of every second between two dates
I need to create a table of every second between two input dates eg between 01/01/2015 00:00:01 and 05/01/2016 00:00:00 So a 3m row expected output that looks like this: Does this need a CLR? …
How to use case to construct a conditional update
I have to write an update query. If the special_member account is not cancelled then in the where clause I have to use this condition by adding a grace period of 15 days to the expiry date and compare …
Use multiple criteria in SQL Server and return value
I have the following criteria that won’t run. I have tried: SELECT Main_ID AS [First_Custom_Column], CASE WHEN Column_1 = ‘Y’ AND SUM(CASE WHEN Column_3 > 1 THEN …
Return all rows from one table, and match rows from another table
I have the following two tables: ExchangeRate (T1): CurrencyCode Rate CHF 6.9660 EUR 7.4445 GBP 8.2569 NOK 0.6686 Customer (T2): CustomerNo Name …
Multiple aggregate calculations using Group by
I have a dataset, df1, where I would like to: Take the average of the TotalB column based upon grouping the TotalB column. I would then like to take this new column and subtract the free value to …
After Insert trigger to modify particular value
I have some problems with my trigger. On my transactions table I can’t allow any rows to be inserted which are cancelled. Any transaction can be Scheduled, Done or Cancelled. If you insert a cancelled …
String formatting issue for creating the SQL query for BCP
I want to use some of the static data to the new BCP query and export the extracted data to CSV. The static data are generated as a result after running some BCP command earlier. But I have been facing string formatting issue for creating the SQL query using those variables and generate a SQL command. I simpl…