Questions tagged [sql-server]

Microsoft SQL Server is a relational database management system (RDBMS). Use this tag for all SQL Server editions including Compact, Express, Azure, Fast-track, APS (formerly PDW) and Azure SQL DW. Do not use this tag for other types of DBMS (MySQL, PostgreSQL, Oracle etc.). Do not use this tag for issues on software and mobile development, unless it is directly related to the database.

Filter by
Sorted by
Tagged with
0
votes
0answers
11 views

How to save an ID from a table to another table in ASP.NET MVC?

I have a problem regarding passing 'slot_id'(auto-inrement primarykey) from 'tb_parkingslots' to 'tb_freeslot' and save it. Here's my code: controller: // GET: Admin/Create public ...
0
votes
0answers
9 views

How to count users logged with duration per date and 15 min interval

I want to determine the connected users by date and 15 min intervals, based on login and logout Date Time columns and sum the duration (in seconds) of that event depending on the login time and actual ...
-1
votes
0answers
27 views

Could I get support to make this function properly?

I'm trying to access database values with a button whose purpose is to make calculations on the input from a given textbox(textbox1) by using the input and value from database to do arithmetic ...
0
votes
1answer
32 views

Identical tables, different performance in SQL server query

We've been having problems with performance for a SQL server at work. Queries that run well on one server run awfully on another (e.g. 20 minutes vs 16 hours, same box specs, seemingly same setup). ...
-2
votes
1answer
28 views

Entity Framework does not see data in database until a DBSet is converted to a list

I define the index API of a controller as the following: [HttpGet] public IEnumerable<Blog> GetDatas() { return _context.Blogs; } This always returns empty even-thought the database ...
0
votes
1answer
34 views

How to call id of data which is inserted into database?

