Skip to content
Advertisement

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 ‘OPTION’. Answer

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 that supports row_number()

Text was truncated or one or more characters had no match in the target code page including the primary key in an unpivot

I’m trying to import a flat file into an oledb target sql server database. here’s the field that’s giving me trouble: here are the properties of that flat file connection, specifically the field: here’s the error message: [Source – 18942979103_txt [424]] Error: Data conversion failed. The data conversion for column “recipient-name” returned status value 4 and status text “Text was

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 working this way

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 grouped by UNITPRCE

How to fill missing dates and values in partitioned data?

How to fill missing dates and values in partitioned data? I’m having a lot of trouble Googling this as most of the posts seem to feature Oracle databases, and I’m working with Microsoft SQL Server. I have the following hypothetical table: I want to fill in the dates in between the gaps and copy over the value from the most

Advertisement