Skip to content
Advertisement

Tag: sql-server

SQL ‘insert into select’ into existing table

I wrote a simple insert into statement: I got this error: Cannot insert the value NULL into column ‘Worker_ID’, table ‘Worker’; column does not allow nulls. INSERT fails (By the way Worker.WorkingPlace is a nullable column) I’m very confused, because I’m just inserting data into the ‘WorkingPlace’ column, aren’t I? Answer This will create as many new rows in table

Increment column value based on condition

I’d like to increment the values in the column nc by 1 each time the value in 10minDiff changes. In the Table below, the values in nc should read 2 from row 1246 onwards and 3 the next time 10minDiff changes from 10. Answer Since data is not textual.I am writing UnTested query.

Trigger causing Maximum trigger nesting level exceeded

I have created a new trigger that updates my [Purchase Table] if the number of delivered items equals the ordered quantity, but every time it’s run I get the following error. ODBC–update on a linked table ‘dbo_Purchase Table’ failed. Maximum stored procedure, function, trigger or view nesting level exceeded (limit 32). (#217) This is the trigger that I have created:

SQL pivot and group by month

I’m trying to get the sum of production per month and pivot the month row to columns. Could you please tell me what is wrong with this code?’ Answer There were several items wrong in your query. Columns need aliases and your max() within the PIVOT was referencing an invalid column name

Simplifying SELECT statement

so I have a statement I believe should work… However it feels pretty suboptimal and I can’t for the life of me figure out how to optimise it. I have the following tables: Transactions [Id] is PRIMARY KEY IDENTITY [Hash] has a UNIQUE constraint [BlockNumber] has an Index Transfers [Id] is PRIMARY KEY IDENTITY [TransactionId] is a Foreign Key referencing

Returning non-overlapping records within a date range

I have the following data. I have looked over a lot of threads about overlapping and non-overlapping dates but none seemed to help me. From this table with a SQL query I want to return the first record out of overlapping dates or basically I have been struggling a lot with this query and was wondering if this is actually

Java to SQL Server using Windows Authentication

I am trying to connect to a remote SQL Server DB from a Java application without success. I am able to successfully connect to that SQL Server instance from a SQL client for Mac called SQLPro for MSSQL However, if I try to connect from the Java application using those same credentials, I always get a Login failed error, this

Advertisement