Skip to content

Tag: sql-server

Issue connecting to SQL Server via Python pyodbc

I have an ongoing issue that I just can’t solve. It concerns a Python script that loads data into a SQL server database. When I run it from my local machine it works fine, however when I run the same script from a server I get the following error: conn = pyodbc.connect(r’Driver={SQL Server};&#8217…

Extract number before and after character

I need to extract a certain number from my ‘TblA’ from column ‘Input’ in sql. I have the following example input and desired output 1 and 2. Input Desired Output 1 Desired Output 2 20 x 88 nc. 20 88 100 x 300 nc 100 300 200x 88 nc. 200 88 5x 300 nc 5 300 ol (200x 88nc.) 200

SQL Server: update rows that take part in grouping

I’m using SQL Server 2017 (v14.0). I have two tables with one-to-many relationship. I need to group the rows in the “Orders” table and by this info create the row in the “Transactions” table, then I need set the relationship – for a created transaction I need set the Transa…

Issue with SQL Server select statement

I need help with a select statement that I’m currently struggling with. The scenario is this: select * from mytable WHERE isActive=1 and if only id is provided, select everything where the id=@id if firstname and lastname is provided, then select everything where firstname=@firstname and lastname=@lastn…