Stored Procedure result into temp table in Azure Data Warehouse

In Azure Data Warehouse, i have a Stored Procedure which will return the result of SELECT command. How to push the Stored Procedure result into temp table? I tried the below query and it is returning an error message. CREATE TABLE #temp (name varchar(255), created_date datetime) GO INSERT INTO #temp EXEC sp_testproc Output message: Msg […]

Separating multiple SQL Server statements running in batch

I’m trying to send a batch of CREATE TRIGGER statements as a string to be processed when migrating my DB CREATE TRIGGER [dbo].[triggerBar] ON [dbo].[tableBar] INSTEAD OF UPDATE,INSERT AS BEGIN SET NOCOUNT ON — Trigger body here.. END; CREATE TRIGGER [dbo].[triggerFoo] ON [dbo].[tableFoo] INSTEAD OF UPDATE,INSERT AS BEGIN SET NOCOUNT ON — Trigger body here.. […]

I want to find difference between two presenters salary

I have the following table Presenters(pre_name, salary) Suppose I have the following values Values ( ‘A’, 8 ) ( ‘B’, 6 ) ( ‘C’, 7 ) I want the following results Pre-name pre-name salary-diff A B 2 A C 1 B C -1

How to check a value in dataset is empty or not?

I have a fileupload option in my project. It inclueds a query which returns a dataset. It works fine. But now i want to check whether the returning dataset is is empty or the same value i passed as a parameter to the query. Here is my back end code. .cs code if ((FileUpload1.HasFile))//&& (ext […]

How to reduce execution time of SQL Select Query

TitemName and TshotName is the problem here SELECT DISTINCT tJobs.* , tCustomer.Name AS Customer_name , (SELECT tEmployee.First + ‘ ‘ + tEmployee.Last FROM tEmployee WHERE tEmployee.EmployeeID = tJobs.AccountExecutiveID) AS AccountExecutive, (SELECT tEmployee.First + ‘ ‘ + tEmployee.Last FROM tEmployee WHERE tEmployee.EmployeeID = tJobs.AccountManagerID) AS AccountManager, dbo.RetrunUserFavourite(tJobs.JobNumber, 33369, ‘Employee’) AS Favorites, (SELECT COUNT(*) FROM tShots WHERE […]

Query tables using lookup table

I’m tryng to query tables using a lookup table, this because the tables have a differente name/code for a same value. For example, Employee and Production tables have same field of Site, but they have it named differently.So I want the field Person from Employee and Percent from Production, this joining being done through the […]

Rollback and Raiseerror, which first?

I sometimes perform the following set of statement in the following order: Raiseerror(…) Rollback; but I am wondering if it cause the same effect as below: Rollback; Raiseerror(…) I understand they are the same and cause the same effect. Doing Rollback first, after execution it continues executing on the following line, that is, Raiseerrror(…) Could […]

Full outer join with multiple columns

I have two tables: one containing data with end of year information and another with end of quarter information for multiple products. I want to join them so that each row has information for one product per day: product_id | annual or quarter date | annual_info | quarterly_info A full outer join like: select, […]

MSSQL count total time between many entries and exitis

I would like to ask you for help on how to count the total time spent between many entries and exits. The example table looks as follows (for one user): Date_Time | Event | User ————————|————–|——— 2016-08-01 09:19:11.000 | Reader entry | John D. 2016-08-01 10:00:56.997 | Reader exit | John D. 2016-08-01 10:09:24.000 | […]

Show only one record, if value same in another column SQL

I have a table with 5 columns like this: | ID | NAME | PO_NUMBER | DATE | STATS | | 1 | Jhon | 160101-001 | 2016-01-01 | 7 | | 2 | Jhon | 160101-002 | 2016-01-01 | 7 | | 3 | Jhon | 160102-001 | 2016-01-02 | 7 | | 4 […]

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