Can’t store decimal value in SQL. Want to store like decimal(2,8) Like 32.12345678 [Column(TypeName = “decimal(2,8)”)] [Display(Name = “Latitude”)] public decimal Latitude { get; set;…
Tag: sql-server
SQL where clause to check if all selected column value is in a subquery select
Does the select concept below can be translated into an sql select? select S_ID from table1 where S_Type = TYPE and all S_ID in (select S_ID from table2) The concept of this is like below: item1, …
Insert stored procedure results into temp table
I have a stored procedure that returns this result: The way I call the stored procedure is: I want to store these results into a temp table so I used insert into like this: But I get an error like this: INSERT EXEC failed because the stored procedure altered the schema of the target table. Answer Hard to say …
I’m going to get the ten day sales report and i want to return 0 if there is not record for each day
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[Sp_Rsv_DailyContractReport] @ContractDate datetime =null, @RegisterUsersId varchar(32) = null AS Select …
Getting the primacy function for an emolyee
I have this following query to get the primacy for an employee : My output is like below : What I want is to get primacy (primary,secondary, tertiary) to each function like below : The function having the minimal sumOrder will be the primary function and so on. Answer You can use a ROW_NUMBER() ordered by the…
Update column with below query?
How do I write this query to update a column based on the case statement? Answer As commented, you query looks pretty good, apart from these: the ORDER BY clause does not make sense; an UPDATE query does not return any record, so ordering is out of scope for the same reason, you don’t have to alias the …
Query works on SQLite but fails on SQL Server
The following query works for me in SQLite. But in SQL Server, it gives me an error. Invalid column name ‘VehId’. And the editor puts a red squiggly line under the last VehId (but not the first). As you might expect, Vehicles.Id is the primary key. I’m trying to find all foreign keys in Tran…
Merge groups of consecutive rows in T-SQL and sum values from each group
Updated 10/08/2019: @Gordon Linoff: I have tried to applied your solution but I realized that is not working as expected. I have added an example with expected result with comments here (https://dbfiddle.uk/?rdbms=sqlserver_2017&fiddle=1b486476d6aeab25997f25e66ee455e9) and I would be grateful if you could…
Select max data in interval of 1 hour within a time range in sql
I have some difficulties with sql server to select max value in a column in interval of 1 hour within a time range. My table look like this: +———-+——-+———————+ | Id | …
Select query in SQL SERVER need to support
I have 3 tables like that: – Employee_Table (Employee_Number, Employee_Name, Department_Number) With Employee_Number is PRIMARY KEY, Department_Number is FOREIGN KEY; – Employee_Skill_Table (…