Skip to content

Tag: sql-server

Create view with JSON array based on many to many table

I have a typical table with users. I have also a many to many table where first column is UserId and second BusinessId. I want to create a view with users where their businessId will be as json. I tried something like this: But in view I get this: Id BusinessEntityIds 1 [{“BusinessId”:1925},{&#822…

Renumbering A Column Based On Other Columns

This table contains Purchase Orders which can have multiple lines per order. Right now the table appears like this. Purchase_OrderNumber Account_Number Line_Number 174558 0000448 1 174558 0000448 2 175812 295812 1 175812 295812 1 175812 295812 2 175812 295812 545 175812 295812 26686 175812 295812 53481 175813…

Finding orders placed between two times gives zero result

I’m not sure what’s happening here. I’m trying to select the orders that were placed between 4PM and 4AM, so from 1600 to 0400. The date does not matter, just the time. This is what I’ve tried so far. Here is the code for the table: I selected using several ways: I keep getting nothing…

Show a string that contains two numbers in SQL [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last year. Improve this question I’m studying SQL just recently and I have encountered a problem. I want to show the Addr…

Error converting data type varchar to bigint: INSERT INTO SELECT

I keep getting this error when trying to execute a stored procedure and am not sure why: Msg 8114: Error converting data type varchar to bigint. Please see my SQL query below: I believe the error is emerging because of the UniqueStudentID I have tried using CAST & CONVERT around the SELECT line but still …