T an entity.I use singleton pattern for database context. private DbSet<T> _objectSet; public Repository() { _objectSet = db.Set<T>(); } public T Find(...
0
votes
4answers
38 views

How to join two columns from same table and format the new Column in SQL

I am very new to SQL and trying to join two columns from the same table and format the result. The code I have so far is: Select LastName + FirstName as FullName from Customers order by FullName ...
-1
votes
1answer
25 views

Entity framework does not detect an existing navigation property and attempts to re-add it

I define my model and relation similar to the blob and post example on as on this page. When I have an existing blog and want to add new posts to it, entity framework tries to add a new blog with ...
0
votes
1answer
16 views

How to run sql based on filter condition in Tableau report

I have this data output in Sql server for a table to which i have extracted in tableau using extract data :- Requirement is that when user select source_nbr and stock_date which is under filter ...
0
votes
1answer
13 views

NodeJs sequelize mssql connection not working

I'm getting an error while connecting to SQL Server through sequelize to next computer in network using IP address in host : const Sequelize = require('sequelize'); const sequelize = new Sequelize('...
0
votes
0answers
18 views

ODBC Query Works in MS Access & Timeouts in SQL Server

We have a pass-through query in MS Access that we need to convert to SQL Server. The query in MS Access is using a 32-bit ODBC DSN to connect to a Redshift database. The query is complex (e.g. has ...
0
votes
2answers
27 views

Sum number by previous row number using select statement

Suppose there are two column name SrNo and Salary i need a third column whose result would show like as below:- SrNo - Salary - Result 1 - 1000 - 1000 2 - 150 - 1150 3 - 200 - 1350 4 ...
0
votes
0answers
16 views

Nodejs & TypeORM Transaction Confusion

I have confusion and I couldn't resolve it from the TypeORM documents. Here is my function that is used as request handler and it is using transaction taken from getManager() static makeTransaction ...
0
votes
3answers
35 views

SQL Server shift based weekday, weekend, public holiday and time of the day

Need help with creating a view for an existing table where there is a datetime column and it has to be divided into shifts based on the day of the week, hour of the day. For example during the ...
1
vote
1answer
23 views

How can I Create Multiple DATEDIFF Columns?

I would like to calculate the DATEDIFF between each of the different ranges represented by the NewValue column below. Id CreatedDate NewValue Count 0 ABC 2018-11-28 09:16:15 ...
0
votes
2answers
37 views

Is there any way to exec a stored procedure for all selected data rows?

I'm setting up a storekeeping program in which I have 2 tables, one for products and another for materials. In the products table, each product has several materials. Is there any way to select these ...
0
votes
1answer
14 views

How to retrieve the exact response of insert/update statement of Query Explorer SQL Server through python using pymssql

Insert/Update statements always provide updated rows and inserted columns in SQL Server Query Explorer Response Window. Want to retrieve the same results from Python 3.x. I have millions of records ...
-1
votes
1answer
11 views

How query avoid locking on table write continuously in a transaction takes a few times?

I have a business job which writes into a table every 1 minute. I also have a client query result from the job. Sometimes query slow when does in job time. How query avoid locking on table write ...
0
votes
1answer
45 views

Is sql views the proper solution

I have a table named 'Customers' which has all the information about users with different types (user, drivers, admins) and I cannot separate this table right now because it's working on production ...
0
votes
2answers
24 views

Merge records that have at least one non-null element in a specific column - SQL Server

My data looks like as following: id ProteinID Gene_Name Class 10008 P08648 ITGA5 extracellular 10009 P08648 ITGA5 extracellular 10011 P08473 MME 10 NULL ...
0
votes
0answers
13 views

Deadlocking in Concurrently Executed Nested Stored Procedures

I have a stored procedure that calls child stored procedures to parse JSON that is coming in from the client. The problem is that the JSON parsing mechanism is bottle-necking the application because ...
0
votes
1answer
22 views

How to shuffle rows in random order in SQL and save results in new table?

So I have a table called Customers id | name ------------ 1 Tom 2 Bob 3 Sam ...
-1
votes
1answer
36 views

How can I add a column with its values from one table into another table in SQL?

I know this question has been probably asked a million times, but I can't seem to find what I do. I have this table called Customer that only has 1 attribute (id) id ---- 1 ...
1
vote
0answers
16 views

Configuration issue for web app on iis express

I have a problem in connecting local DB in my web app to run it on iis express. I developed the application on VS2017 (my os is win10) and to run it on iis I installed sql server 2017 express (until ...
0
votes
1answer
30 views

Connect to SQL SERVER from google sheets

I want to connect to a SQL SERVER on my machine through google sheets. I have port forwarded, set up appropriate firewalls and started the server browser and all of these are working. Here is the jdbc ...
2
votes
1answer
44 views

Perform a single query based on comparison of sum of child collections

I have the following classes public class Order { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public DateTime Date {...
-3
votes
0answers
25 views

Error converting data type varchar to int SP [on hold]

Alter PROCEDURE updateRecord_CaseDetails --SP Created for Updation of two tables @CaseID int, @YearID int, @CategoryID int, @SnoGaapNo nvarchar(50), @SnoYearCode nvarchar(50), @...
-1
votes
3answers
51 views

Sum value in periodic time

I want sum work time of machine that save in table but I need sum in periodic time for example between 2019.07.10 and 2018.04.05 every 7 days sum values.
0
votes
1answer
29 views

Failed to Make Modulo11 Function on SQL Server

Create a function CheckModulo11, that checks if a given accountNr is valid number use this function in a check clause in a table with a column that represents an accountNr. (You need to create a table ...
0
votes
4answers
56 views

Get the rows of my output sorted in ascending order from this table?

I am using SQL Server 2014 and I have the following table (t1) which contains around 5,000 rows. Here is an extract of t1: n1 n2 n3 n4 n5 n6 Type 6 15 10 11 22 25 C1 2 ...
-2
votes
3answers
40 views

Obtain the top-grossing product for each individual vendor

How do I obtain the top-grossing product for each individual vendor? I came up with this so far and can't seem to proceed. select vendor.Vendor_Name, Product.category AS Product , SUM(SalesFacts....
-3
votes
1answer
25 views

teble month update uing procedure [on hold]

I have a table ERM_DEV_TBL, it has two columb TERMINAL_MONTH_STATUS and CREATED_DATE . if CTEATED_DATE month is eqal to system month then TERMINAL_MONTH_STATUS is active other wise inactive, please ...
-1
votes
1answer
49 views

DateTime Parameters in stored procedure

I have a stored procedure insert into to the table in SQL Server: CREATE PROCEDURE ThemHocSinh @TenHS NVARCHAR(255), @NgaySinh DATETIME, @TenChaMe NVARCHAR(255), @SDTChaMe VARCHAR(16),...
0
votes
3answers
29 views

Top N records in SQL Server with parameter shows error

I'm writing a stored procedure to return N records based on input parameter passing: ALTER PROCEDURE [dbo].[StaffQueue] @Staff_Dept VARCHAR(100), @numberOfStaffs INT AS BEGIN DECLARE @SQL ...
0
votes
1answer
26 views

SQL Server - Understanding stored procedure call

I try to understand an application based on a SQL Server database. For a certain functionality, it executes a stored procedure using the following query: declare @p3 dbo.IdsTableType insert into @p3 ...
0
votes
1answer
22 views

How can I validate an account with a stored procedure that uses hash encryption, C#, ASP.NET MVC, Entity Framework

So basically I have a stored procedure which is able to decrypt the password and return 1 if user exists. Here is the code: CREATE PROCEDURE [dbo].[ValidateAccount] @Username VARCHAR(50), ...
0
votes
2answers
24 views

SQL Server 2008 R2 : Conversion failed when converting date and/or time from character string

I'm getting the following error Conversion failed when converting date and/or time from character string I can't get it to run properly please help me, here is my code (don't shame my loop i just ...
0
votes
3answers
33 views

Stored procedure in SQL Server does not return a result set when called by java

I have the following stored procedure and my goal is to return a result set from it, using the query "select * from #justTmp" create procedure spAddPerson @ID int, @Name nvarchar(50) as begin ...
1
vote
0answers
18 views

PHP/SQL: How to setup LDAP at Windows Server 2016 [on hold]

Currently, I can connect from PHP Page to Windows AD. This means, I create a simple login page, fill in username and password, and login successful. I locate my PHP code at XAMPP. Now, I ...
0
votes
2answers
35 views

How to use the result of a SELECT in Table A, to limit the SELECT of Table B using IN

I tried to use the result of a SELECT inside of the IN operator of another SELECT but it takes 15 minutes, but if I run the queries(Query1 and Query 2 below) separate I have results in 2 minutes ...
0
votes
1answer
18 views

Python how do I auto generate a non existent primary key every time I insert new data

I have this SQL query, but I have to change the id everytime I insert new data, because It's a primary key. How can I make it add a new nonused primary key value everytime I insert? I am using ...
-1
votes
0answers
19 views

Compare data from a database with data in a ComboBox

I want to compare data contained in a table of a sql-server database with a comboBox in my windows forms c# app. I'm running Visual Studio 2019 Enterprise, SQL-Server 2017 Developer.
0
votes
0answers
22 views

How to pass multiple parameters to a python SQL insert statement including a where clause

I am trying to pass information into a python for loop from a python dataframe to update rows in Microsoft SQL server to update a table. I have a Pandas data frame value in row['id'] which should ...
0
votes
0answers
8 views

How to set up Azure Sync to other databases to delete records that are no longer in the source

I'm very new to Azure so please don't judge me too harshly. So, in this project, I've got SQL Server on-premises 'production' database which is the 'master' data. I'm writing a small .NET ...
0
votes
1answer
22 views

Need where clause to find difference between 'today' and date_column > 10 days and < 15 days

Hello I am trying to figure out a where clause to find difference between 'today' and date_column > 10 days and < 15 days. So far all I can think of is creating a variable for each? But I am not ...
0
votes
1answer
23 views

Operand Error Message when Summing columns

I have the following statement in my query and I am receiving an error: SUM(isnull((T1.RecvQty),0)) '3rd Party Received Qty', SUM(isnull((T0.Quantity-T0.Quantout),0)) 'SAP Onhand', SUM(isnull((...
2
votes
1answer
39 views

Join Two Tables Then Transpose Rows From One Table As Column Names

I'm trying to join two tables ColumnNames ID |Name |Type |Status | ----------------------------------------------------- 1 |Fullname |varchar |Active 2 |Email |varchar |Active ...
1
vote
2answers
43 views

Insert stored procedure output data into a column of a table

I created a stored procedure in SQL Server. The stored procedure subtracts two columns in the same table. How do I insert this stored procedure data into a Inventory column of the dbo.Store table? The ...
0
votes
1answer
27 views

Mainframe job dependency in SQL Server job

I have a SQL Server job which has to check if the mainframe DB2 job is complete (for the data) and then run the SSIS packages. I plan to add step 1 to check if the job is complete. I cannot add the ...
0
votes
3answers
28 views

Best way to loop through values and pass each value to query in SQL Server procedure

I have a select query which returns a list of table names. I want to pass each table name to a drop table query so that I can drop the table. I can use temp tables. Is this the best way to do this? Is ...