I am trying to compare records between two different SQL tables/databases in my Node project and have to do some transformation in order to compare the values. In one database (MariaDB) the value is of type INT, and looks like this: 516542 In the other (SQL Server) database the value I need to match to is of …
Tag: sql-server
SQL Server export image to hardisc by iterating through fieldnames
We receive 10 images in varchar format through a mobile device app which are stored in one record of a table. The fields where the images are imported are named ImportPictureData, ImportPictureData2,… more of the importfields could be added. To make the export flexible, I read the fieldnames in a table …
The INSERT statement conflicted with the FOREIGN KEY constraint “FK__…”
I’m a very new beginner with SQL and I’m battling a problem I can’t seem to find the answer to. I’ve found similar questions here on Stack Overflow but I still can’t see what I’m supposed to change in my code to make it work. I’ve got 4 tables in a relation as follows…
Compare two similar columns in different tables and result in separate output
I have a two tables with same column names. I would like to compare two columns . For eg:- Table 1 has server and IP address like Table 2:- Desired output:- Answer It looks like a FULL JOIN is what you need here. Sample data Query Result
Split Row and Paste to Different Tables Based on Column
I have a table like this. Table is populated each time an order is complete. One order can have one or many compartments. Please help write an SQL script that takes the above and splits it into two new tables like so: Table 1 Table 2 I’ve tried using the DISTINCT command as suggested; Which returns the …
Creating extra columns based on condition (Case When Sum)
I have survey table where someone is asked roughly 5 questions. 4 of those questions are the same questions, but the options to their answers are different since they were to understand their purchase. Here are the questions: The goal is to create four extra columns based on their answer and they will be assi…
Join two columns as a date in sql
I am currently working with a report through Microsoft Query and I ran into this problem where I need to calculate the total amount of money for the past year. The table looks like this: How would you calculate the total amount from 02-2019 to 02-2020 for the item number 12345? Answer Assuming that you are ru…
Can’t insert multiple rows in SQL Server Manager Express 2005
I have a Table HORAS_X with ID_HORA(int), ID_ZONA(int), DESCRIPCION(nvarchar), COMIDA(bit), META(int), NUMERO(int). I can insert a single row like: INSERT INTO HORA_X (ID_HORA,ID_ZONA,…
Calculate time difference in days:hours:min:sec format
I have this query: Wherein I have to calculate the time difference in Days:Hours:min:sec format Output: My question is, how to calculate the sum of the 2 rows? My desired output is: Answer Find the difference in second & do aggregation :
Can’t add row in sql server because of date
I have a web application where I need to insert data in my SQL Server table, the problem is that I have this error in my Apache log: General error: 241 Conversion failed when converting date and/or time from character string. I have the same error when I try directly inside ms sql server. There is my php code…