Tag: database

Automated task using pymssql runs fine during the day- but not at night; why?

I have a web scraping job that needs to be executed each evening. Our company has a virtual machine with the “Windows Task Manager” application installed. So, I created a new task (i.e., an entry in task manager) to run every evening at 3 a.m. Initially, the process did exactly as expected: it fetched the […]

Composite or Unique Primary Key repititons

So i am working on creating a db, whereby i have the option of tableA or tableB. Please note that in the current concept InstanceID, slabID, and ChangeID are repeated in almost every table because only when combined with a table specific NO or key, can they uniquely identify each row. My concern is whether […]

SQL – Left Join according to Time

Facts There are two tables MachineStatus and MachineShift. They are linking to each other by FK: machineName. Output Required TO get Machine Status Duration according to shifts Please find attached image to clarify the output. Problem I am unable to achieve old dates status, what will be a condition to meet the criteria in Left […]

MSSQL Parameterized Queries

Over MySQLi I would do: $sql = $connect->prepare(“INSERT INTO Table (a, b) VALUES (?, ?)”); $sql->bind_param(‘ss’, $a, $b); $sql->execute(); $sql->close(); Now the question is, how I do the same thing with mssql for a SQL Server instead of MySQL? I know I could do: $sql = sqlsrv_query($connect, “INSERT INTO Table (a, b) VALUES (?, ?)”, […]

Update a table column with data from another table

I’ve searched everywhere but I can’t seem to make it work or understand why the join is behaving like this and right now I am not able to ask anyone so just trying my luck here. So here’s the issue: tblOldAccess User Srv Perm LogDtTm ———————————————— TestNm1 Srv1 Perm1 2016-09-20 00:00:00.000 TestNm1 Srv2 Perm2 2016-05-30 […]

TSQL JOIN two tables in one big table

I need to JOIN table A and table B in one big table. In each table I have (id,brand,power). Table A id | brand | power ——————- 1 | BMW | 500 2 | SKODA | 220 3 |PORSCHE| 450 Table B id | brand | power ——————- 1 | BMW| 500 2 | SKODA| […]

SQL Server: join 3 tables and sum() one column from each table

I have 3 tables ———–table1————- id code name quantity 1 001 car1 1 2 002 car2 2 3 003 car3 3 ———–table2————- id code name quantity 1 001 car1 1 2 002 car2 2 ———–table3————- id code name quantity 1 001 car1 1 2 002 car2 2 3 004 car4 4 I want to join […]

Performance of TOP(1) select on multiple tables

I’m having a performance problem with a TOP(1) (or EXISTS) select statement on a join of 2 tables. I’m using SQL Server 2008 R2. I have 2 tables: CREATE TABLE Records( Id PRIMARY KEY INT NOT NULL, User INT NOT NULL, RecordType INT NOT NULL) CREATE TABLE Values( Id PRIMARY KEY BIGINT NOT NULL, RecordId […]

Azure database firewall issues

I just tried to create a database on my SQL server and managed to do it. But I get the following error: The server you specified xxx.database.windows.net does not exist in any subscription in xxx@xxx.com. Either you have signed in with an incorrect account or your server was removed from subscription(s) in this account. Please […]

Visual Studio database project how to perform an alter table on a referenced dacpac

I’m sure this should be simple but I cant work it out. Project setup Visual Studio database project with references to master, msdb and another dacpac. It is the additional dacpac that is of interest. For various reasons I will not go into here, I cannot make changes to the database represented by the dacpac. […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.