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 ...

0
votes
1answer
20 views

Calculation in Python or SQL?

I am a data analyst in finance world so we always need to do a lot of calculations in Excel. E.g. calculating Debt to Equity ratio, Sales % of Revenue, etc. In Excel is pretty easy to write formula ...
0
votes
3answers
26 views

For Each Display on Same Row SQL Server

I am trying to create a single row that includes an Assembly number and each component. I have a table called Assembly with a Unique Identifier that can be tied back to the inv_mast table as well as ...
0
votes
0answers
6 views

Call Rest TaxJar API from SQL Server Code

I'm working on calling TaxJar API from SQL Server, I saw some articles like: calling an api from sql server stored-procedure but unfirtunately I did know how to pass a Token value to the call Here ...
0
votes
0answers
18 views

How can I streamline the LookUp command below?

I have this: public HierarquiaDto Selecionar(int id) { var query = (from p in Context.PapelContratos join g in Context.GruposCargo on new { a=p.UsuarioGrupoCargo, b=p....
0
votes
3answers
40 views

SQL Server - Manipulate data and return new results

Is anyway to do something in SQL Server to manipulate data like manipulating arrays in any other programming language? I have one SQL query that returns 3 columns, "dt_ref" (date), "vlr_venda" (float)...
0
votes
1answer
22 views

SqlCommand that inserts data has no effect

I am trying to insert data into an existing Microsoft SQL Server (2014) table using VB.NET (2017). The code does not give me any errors, but it does not insert the record either. Right now I just want ...
1
vote
1answer
18 views

Table Lock SQL Server 2 sessions

i have a doubt about the table locks on sql server. For example, i have one table: RowN RowText ---------------- 1 Row1 2 Row2 3 Row3 In session 1 i need to update the table, ...
1
vote
0answers
17 views

Having xp_cmdshell error running DTSX file

To export some data to a text file, I used the wizard in SSMS 17.x to create an SSIS file, and it ran fine from the wizard, but it gives me an error when I try to execute it again using xp_cmdshell, ...
2
votes
7answers
44 views

Based on the value in one column change the value in another column across group

I am new to SQL Server, kindly help I have a table: Group id DEPT marks -------------------------------------- A 001 CS P A 002 ECE ...
0
votes
1answer
29 views

Multiple Values Parameter with Blank value in SQL Report Builder

I have a report which I need to be able to show all values for 1 required parameter or be able to type in a group of values in the optional parameter. First parameter (required): Manufacturer. ...
4
votes
3answers
48 views

Max() Over Partition By with date conditions

How do I get the following result in yellow? I want to find the maximum score over the previous year (excluding the current date) and partition by Name1 and Parent1 I've tried the following which ...
0
votes
1answer
23 views

Datetime conversion error in SSIS from US date format

I've got an issue with my SSIS dataflow. I'm extracting data from SalesForce Marketing Cloud. In one of the data extensions, there's a date field (in US format). The problem is that when the data is ...
-1
votes
0answers
10 views

ROLAP cube not working properly on knowage

I have to make a summary report to be displatyed on Knowage. The data I have is arranged like this: key month year warehouse attribute1 attribute2 value 1 1 2018 04 M DO ...
0
votes
1answer
7 views

Error on Loading Assembly in While Calling CLR Command in SQL Server

I'm receiving an error when trying to run a CLR object from SQL Server: An error occurred in the Microsoft .NET Framework while trying to load assembly id 65538... Do I need to enable some SQL ...
-1
votes
0answers
19 views

How to migrate a database that has a database master key and certificate for encryption [migrated]

Morning y'all. I'm a little stumped at this one. We have a database that we encrypted a column in a table. This is the master key that I created and the Certificate & Symmetric key. I need to ...
0
votes
0answers
10 views

Error while accessing varbinary(max) column from Oracle via the database link

I am trying to access SQL Server table from Oracle. I have installed Microsoft ODBC Driver 17 for SQL Server for RED HAT 7. Oracle connects to ODBC via Heterogeneous Services and I have created a ...
1
vote
2answers
50 views

SQL trouble! IF/CASE help required

So. Rearranging column format in a table to import into some software. There's a gender column in the previous DB that contains either M, F or U. The new software won't take U as a valid value, so I ...
0
votes
2answers
44 views

how to use group by function in the condition?

my inner query is working well but when i use group by function i am getting an error "Column 'b.id' is invalid in the select list because it is not contained in either an aggregate function or the ...
0
votes
1answer
36 views

need to get description of id from another table which are pipe separated

I have two tables table1 and table2 in table1 there is a column with name typeids in which ids are pipe separated ex: 2|3|4 --> these ids are the primary key in table2 table2 contains Id, ...
0
votes
3answers
27 views

Flag Records with highest version number within calculated field/calculated column as “true”, rest as false

Environment: MS SQL Server 2016. I have a table which contains (Jasper Reports) layout representations like this (only relevant fields shown for brevity): ID Name Key ...
0
votes
1answer
39 views

Stored procedure variable declarations

Just wondering what is the different between these two stored procedure declarations? CREATE PROCEDURE [dbo].[sp_name] @mainSorsTbl NVARCHAR(50), @mainSorsClmn NVARCHAR(MAX), @...
-4
votes
0answers
35 views

How find date or day difference in sql developer [duplicate]

How find date difference from following dates From date: 10/10/2000 , To date is today date Edit1 I use datediff key as below but it not worked and thrown error as invalid identifier
1
vote
0answers
19 views

dotnet core pod in Kubernetes connect to local SQL Server

I have a dotnet core pod in Kubernetes(minikube) that need to access to local SQL Server(Testing Server). it work in the container but when i put it in to pod. it can't fine sql server on my machine ...
0
votes
3answers
53 views

How to get one student from an SQL server DB using Java?

I've been trying to get this code to work for several hours now and need some help. I have a database that contains a table called "Students". I'm trying to write the below method that selects one ...
1
vote
1answer
51 views

How to tune a query with aggregations of tables over 15 million rows?

The execution time of this query is 3:29 minutes. How is it possible to reduce execution time of this query? The overall quantity of rows of FactLoad table is - 16 769 952. The overall quantity ...
0
votes
1answer
58 views

How to run a script on every insert

I've got a script (batch) and a table in a database (Microsoft sql server). I need them to work together. Script collects data from the database and uses it to call an external program which prints ...
0
votes
0answers
16 views

cannot read property 'Fname' of undefined

I am having trouble with posting new object to my DB... Every time I run it in Postman it returns an error: "cannot read property "Fname" of undefined." my code is like this : Connection: const _ =...
-1
votes
0answers
40 views

mssql_query(): Query failed turn txt file into value on mytable

so i want to check txt file from ftp and turn it into value on my table, there's nothing wrong with the txt file, i try to move it using php script it's work just fine. before try this, i using local ...
0
votes
1answer
43 views

SQL Server - Assign string from a list in equal manner

I have a list of 20 rows. Each row represents a list of tasks to be assigned. CREATE TABLE T (TASK_ID as STRING, ASSIGNER_ID as STRING). INSERT INTO T ('ABCD', NULL) INSERT INTO T ('BCDE', NULL) ...
2
votes
3answers
33 views

MS-SQL Pivot by two columns

I got the following data in an MS-SQL database Manufacturer|Model|Location|Inventory|Sold ------------|-----|--------|---------|----- Alpha |One |USA |3000 |123 Alpha |One |UK ...
0
votes
0answers
42 views

ndf file missing error shown while attaching the “mdf” file

There was a space issue for a database in our server. So we added a secondary file (ndf file) for that DB in another drive. (ndf file- 'c' drive, mdf,ldf file- 'e' drive). When we formatted the 'C' ...
0
votes
2answers
38 views

SQL - Rank monthly dataset high, medium, low

I have a table which includes the month, accountID and a set of application scores. I want to create a new column which either gives a 'high', 'medium' or 'low' for the top, middle and bottom 33% of ...
-1
votes
1answer
33 views

Show prompt from script in SQL Server

I'm trying to create a prompt window while running a SQL script to ask the person who run the script to enter a value that it will be assigned to a variable. How can I do it?
0
votes
0answers
14 views

How to create a table in SQL Server using RevoScaleR?

I'd like to able manage table on SQL Server via my R script and RevoScaleR library. I have Machine Learning Services installed on a local instance and Microsoft R Client as an interpreter for R. I ...
2
votes
0answers
19 views

Mapping CLR and SQL SERVER data types in UDF

I'm trying to create an UDF in C#. The C# function returns a string and I need to return it as CHAR(40) from the UDF. The c# function basically is public static string functionname() { return "...
0
votes
2answers
36 views

msg 8152 level 16 state 2 string or binary data would be truncated

Though title looks to be already answered please don't close the question, as I have searched but unable to find a solution. I am getting this error while executing a procedure Msg 8152, Level 16,...
-1
votes
5answers
29 views

Inner Join Invalid Object Name

Trying to do a simple inner join query but keep getting errors Select Alias from Db.SchmaName.Customers as Customer Select Alias from Db.SchmaName.Orders as Order Inner Join Order on Customer.Alias = ...
0
votes
0answers
20 views

SQL server procedure call with Spring boot jpa error: “Unable to extract OUT/INOUT parameter value”

We are trying to call a SQL server procedure call (3 parameters): ALTER PROCEDURE [mvm].[CHECK_USER] @IN_USER char(40), @IN_PASS char(40), @OUT_OK int output AS BEGIN TRY ... ... SET @...
-2
votes
0answers
25 views

How to avoid deadlock if the concurrent updates happen to a particular table from WEB API [on hold]

In my MVC Web API, for every 4 seconds I am getting 60 request from 60 devices now which is likely to scale up in the future as my device increases. The API is trying to update the data in the DB ...
-3
votes
0answers
43 views

SQL query to find employees who came to work all 7 days [on hold]

What is the query which would list employees that worked all 7 days of the week? Also if I want to check how to find the sum of sales for the past 7 days by that employee taking into account he came ...
-1
votes
2answers
39 views

SQL - Calculate Incentive using Frequency (Mode)

I’d like a SQL query to calculate the incentive column and based on the number of times a student was tutored in a month. If the student was tutored in AP Math twice in a month then, the Tutor gets $...
0
votes
1answer
14 views

not able to understand the execution of sortpath column in this SQL code

CREATE FUNCTION dbo.GetSubtree(@mgr AS INT, @maxlevels AS INT = NULL) RETURNS TABLE WITH SCHEMABINDING AS RETURN WITH EmpsCTE AS ( SELECT empid, CAST(NULL AS INT) AS mgrid, ...
0
votes
3answers
33 views

How to Select only Date Hour and Minutes from 2017-09-27 15:39:36.000 [duplicate]

I have a column in my table (having value- 2017-09-27 15:39:36.000). I want to select only Date, Hour, Minutes (i.e:- 2017-09-27 15:39) from column. Can anyone please tell me how to select.?
-1
votes
1answer
32 views

Spilit String in View or store Procedure In Sql Server 2014

I have one table in which i stored values with pipe shine("|").i want to create inner join in which i use value in table .. so how i firstly split value from table column and after split that value ...
1
vote
1answer
23 views

What does (Synchronized) after the database name mean in SSMS.

I just found a database at our client side, which contains (Synchronized) after the database name. I wanted to know, why this is happened?
0
votes
3answers
37 views

Find without using lead lag and CTE missing value from a list

If I am given a table like below. Now based on this we know that there is only 1 ID i.e. 4 which is missing. Is there a way to find this without using Lead, Lag, CTE and only using single select and ...
-1
votes
2answers
35 views

How to store T-SQL query output in new table with date of that day when query executed

I have to created a query which i have to run daily and attach the output in Excel. But what I want is to schedule the query to run on a daily basis and the output will get stored but I'm not able ...
0
votes
3answers
25 views

find total of positive and negative numbers separately inline, using only select and case statement

I have a question. If I am given a table with positive and negative numbers and I want to find total of all positives and total of all negatives separately and display it in one line. I was able to ...
0
votes
2answers
32 views

Select every 2nd, 4th row and so on from same column based on specific material

In 1 packing got 2 material and item sequence is 00010 and 00020. What I need is if I input material from item sequence 00010 in where statement which is 'CB016' , I can list out all the item sequence ...
0
votes
1answer
28 views

SQL get start of shift and end of shift based off consecutive tasks

I am in need of getting the true length of a shift based off the tasks in the shift. There is no record of start and end time of a shift only start and end of each task. I have been trying to get the ...