The script works fine when it has 2 rows. Stop reading from 3. This is MSSQL Server 2005. Try anyway without any result. There is no error message. But if I have more than 10 rows, it doesn’t affect the row that should affect. Answer Given the new information in your comment you should simplify this to an update statement.
Tag: sql-server
SQL select based on column value
We have a DB table that contains company job codes like so: The ‘***’ in company represents an enterprise level job code which can be overwritten at the employer level (DEU, DEC). I need a select statement that returns rows with the following conditions: If there are no company specific Codes (e.g., EW20) then return the enterprise level row (e.g.,
SQL Server query JSONobject to get aggregated values
I have a JSON object stored in SQL Server, in a nvarchar(max) column. The JSON looks like this: { “data”: [{ “RespID”: 3512, “ObsPriceValue”: 2.34 }, { “RespID”: 4904, …
How to join 3 tables and get the field with 2 different conditions?
I have 3 tables: Students, Courses (important field Points), StudentCourses (important field Grade). The exam is passed if Grade is greater than or equal to 70, so student will receive Points. If Grade is less than 70, student will not receive Points. Student is graduated if sum of his credits is greater than 10. I need to select StudentName, sum
T-SQL query to show only differences between rows
I have a query that outputs the following dataset: I need to find a way to find instance where the unitid column and the stat column do not match. An example would be if unitid = 2, CleanCode = 10 …
How to add next and subtract preceding row in SQL Server based on condition
I am trying to calculate the cumulative sum based on TranslationType column in SQL Server. Sample data: Id TransactionType Value ————————- 1 Receipt 10 2 Issue …
Get Data from a single table to an empty table
I am quite new to SQL. I couldn’t find solution and I want your expertise here. I have one table “boxes” and contains the color and type and condition. I want to get the number of types per color …
find total unique number of hackers who made at least one submission every day and find the hacker_id who made maximum number of submissions each day
Find total number of unique hackers who made at least submission each day (starting on the first day of the contest), and find the hacker_id and name of the hacker who made maximum number of submissions each day. If more than one such hacker has a maximum number of submissions, print the lowest hacker_id. The query should print this information
How to include a variable in a block WITH..AS?
I have this query to retrieve for each employee, his main and secondary function: Output : I want to integrate my previous query in the source query of my dimension : My expected output will be (for employee having EmployeeId=1) : Answer When you say: How to include a variable in a block are you asking how can you use
Join two sys.columns tables from different servers
I have two similar dbs on two different servers. I’m trying to join their sys.columns tables, but I don’t understand why this wouldn’t work SELECT * FROM server1.db1.sys.columns t …