I am still a rookie in SQL Server so I can’t quite figure this one out. I have a column that is filled with nvarchar values that I need to sum as durationOfWork, so it needs to do the sum function for time values. The columns are like this: I need to return for each Person the sum of their
Tag: sql-server
Creating a VIEW in SQL-Server
I’m trying to create a VIEW in my database, and it shows me “Incorrent syntax error” Am I doing something wrong? Answer Include GO between your Create View and Select query (or) view should be the only statement.
Create a column from 2 columns of 2 different tables
I have these 2 tables. What I want is that LineTotal is equal to Quantity*Price. I know that if I have Price in my OrderLine I could do LineTotal as ([quantity]*[price]). But that’s not what I want. I also read something about triggers but it wouldn’t work due to errors. What I tried I use SQL Ser…
Encoding special characters SQL to R and back
I have a problem passing data from R to SQL and then reading it back The original data is from some excel files and have the following word: Průmyslový Using latin1 for encoding depreciates the u within the word Prumyslový Using latin2 for encoding changes the accent of the u Prùmyslový Which encoding could i…
C# Get correct filpath string for SQL update Statement
I have created a small WinForms Application (.Net 4.8, SQL Server 18). Now I want to update a picture in my database. For that I have created this method: public void UpdateBild(string picturepath, …
Making groups of dates in SQL Server
I have a table contains ids and dates, I want to groups of dates for each id id date —————— 1 2019-01-01 2 2019-01-01 1 2019-01-02 2 2019-01-02 2 …
MSSQL, PDO, error when inserting XML string: General error: 102 Incorrect syntax near ‘<?xml version="1.0"
I am trying to insert XML string into a MSSQL database from PHP. I get: SQLSTATE[HY000]: General error: 102 Incorrect syntax near ‘ (a chunk of the xml follows). The prepared statement is: The $xml is a valid XML string. The same XML can be inserted OK using an identical statement in an SQL client app (…
INSERT INTO a table comparing two other tables using Not EXISTS
I have 3 tables: Server_db_relation DatabaseList DatabaseList_Archive The goal is to compare table Server_db_relation and DatabaseList based on the values in column ServerName and DatabaseName. If the values do not exists in the table Server_db_relation, but do exist in DatabaseList, then it should insert the…
SQL Select results based on two rows with different condition
I’m trying to fetch results where I want to check if two rows exist for a common ForeignKeyId and add a check on both rows. Suppose I have a table below – ‘Test1’ I want to fetch Result from Test2 table where Test1 should contain two rows where C = x and D <> NULL. So, select que…
Why aren’t these two attributes being filtered for?
I am writing an query that determines which courses were held in large lecture halls or auditorium type classrooms in Summer Quarter of 2016. When I execute it, it successfully filters for the Classroom Types of either Large Lecture or Audio but it doesn’t do the same for both Quarter and Year Sample Ou…