The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

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.

0
votes
1answer
18 views

Self join to get friends of friend in SQL

I have a friends table as below +------+--------+ | Name | Friend | +------+--------+ | A | B | | B | C | | D | B | | D | C | | A | E | | E | Z | +-----...
0
votes
0answers
4 views

Allocate more resources for Full-Text search index population service

We have a table with Full Text Search index enabled. And Change tracking is set to 'Automatic' The problem we have is that we generate content for this table faster than indexing is happening for ...
0
votes
0answers
23 views

How do i backup one specific database from my database server

Hi i want to backup one database of my database server using a bat and a sql file. REM Run TSQL Script to backup databases sqlcmd -S HEIST-BERG-SL\SQLEXPRESS -E -Q "C:\SALTO\Automatic Backups\scripts\...
-1
votes
6answers
46 views

Category and Sub category in one column in sql

How we can show category and sub category in one column in sql. Both columns are present in same table. Example: Table category sub category Values Bird parrot 5 Bird ...
1
vote
5answers
49 views

SQL GROUP BY with null values

i have these data in an MSSQL 2012r2 table: id data1 amount ------------------ 10 abc 95.00 10 NULL 312.00 20 def 16.00 30 gqi 32.00 Expected query result: id data1 ...
0
votes
0answers
9 views

How to use Full-text-search with custom file types?

I am using Sql server 2017 and I want to use full-text-search on my own file type. I created several files with my own extension. Then I created the appropriate tables and threw these files into it. I ...
0
votes
0answers
21 views

How to concat record data into one string in SQL? [duplicate]

I'm just creating a store procedure to simply concat several records into one string in Microsoft SQL Server. here the sample table look's like: Table Product: ProductID Name -------------------...
0
votes
0answers
18 views

Create dynamic PIVOT table with several aggregated functions in SQL Server

I am trying to create a pivot table. The source one is following: +--------+------------+-----------+--------+--------+------------+ | UserId | LastName | FirstName | Param1 | Param2 | Date | ...
0
votes
0answers
29 views

A network-related or instance-specific error occurred while establishing a connection to SQL Server? [duplicate]

I am using Visual Studio 2008 for a legacy project. The project is not getting connected to the instance of a database on my local PC. web.config: <connectionStrings> <add name="...
0
votes
1answer
18 views

How to delete record from selected row datagridview and update database after deleted?

I'm trying to build a winform with a Delete button and DataGridView. What I want is to click a row in DatagridView and then click Delete button. The selected row will be removed from DataGridView and ...
3
votes
1answer
36 views

Database constraint over multiple tables

