Failed to connect to database server. How do I connect to a database that is not on my localhost using powershell and integrated security?

Background to my question At any moment I am expecting the security people in black suits and black sun glasses to come and take me away because of all my sql server login attempts… I used and adapted iris classon’s example to connect to a database via Powershell. The adapted code uses Integrated Security=True” $dataSource […]

Trigger SQL insert and update

I have two table INVENTORY and INPUT create table INPUT( PRODUCTID nvarchar(10), QUANTUMINPUT int ) create table INVENTORY( PRODUCTID nvarchar(10), QUANTUM int, QUANTUMINPUT int, LASTQUANTUM int ) How to create SQL trigger on SQL when insert column QUANTUMINPUT, table INVENTORY change over?

Group continuous date ranges from same table SQL Server

I have following data: CREATE TABLE #Rate ( RateId Bigint ,PropertyId Bigint ,StartDate DATETIME ,EndDate DATETIME ) INSERT INTO #Rate VALUES (100,1000,’2015-01-01′,’2010-01-11′) INSERT INTO #Rate VALUES (100,1000,’2015-01-12′,’2015-02-02′) INSERT INTO #Rate VALUES (100,1000,’2015-02-11′,’2015-02-25′) INSERT INTO #Rate VALUES (100,1002,’2015-01-01′,’2010-01-11′) INSERT INTO #Rate VALUES (100,1002,’2015-01-12′,’2015-02-02′) INSERT INTO #Rate VALUES (101,1000,’2015-02-11′,’2015-02-25′) INSERT INTO #Rate VALUES (101,1000,’2015-01-01′,’2010-01-11′) INSERT INTO #Rate […]

Bookmark look up confusion

New versions of SQL Management Studio render a bookmark lookup as in the picture below. That makes me think the operation is independent from Index Seek (and can run in parallel?). Shouldn’t Index Seek finish first? Its output (physical row IDs) is the input for Key Lookup, right?

Model in django to store working hours of an employee for specific year, month and week

I am creating a Django application for online attendance system that has to store weekly working hours of employees for few years(5 or 6) I want to create a table, that has employeeid, year, month, week and hours(example 4hrs for week1 in Jan 2015 for employee with id 200) I tried creating models(year, month, week, […]

Insert Stored Procedure for One to many relationship SQL

Asp.net Form Student Name Student Address English (marks) Maths (marks) Science (marks) For the above form I have created the following table structure Create Table Student ( sId int primary key identity(100,1), sName varchar(50), sAddress varchar(100) ) Create Table Subjects ( subId int primary key, subName varchar(100) ) Create Table Marks ( mid int primary […]

MSSQL Binary PDF with PHP

I’ve been pulling my hair out for a couple of days about the issue i’m having. Trying to read a PDF that is stored as binary blob data in a SQL database (not mysql) varbinary field. If I use a program like Navicat, and save the raw blob data directly as a PDF, the file […]

Right sql solution?

I have a following question with respect to which of the below sql is right for the types of question. QUESTION 1: I have two tables: TABLE1 and TABLE2. TABLE1 has 1 million records and contains the variables ID and AGE. AGE is a bucketed variable to the nearest 10-years (e.g. 10, 20, 30, 40…). […]

Get the difference between top and last value in result set

My table looks something like deal_id test_value run_date 820117648 1.2 2014-03-31 820117648 1.33 2014-04-30 820117648 1.33 2014-05-30 820117648 1.26 2014-06-30 820117648 1.11 2014-07-31 820117648 0.58 2014-09-30 820117648 1.64 2014-10-31 820117648 0.64 2014-11-28 820117648 3.65 2014-12-31 820117648 3.8 2015-03-11 820117649 0.64 2014-09-31 820117649 0.23 2014-10-31 820117649 0.64 2014-11-28 820117649 3.65 2014-12-31 820117649 3.8 2015-03-11 SELECT deal_id,test_value,run_date […]

SQL Server Filter items for a user

I have a order table and an orderItem table. I would like to get orders for a user which are placed less than or equal to 2 mins between them and who have the same products(number of products must match as well) associated to them. Based on this question I’m able to sucessfully filter out […]

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