Tag: sql

Sql to repeat rows for all the months based on Startdate and EndDate

I have a table ‘Quota’ Which has Quota Amount for every team with Start Date and End Date of quota’s. Here is the sample quota Table ‘StartDate’ is Start date of quota, ‘StartMonthYear’ is month+Year of startdate, ‘EndDate’ is end date of quota , ‘QuotaAmount’ is quota between startdate and EndDate and TeamName is Team […]

Powershell script executed from SQL Server – stops working if put to background job

I execute a PowerShell script to create folders and inbox-rules in Office365. The script works fine when called from SQL Server. But if I put the code in function and calls with Start-Job then it stops working from SQL Server – but it will work if executed from local machine(?) I really want code to […]

MS SQL – How to have dynamic query of OPENQUERY in sql view

I have to create a view querying AD group using OpenQuery. I have gone through this question but this doesn’t work in case of an SQL view since we can’t have local variables in a view. Please see my below view query: SELECT emp.PersonnelID FROM OPENQUERY( MyLinkerServer, ‘SELECT sAMAccountName FROM ”LDAP://DC=**domain**,DC=organisation,DC=com” WHERE objectCategory = ”Person” […]

Get Work week or Number of Weeks T-SQL

How can I get the exact week number if my date range is from Friday to Thursday nextweek? I used this code datepart(wk,t.date) as workweek but the week number is different, maybe because the format that I want to get is from Friday to Thursday nextweek. I hope somebody can answer. TIA!

How to combine 4 or more tables with different joins, avoiding some minor duplication

I’m trying to build a query for combining 4 of my tables into a pre-created table, my query was running smoothly for the first 3 tables. Here is my query (*query and tables are already simplified) INSERT INTO goaltable SELECT b.employeeID, b.employeeName, a.grupID, a.shiftID, b.scheduleDate, b.scheduleWorkTime, c.hierarchyID, c.companyID, c.city1, c.phone, d.machineID, d.tapDate, e.tapTime, e.tapID FROM […]

Does SSAS faster if using InMemory Table SQL?

I want to change my tables into InMemory table, and also I created SSAS from that table. wheather OLAP could be faster if I change into InMemory tables ? Please advice. I am concern about my memory. I am using SQL 2014 and SSAS Tabular Thanks

SQL server IF EXISTS vs IF Condition Perfomance

I have a Table Business (contains more than 10,000 rows) with a bit column ISBILLINGBUSINESS. In a Stored procedure I have to check whether ISBILLINGBUSINESS is True of False for a record. I can compare with two methods. (1) IF EXISTS (SELECT id FROM BUSINESS WHERE ID = 5404 AND ISBILLINGBUSINESS = 1) select ‘Billing […]

Synchronize SQL CE with a SQL Server using the Sync Framework 2.1 DbSyncException

I try to make a application to that supports offline use. I thought Microsoft Sync frame work would be a good idea. but I try to make a small demo with only one table in my SQL server database and my SQL CE database: CREATE TABLE [Products] ( [ID] int IDENTITY (1,1) NOT NULL , […]

Change date format according to existing record

I want to change the date format from 2016-04-04T00:00:00 to dd/mm/yyyy. [Target_Hire_Date] is the column that I wanted to update. My code can shows the result but have an error. Can you please help me? Thank you so much! select convert(nvarchar(10),CONVERT(date,[Target_Hire_Date],103),103) from [master].[dbo].[1A] Error: Result:

how to insert in different table using merge query

Here i am trying to add bulk data using Store Procedure but the problem is i dont want to Update Data i want to Insert Data into temp table when condition Matched Alter PROCEDURE [dbo].[Update_Customers] @typeMembership aspnet_Membership_type READONLY AS BEGIN SET NOCOUNT ON; MERGE INTO aspnet_Membership c1 USING @typeMembership c2 ON c1.EmployeeCode=c2.EmployeeCode WHEN MATCHED THEN […]

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