Say I have the following tables: CREATE TABLE [Weeks] ( [Id] INT NOT NULL IDENTITY, CONSTRAINT [PK_Weeks] PRIMARY KEY ([Id]) ); CREATE TABLE [Days] ( [Id] INT NOT NULL IDENTITY, [...
0
votes
3answers
35 views

Infer value of one column based on other column values in SQL Server

If running speed of a day is > 0, its status is true. In case of no data for a particular day, infer last status code (another column in table) value recorded and if the value is zero then mark run ...
0
votes
0answers
17 views

How to fix random “The wait operation timed out” with EF 6 and SQL Server AWS RDS

PROBLEM: Since a DB migration, I have many intermittent exception from SQL timeout. All what I now after my 2 months of investigation: All my .NET C# apps using RF 6 are impacted Whatever time in ...
0
votes
0answers
28 views

Multiply hours difference between startdate = 00:00:00 and enddate HH:mm:ss on Float value

I need calculate power usage, and it is calculated as the average power per hour multiplied by the number of hours worked per day. Can i multiply value on hours datediff between two datetime, start ...
0
votes
0answers
12 views

Select first next subsequent change in the previous row in a new column

I have a table with a unique index on Contracts of Customers that live in Houses. I want to know the days per house how long it takes when someone moves out (Contract end date) and a new contracts ...
0
votes
1answer
60 views

How to do alpha numeric sort

Following are my data Transmitter #1 Transmitter #10 Transmitter #11 Transmitter #2 Transmitter #3 Transmitter #4 Transmitter #5 Transmitter #6 Transmitter #7 Transmitter #8 Transmitter #9 Room 1 ...
1
vote
0answers
17 views

How to INSERT the value of a combo box in SQL Server with an Integer value using Netbeans [duplicate]

I'm currently building a System using Java lang. Unfortunately, (new at java) i got stuck on inserting the value of jComboBox on the database which has an integer data type. Have tried using this ...
0
votes
1answer
35 views

.Net/SQL Insert and Select on datetime2 not matching

I have a piece of code that inserts a data sample ([id + datetime2] +...) in sqlAzure database. Later for each call I do a select to know if the primaryKey is already in DB [id + datetime2] so I ...
0
votes
1answer
36 views

Query to split words on varchar and check if each word exists in a table

I am working in building a query that is going to split a string into words and check each word if it exists in the DB, if it exists I need to update the counter of the word and if it doesn't I need ...
1
vote
0answers
33 views

How to bulk insert data into a table when the primary ID is set with a sequence

I'm trying to use SqlBulkCopy to insert a number of rows into a table where the Id column is set with a sequence. The sequence and table look something like: CREATE SEQUENCE [dbo].[MyTableId] AS [...
-1
votes
0answers
32 views

Time between status change SQL

I have a log table where data is stored. There are three different statuses (Start, Success, Failed). The data comes from an ETL process. When an SSIS package starts running it logs a start. When the ...
0
votes
0answers
26 views

How to execute same job in a same time concurrently

I have already created job and i need to execute job in about 15 time within 10 times nearly. created job spend 4 min finish that steps. how to do this?
0
votes
1answer
27 views

select rows with events related with another events in the same query column

I need to select rows with EventTypeID = 19 which does not have related EventtypeID = 21 LoggedOn exactly 4 minutes earlier for the same EmployeeID. Here's the query bellow and some raw output: ...
0
votes
0answers
13 views

Cross-Location Look up database

The cross-Location Look up database cannot be opened. The error message is [Microsoft][ODBC SQL Server Driver] [DBMSLPCN]SSL Security error
0
votes
1answer
13 views

EF6 Schema compare between dataase and sql-file?

I use EF6 model-first approach to design MS SQL database by using "Generate database from model..." in Visual Studio. This generates a sql-file with all drop and create statements. At some productive ...
0
votes
0answers
30 views

How to properly use DateTimeOffset when trying to compare datetimes with the local offsets

SOMETABLE [Last_Check_In_Time] [datetimeoffset](7) NULL, [Last_MSG_Sent_Time] [datetimeoffset](7) NULL, [Last_MSG_Received_Time] [datetimeoffset](7) NULL, [User_Time_Zone] [nvarchar](...
0
votes
1answer
39 views

How to write a polling service in SQL Server?

I have to two tables employee and department. Employee Id, Name, JoiningDate, SpecialRegistrationDone, DepartmentId Department DepartmentId, Name There is a special department with DepartmentId ...
0
votes
2answers
25 views

How to Union the title in sql query with data?

I want the title for the SQL query.How Can I generate it? In the following code ContractID is int, Contract Number is nvarchar and ClientContractNumber is nvarchar. I have tried the following Code ...
1
vote
0answers
26 views

Convert ToUrlString Extension to T-SQL

I need to create a report of all our items with a URL link to the webpage that is generated for each item. The website uses the .ToUrlString extension (http://www.extensionmethod.net/1935/csharp/...
0
votes
1answer
16 views

OLEDB using 32bit instead of 64bit

I need to import some datafrom a Excel worksheet but the OleDbConnection is using the 32bit version, so it cant find the provider. I already imported using the 64bit wizzard and everything is working ...
0
votes
1answer
37 views

How do I write a SqlCommand that selects top 3 most repeated values in a column in ASP.NET

I am trying to retrieve the most sold items from a date picker "from-to" format. I have this SqlCommand I am trying to run but its not working. SqlCommand cmd = new SqlCommand("SELECT TOP 3 Sold ...
1
vote
1answer
14 views

SSIS cannot connect to SSMS using SQL Server Authentication

I'm trying to set up a connection to SSMS from SSIS project I'm working on with SQL Server Authentication. I set up a cube_user login and gave it permission to my database transactions Here is how I ...
0
votes
0answers
17 views

How to save the content in p tag to SQL Server?

I want to store the content inside the <p> tag into database. Is it possible? <p align="center"> <button type="submit" class="btn btn-success" id="btnCheckin" onclick="getLocation()"&...
0
votes
0answers
15 views

Import Json with Thai language

I want to import json file to sql server 2017 but some field is Thai language can't show Thai language How to do... DECLARE @farmer VARCHAR(MAX) SELECT @farmer = BulkColumn FROM OPENROWSET(BULK'G:\...
0
votes
0answers
25 views

WCF Seralization issue with EF

I am getting this weird exception in WCF Service Exception thrown: 'System.Runtime.Serialization.SerializationException' in System.Runtime.Serialization.dll Here is the given schema of the DB: Here ...
0
votes
0answers
11 views

Re-store SQL jobs from saved “create job code” in DR scenario?

As DR and good practice, we [Backup] everything We backup our SQL logins, jobs, linked server, system settings into a separate database so that we can restore it in DR scenario The job was exported ...
0
votes
0answers
33 views

Reverse Engineering Salted SHA1 Password Logic in SQL

I recently took over as an application administrator for an in-house developed app, an app which came with no documentation and no support. I found out my predecessor gave the exact same initial ...
1
vote
1answer
25 views

Need a script/cursor that runs at server to look at temp on all the databases hosted

I have configured CMS configured that list all my servers. I want to be able to run a script at the server to look at temp tables that exist on all the databases hosted on a server. I want to drop all ...
0
votes
0answers
27 views

C# Entity Framework 6 project builds but no data shown from database

New to Entity Framework but I'm trying to bring my employer into the 20th century. Here is the problem. We have a third party product that we use for the majority of our organization's activities. ...
0
votes
3answers
41 views

Converting nvarchar to datetime and back into database

I was handed a table where the Date column was loaded as nvarchar(50). I more or less figured out converting it into datetime. select convert(datetime, Date_Time_In, 101) FROM [DB].[dbo].[table] ...
0
votes
2answers
34 views

Sum two rows from Same column within same table

I have a column called price. I have two rows in that column. How do is subtract row2-row1 Table = table1 It has columns name, price Price column has values as Name price pen 123.24 ...
1
vote
1answer
12 views

Querying attributes from a XML column

I need to get the Name field's value from all of the Output\OutputFields\OutputField in the SPEC column. create table T ( ID uniqueidentifier default newid(), SPEC xml ); insert into T (...
-2
votes
2answers
28 views

Exporting distinct names based on same Id

I have one table myTable with columns name, Id and code. Sample data in myTable is as below. ------------------------- | name | Id | code | ------------------------- | XYZ | A12 | F1 | |...
0
votes
1answer
11 views

Getting Dynamics CRM Meta Data

I'm using Microsoft Dynamics CRM 2016 On Premise, I'm trying to get some specific meta data, basically get through SQL Server the field physical, field display name and the field value from a given ...
0
votes
0answers
33 views

Entities Enums or ID list [on hold]

There is a game server with a SQL database. There are many tables with entities (resources, builds, unist, ets). Each has its own ID in the table. The task was to develop an API in the form of a ...
-1
votes
2answers
22 views

List databases under instances not connected to

How do I find out what databases are listed under an instance that I'm not connected to? (this is homework...sort of) I found out how to locate other instances through Admin Tools, then Services. ...
0
votes
0answers
36 views

How To: Auto Name Column when building a table

I seen some answers that seemed close to my solution but they used code and I'd prefer to do this in SQL if I can. I know roughly what's needed but I have never seen anyone do this before in SQL. I'm ...
0
votes
1answer
20 views

Querying web services JSON from SQL server

I'm following this tutorial. I created GetWebService stored procedure from tutorial, and example from there works fine DECLARE @response NVARCHAR(MAX) EXECUTE dbo.GetWebService 'http://headers....
0
votes
0answers
21 views

Can't connect to SQL Server DB from Pyodbc

I am having a difficult time trying to connect to a SQL Server DB on Linux, using pyodbc. I have a ODCINI file entry created. I started with this: import pyodbc conn = pyodbc.connect('DSN=DSN;...
0
votes
1answer
33 views

React to pull SQL data from server

I figured out how to make a request to SQL server and post as JSON on the server side. I'm wondering how I can pull that data into the react side. Server.js: let pullTable = require('./actions/...