I’m having bit of issue with joins here: Tasking is to select Item code, Item name and Concat together that items prerequisites item code and name together. I can get the select to work to show item …
Tag: sql-server
Pivot One Column and Retain SUM,AVG,COUNT Columns
Let’s say I have a table PRODUCT like this. ProductName Amount ——————— Soap 1.10 Toothbrush 2.00 Towel 3.00 Soap 3.00 Then I get their sum, average …
SQL Server : concatenate and where clause
I am trying to concatenate three columns from two tables Customer and Invoice, create a new column and find the new_id member whose name begins from ‘Astridgruber’ in SQl Server. The below is causing …
The Delete code doesnt work after it updates a column
When I send data to the procedure which contains the ResStatus as C it updates the ResMaster’s ResStatus as X After it updates the column, I want to delete a record from 2 tables they are- Folio,ResRoomAllocation. I have done the coding but it doesn’t work it only updates the ResStatus as X What&#…
How to use scalar variable in XML Path query SQL?
I want to pass table name into into a scalar variable @Table_Name as a string. But I am getting error as: Must declare the table variable @Table_Name. How to achieve the same? Below is my code snippet: Answer So I created a temporary table using the input provided by the user and used that temp table in the q…
Exception when starting Snapshot Agent when setting up database replication
I am trying to set up replication between databases. I followed this tutorials: https://docs.microsoft.com/en-us/sql/relational-databases/replication/tutorial-preparing-the-server-for-replication?view=sql-server-ver15 and after: https://docs.microsoft.com/en-us/sql/relational-databases/replication/tutorial-re…
How to add if/else condition in SQL Server query?
I have to parse a json like this: [ { “id”: 2, “name”: “John”, “age”: 25 }, { “id”: 5, “name”: “Jane”, “age”: 18 } ] I have to parse it and check if the name already exists in userInfo table….
Python SQL: Error reading and executing SQL file
I’m trying to red and execute a SQL file in Python using sqlalchemy. Should be simple, right? I get this error Why am I getting this error? I’m not sure if this is a file encoding error or a SQLAlchemy error. Ideally, this should be simple. EDIT: This code works fine, assuming the table temp exist…
How to group by row in diferents columns
I have this table in SQL, I need to group it by the report name and I need to split the price_bucket column and the count_sales column in diferents rows. I think that I should use the PIVOT funtion in SQL Server and an intermediate table. How should I do it? This is what the final table should look like:
Eliminate the rows that becomes same after swapping as in original table in SQL Server
I have a table which contains data as follows: I want a table which do not have Mumbai—>Jaipur as it is present already before being swapped. Similarly, Lucknow—>Indore is not required. All other entries must come as it is which is there in the existing table. Can any body help. Note: Table …