Skip to content

Tag: tsql

MS SQL Server – How to create a view from a CTE?

The here above SQL is outputing like a charm all hours between two dates and a field retrieved from a join with another table: I would like to create a view from that but I do not manage to do it. I tried several things but without success. The following is returning : Incorrect syntax near the keyword &#8216…

Join Two Non Related Tables

I have two tables Like A and B. Each have one column (ID) in ascending order. I want to join tables LIKE C Table. Datas are not statical but in A and B the row counts are always equal. I’ve tried join statements but couldn’t find out. Thanks for your help. Answer If you’re using a database t…

SQL Update if parameter is not null or empty

I searched some ways to check if a SQL Server parameter is not null or empty but I’m not sure what’s the best way to use this when updating several columns: I had this code at first that was updating without checking for empty or Null values: Then I added an IF clause before updating, it is workin…

Trying to get a single record involving MAX(Date) and GROUP

I am trying to create a query in which I start with an item number and a customer and I have to determine the last selling price. The tables involved are SOP30200 = Sales Header SOP30300 = Sales Detail lines Given the following code and results: CODE: RESULTS: I am getting 2 records because the query is group…