Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

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
16 views

SQL Sysadmin is unable to create database

I am trying to install a MSI that is supposed to create database and install all the applications that go with it. Every time when it comes to the create database line the MSI is failing complaining ...
1
vote
0answers
25 views

Developing SQL queries safely in Java

How do I develop multiple SQL conditions, and subsequently incorporate these conditions into a query along with the order by clause safely ? I'm trying to write SQL statements with potentially ...
0
votes
2answers
17 views

Demoting Server Login/DB User Permissions to SELECT, View Definitions, Exec Stored Procs and use functions

I am working though a change in permissions so that when in production, a user may only view definitions, select tables, execute stored procedures, and use functions. Essentially any modifications to ...
-1
votes
0answers
18 views

How to loop through all tables and fields in each table to get percentage of missing values

I am trying to, using SSIS, obtain a table to get the percentage of missing values of every field in every table of a SQL Server database. Ideally I would like to create a new table in another ...
0
votes
1answer
15 views

Re-writing Common Table Expression (CTE) to Subquery to make a compatable PowerBI DirectQuery

I have the following MS SQL Server query that when run in PowerBI throws an error as CTEs are not supported by DirectQuery. ;WITH Daily_Report_CTE AS ( SELECT WazeUpdateTime_PST, Name, Length, ...
0
votes
0answers
18 views

Conectar Sql Server ao php 7.3.7 no Windows

Google Translate english version I can't connect PHP 7.3.7 to SQL Server on Windows. Already downloaded the drivers, put the DLLs inside C:\MAMP\bin\php\php7.3.7 and set up php.ini calling the ...
0
votes
1answer
12 views

Connect Power BI with Azure SQL Database Server Using AAD Credentials

I am trying to connect Power BI to an Azure SQL Database Server. I am able to connect to the database using SSMS and have added my IP to the firewall settings of the server. However, every time I try ...
0
votes
0answers
9 views

Server list always blank when adding a new connection

Every time I try to connect to a database using for example an OLE DB Source, I get a empty list in Server name (even after hitting the refresh button) I have been able to connect to a server anyway ...
0
votes
1answer
26 views

Website in web hosting service and DB in local server [on hold]

I have my webapp (ASP.NET) and database (SQL SERVER) on my own server. I plan on moving the website to a web hosting service like GoDaddy but I need to keep the database on my server. Is there a way ...
-1
votes
1answer
25 views

Select records in one table where a field in this table is included in another table

Basically I have two tables. Table1 has millions of rows. Table2 has very few rows. Table1 has field1 which is a product ID (not unique). Table2 has field2 which is just a list of productID's that ...
-2
votes
1answer
19 views

Add unique id to groups of ordered transactions

I currently have a table with transactions that are sequentially ordered for each group like so: | transaction_no | value | |----------------|-------| | 1 | 8 | | 2 | ...
-2
votes
1answer
33 views

T-SQL grouping by either of two columns

I have a table where I hold chat history as follows: Id From To Text Hour ================================================= 1 A B Msg_A_B1 00:...
0
votes
0answers
12 views

Change SID of USER DBO in SQL Azure Database

I am not able to create a USER with name PUBLISH_ADMIN in a user Database. In Master Database, LOGIN PUBLISH_ADMIN has SID = 0x010600000000006400000000000000002532749BDD5C974C9BA8EF44CFA5. In User ...
0
votes
0answers
24 views

Attach .mdf / .ldf files in SQL database from shared location in a local network

Actually, I want to install a database from installer on remote machine SQL Server from server machine.
0
votes
0answers
21 views

SQL Server ignoring collation from database

So for tests I am creating temporary docker SQL Server. Unfortunately my production database uses some non standard collation. So for tests I am creating test database with my custom collation. In ...
-1
votes
0answers
22 views

Save selected multiple options from dropdown in database

I have a dynamic dropdown list in programmed with html connected with my SQL Server database. Now I made a dropdown with the possibility to choose multiple options. But when I select multiple options ...
0
votes
1answer
25 views

Sum of other ID's based on date in SQL CTE

My sample CTE which is coming from multiple sources and drawing data from: with sample_cte as (ae.spvr as col1, ae.startDate as start_dt, ae.END_DT as end_dt, ROUND(ae.Scre,2,1) as Scre , from ...
0
votes
1answer
25 views

Convert Int into time

I'm trying to convert a field into the correct format that I would like. The field is suppose to keep track of time, but it does it in military time and it is set as an Int. Can anyone help me in ...
0
votes
0answers
31 views

Count of one if there are more than one entry in the result?

DECLARE @StartDate AS SMALLDATETIME DECLARE @EndDate AS SMALLDATETIME DECLARE @BranchNum AS INT SET @StartDate = '2019-10-22' SET @EndDate = '2019-10-23' set @BranchNum = '4' SELECT DISTINCT s....
0
votes
0answers
40 views

SQL Function not providing expected result

I have created a SQL function to return results based on two filter conditions. In TVF function I just have one select query where the results will be returned in Table format. When I run the select ...
0
votes
0answers
23 views

bcp for Linux fails when importing very small data value, such as “-1.28212683287E-308”

Using the Linux version of the bcp utility to import data into SQL Server (SQL Server 2016). And, the import fails on data row with an extremely small data value in one of the columns, such as "-1....
0
votes
0answers
14 views

How To Connect SQL Server to Android Studio

How can I connect my Android studio project to SQL database Should I do something in the database to make it local so I can connect it to the database
0
votes
1answer
24 views

Create a single table by importing all CSV files in a folder?

I have around 30-40 CSV files in a folder. For example, suppose folder 'Florida' has customer information from different cities of state Florida. each CSV file has customer information of one city. ...
0
votes
0answers
10 views

Varchar(MAX) field being truncated in SSAS cube

In SQL Server 2016 I have a relational dimension table that has a field set to varchar(MAX). Some of the data in that field is over 2k characters. When this data is processed by SSAS the field is ...
1
vote
1answer
35 views

Combine tables with different number of columns

I need to UNION two tables that have mostly the same columns, but one has several additional columns. I'm aware that you can do a SELECT with placeholders for those additional columns, but I'm working ...
0
votes
0answers
35 views

Block parent from deletion when child is available in SQL Server

For a database I want to have some blocking being done, when the parent has a relation to a child, where the child has value. When the parent doesn't have a link, it should be able to delete this. But ...
0
votes
0answers
21 views

Hash Match in Query Execution Plan

I am working with a query where the execution plan shows a Hash Match join in multiple places. I understand the hash Match joins are costly and should be avoided. However as you can see in this case ...
2
votes
2answers
44 views

Faster way compare changes between SQL sub-queries?

I need to check for the change in the color of cats between two dates. I have the query below: WITH cats_prior AS (SELECT IDTAG,Color FROM CATS WHERE APPOINTMENT = '06/30/2019'), cats_now AS (...
0
votes
0answers
32 views

Normalize a set of numbers (remove nulls, consecutive duplicates, shift remaining values to the left)

I have a data row with 5 numeric columns. I want to: Remove Zero/NULL values Remove consecutive duplicates After removal of Nulls / Duplicates, I want to shift the remaining values to the left - I ...
0
votes
1answer
27 views

Update a table using a case expression when the results are NULL?

I have created a helper temp table which stores the results of a query. Sometimes this query returns 1, 2, or 3 rows. If there is data in the table, I need to use it to update a different table to ...
1
vote
0answers
25 views

How can I access deleted parent data in a cascade delete?

I have three tables, lets call them GrandParent, Parent, and Child. Parent has a foreign key to GrandParent's Primary key set up with a Cascade Delete. Similarly, Child has a foreign key to Parent's ...
0
votes
0answers
19 views

Execute SQL command in R and return MESSAGES only

I would like to execute SQL command from R and take the printed output and execute it in postgres. The actual query I am using includes multiple if-condition that if they are true, it will print a ...
1
vote
1answer
21 views

How to shrink log file in SQL Server after unknown period of not being backed up?

I recently took over management of a database that has been in use for 2-3 years, and it had no transaction log maintenance plan in place. The DB file is 8 GB, but the transaction log file is a ...
0
votes
2answers
64 views

SQL SERVER - Complicated SQL query 2

I have two tables document and documentd the first one contains the numbers of the documents 'doc_num' primary key, document types 'doc_type' (FACA, BLCO, BLCM, BLCK .....) and the document date '...
0
votes
1answer
19 views

Select all columns for users in multiple groups within a case [duplicate]

I'm trying to return all columns within a UserGroup table for users in multiple groups per case. TABLE structure: Case Group LastName FirstName A 1 James Mason B 2 John ...
0
votes
0answers
16 views

How to check NULL value for geometry data type in Where clause in SQL Server

I am working in a app to store polygon data in a SQL Server database. I already have a table where I add a column ALTER TABLE SpatialTable ADD PolygonGeometry geometry Null ALTER TABLE SpatialTable ...
-2
votes
1answer
20 views

Get highest value using partition in SQL [duplicate]

I am trying to get the highest spend and show the vendor that has the highest spend in the category . Here is what i have: Vendor Category Spend 3M cat1 200 XX cat6 ...
-1
votes
0answers
8 views

Problem with import DBF files to SQL Server

I have this problem: I am trying to import .dbf files into SQL Server 2017, but I get an error all the time. I want to know how I can import .dbf files into SQL Server. This is the error I get: The ...
-4
votes
0answers
27 views

Show column with yesterday's sales data [on hold]

enter image description hereI'm new here and I need help. I have a table X on sql server and I need to create another table Y, where table Y receives the sales data table X and a new column will be ...
-1
votes
0answers
20 views

Problems with site loading and sql connections when disabling old SSL on Server 2008 R2

We have some Server 2008 R2 machines (I know, we are going to migrate to new servers soon hopefully) that we are trying to disable old SSL protocols and ciphers as per a security recommendation, and I'...
0
votes
2answers
43 views

context.SaveChanges() doing something else besides expected

I started working on a project in my work that doesn't have any documentation, and the person who developed the project in the first place isn't avalaible anymore. There is this piece of code for ...
0
votes
0answers
11 views

Otcopus deploy - SQL - Deploy DACPAC “Could not connect to database server.”

Trying out Octopus deploy for the first time. Trying to deploy a dacpac to a machine and it keeps on failing. I keep on getting the following error: Exception calling "Extract" with "4" argument(s):...
0
votes
0answers
23 views

Can I get a percentile in MS SQL Server Management Studio 17

I need to show the 50th percentile in SSMS I am using TSQL and the percentile_cont but it isn't recognised? Is there another way? I am querying a table like this: HerdID Event 100 01/01/2009 ...
0
votes
0answers
16 views

SQL Server 2017 - Import Flat File Date Formatting Issues

I am using the Import Flat File tool to bring in .csv files into SQL Server Management 2017. Here is the source data file showing two columns with dates in the correct date format. Original Data ...
0
votes
2answers
33 views

SQL Server - Creating Grouped Columns

I am needing to create some columns where I sum values to create a "grouped" value data set. Here is the data I have and below is what I need as an output. Any help is much appreciated! Current Data ...
-2
votes
1answer
27 views

Next row value in next column in SQL Server

How to display next row value in the current row as next column in SQL Server? Mast table ID Name --------- 1 XYZ 2 abc 3 MNO Detail table ID Date ------------- 1 1/1/2019 1 1/...
0
votes
1answer
42 views

proc sql in SAS run 37 times slower than sql in SQL Server

I have this proc sql step in SAS that takes about 1.7sec to complete, however, if i run this SQL via SQL server or any sql client, it takes only 0.04 sec to complete. From the sastrace log i found ...
0
votes
6answers
46 views

SQL ERROR : Msg 102, Level 15, State 1, Line 4 Incorrect syntax near ','

I am trying to run this code: SELECT FIN AS 'LIN', CUSIP, Borrower_Name, Alias, DS_Maturity, Spread, Facility, Facility_Size, Log_date FROM [Main].[...
0
votes
0answers
30 views

Sql Query from a data table and output in a matrix within a Loop

I am working with some traffic data in Visual Basic 2015 and Microsoft SQL Server Data Tools 14.0.60519.0. My Data Table name Veh_Record. Here is sample data Veh_No Lane Position Speed ...
0
votes
2answers
23 views

How to get the count of account numbers my query is returning, using count(case when)?

SELECT DISTINCT s.branch AS [Branch] , s.CREATEDBYUSER AS [Teller Number] , acct.accountnumber AS [Account Number] , COUNT( DISTINCT CASE WHEN s.CLOSEDATE is null AND s....