Skip to content

Tag: sql-server

Get all payment transactions recursively using SQL

I have a series of records. Based on the data below, how to get all transaction (XZ) for specific customer invoice (XR)? Legend Example 1 Condition Desired output Explanation above: There is Customer invoice (XR) with the amount of 36,247.62. There is payment recorded (XZ) with the value of 4.76 for document …

Incorrect syntax near format in BULK INSERT?

I’m trying to figure out why the BULK INSERT command I’m using isn’t recognizing the FORMAT and FIELDQUOTE options used in the command. For some reason, I’m getting the error: Msg 102, Level 15, State 1, Line 6 Incorrect syntax near ‘FORMAT’. Addition: FORMAT shows up in pi…

How to find these master records whose totals are not accurate

I have two tables (master-details relationship). The master table has a column (called total) recording the number of details records for the same master record. Having this column is for the performance reason). Here are the table specs: Because deletion of details records, the total in the master table may …

Using ‘LIKE’ and ‘REGEXP’ in a SQL query

I’m trying to use some regex on an expression where I have two conditions on the WHERE clause. The pattern I want to capture is 106 followed by any digit followed by a digit that must be either 3 or 4, i.e. 106[0-9][3-4] First, I tried this: This produced an error as below and it would be good to know

SAS pass through query to SQL Server

I have some troubles with passing through query to SQL Server. OS is RedHat 6. In SAS Enterprise Guide I try to execute this code: but I faced with error: ERROR: CLI execute error: [SAS][ODBC SQL Server Wire Protocol driver][Microsoft SQL Server]INSERT failed because the following SET options have incorrect s…

Update statement SQL with CTE

I have a common table expression that I am using trying to use as an update statement. The only reason for the CTE is so I can use a where clause to filter by CredCount. I would like to use that where clause to update only records that match in this case CredCount of 2. However, I am having trouble

Executing a SQL query with C#

I would like to add some information to my database. I searched for some tutorials, but none of them work. NonQuery can do what he needs to do, because the messagebox returns “Success” (1). But it does not update my database. If I put the same query to “Add New Query”, directly to my d…