11,265 questions
1
vote
1
answer
132
views
Most efficient identification and concise expression of a set of disjoint elements
I am attempting to determine how to most efficiently identify the sets consisting of the least number of terms for a group of disjoint sets.
I have a set of Boxes (B##) and Cartons (S##) which are ...
-4
votes
1
answer
90
views
Using join is causing my record to be shown two times
I am using left join in my query, and for some reason it's showing the same record two times. if I remove this join (left JOIN tbl_item AS i ON sd.ItemIDsale = i.itemid) then the result will be not ...
0
votes
0
answers
126
views
Get a list of all attributes/hierarchies (both enabled and disabled) of all dimensions of a cube
I need a way to obtain a list of all attributes / hierarchies of all dimensions of a given cube. In the Internet I have found that following SSAS DMV for doing a similar job:
SELECT [CATALOG_NAME] as [...
0
votes
0
answers
132
views
SQL Server Connection Timeout post-login phase Docker .NET 8 OpenSSL3.0 already config for TLSv1
I need to connect to a "very" old SQL Server running on v10.50.2550.0 (Win NT 6.1 (7601)) (SQL Server 2008 R2).
Yes I know it should be updated but there is no way for this atm!
The Docker ...
1
vote
1
answer
132
views
Laravel - Implicit conversion from data type nvarchar to varbinary is not allowed
I am using Laravel 8.40 and trying to migrate my WebApp to
SQL Server 2008 R2 SP1
on MySQL everything works fine, but after I migrated my database over (with plain SQL commands) and when trying my app ...
2
votes
1
answer
126
views
Java 1.8 / SQL Server 2008 R2 : unable to run query when encryption is activated
I'm working in Java 1.8 and with a SQL Server 2008 R2 (I'm fully aware that it's not supported since a long time, but it's unfortunately not in my hand) which only support TLSv1.
I use ms-sql jdbc to ...
0
votes
1
answer
179
views
Count just working days (exclude weekends and public holidays) and add filter that a query
I want to add a filter to a query which grabs dates till last 5 WORKING DAYS.
declare @DataRetentionPeriod INT =5
Delete FROM dbo.table1 pt
WHERE CONVERT(varchar,pt.ptStampDateTime, 112) < ...
1
vote
0
answers
116
views
Connect to MSSQL hosted on Windows 2008 R2 from Amazon Linux 2023 PHP 8.2
I can't do anything with legacy database, can't migrate or update, I have to read some data from it. Personally, I'd love to migrate, but I can't.
Is there any way to connect Laravel 11 on PHP 8.2 ...
0
votes
1
answer
102
views
Query to SQL Server 2008 R2 with nested function call succeeds in SSMS but fails using ODBC
I have a legacy database that is running SQL Server 2008 R2 Express Edition.
Today, I was trying to use sqlacodegen to generate SQLAlchemy classes via the pyodbc package. I was able to connect to the ...
0
votes
0
answers
64
views
Error on transaction execute on my web site
When I execute my code on my ASP.NET website, I get this error:
Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 1, current count = 0.
...
0
votes
0
answers
88
views
Debug a trigger within a PowerBuilder program?
I working on for maintaining a legacy project, my PowerBuilder version is 12.5 and my SQL Server is 2008 R2, I encountered a problem which when I tried to update the records within a datawindow in a ...
0
votes
0
answers
63
views
Execute a stored procedure for a list of values using while loop from a query resultset in SQL Server 2008 R2
I am trying to execute a stored procedure for the list of values from a query using a while loop but the while loop is taking forever to complete.
CREATE PROCEDURE ItemsToBeCleared
@BatchDays INT
...
1
vote
3
answers
87
views
Convert Segmented Time Periods in SQL Using Cross Apply & Pivot
My core table data looks like this. It is keeping track of order statuses.
ID
PartNum
EnteredOn
PickedTime
DeliveredTime
100
50A
2024-03-28 08:59:13.727
2024-03-28 09:30:20.237
2024-03-28 09:56:42.570
...
1
vote
1
answer
56
views
Retrieve bounded time periods as a step function where beginning of period returns 1, end of period returns 0
I have a table in Microsoft SQL Server called Downtime that looks like this (I have omitted some irrelevant columns and many entries):
ID
StartTime
EndTime
5
2024-03-27 09:07:20.653
2024-03-27 09:09:...
0
votes
2
answers
409
views
Convert comma separated rows into a table without using CTE or split_string
I've hit an interesting problem in our system. A design decision was made to include IDs in a comma separated string which are referenced in the day-to-day functioning of the system. It wasn't causing ...
0
votes
1
answer
70
views
Export Attendance SQL query
I would like get help in the following Data. We have hand punch machines which saves exit and entry log, each exit and entry log stores a different row for an employee.
Table:
Date
circuit_label
...
-1
votes
1
answer
150
views
Using STUFF to get children value grouped by parent ID
I'm looking for a solution to get children's values in a single cell, I've found out about STUFF but when I'm trying to apply it to a self-referencing table it does not work.
Neither CONCAT nor ...
0
votes
1
answer
67
views
SSIS 2008 R2- Schedule Data flow task so that it only runs on Workday 1 - 2 Days
I have a SSIS package in visual studio 2008 which just contains a simple data flow task (ole DB source, flat file destination). However I need to add a constraint so that the task only executes on ...
0
votes
1
answer
69
views
Microsoft SQL Server : existing table new PK & index issue
I have an old database that unfortunately a choice was made when it was designed that one of the largest tables, which contains photos (table called Photos) and has a PK of type uniqueidentifier. This ...
0
votes
0
answers
25
views
SQL Server Profiler 2012 Always has "master" listed under DatabaseName
I'm trying to identify some slow and databases and queries on SQL Server 2008 R2. I have been able to filter by time and display the database name succefully. However the DatabaseName always says '...
1
vote
2
answers
142
views
Problem with updating the table via UPDATE SELECT
I'm using MS SQL Server. I have 2 tables:
Table1 stores information about the individual object number (Object_id), the number of its property (Prop_id) and the value of this property (Value).
Example
...
0
votes
0
answers
126
views
Cannot Import my Data from .CSV file into SQL Server Table
Here is my specifications:
My SQL Server: Microsoft SQL Server Enterprise 2019 (v15.0.2000.5)
My Windows : Windows 10 Enterprise LTSC 2021
My Office : Office 2016
My CSV file full path: F:\TaxStuff\...
0
votes
1
answer
158
views
LocalDB Help using SQL Server 2008 R2
It is possible to create the database using SQL Server 2008 R2, once created with all tables and stored procedures etc. then copy and paste it into the Visual Studio App_Data folder to be used as ...
0
votes
0
answers
188
views
Error saving incorrect version of SSIS package in SSMS
I'm trying to save a SSIS package for an export of a query to a .csv file. The problem is that the PackageFormatVersion of said SSIS package is 8 (for SQL Server 2016 onwards) but the instance I'm ...
-2
votes
1
answer
73
views
How can I do an insert for two tables at the same time using SCOPE_IDENTITY()?
I have 2 tables that I need to populate with 100 rows from a remote linked database.
The first table is easy, because I can just do a simple INSERT from a SELECT.
However, I also need to populate a ...
-2
votes
1
answer
406
views
How to Rename Column SQL Server with []
enter image description here
I entered the wrong column name and included [] as shown above [avail_memory_mb], I want to remove [] using the syntax, how do I do that?
I have tried using syntax
EXEC ...
1
vote
1
answer
328
views
How to insert mm/dd/yyyy strings into a SQL Server datetime column using fast_executemany?
I am querying data from BQ. I have to insert it to SQL Server 2008.
pseudocode:
# get results from bigquery
client = bigquery.Client()
result = client.query(sql).result()
# create parametrized ...
1
vote
1
answer
496
views
Combining CSV import with User Variable in SSIS package
I am importing a number of CSV files into a database. The aim is to take the data from the files but also write the filename of the associated CSV file to each of the database rows.
I am using a ...
0
votes
0
answers
437
views
How Do I Connect to an older (downgraded) database (.mdf file) from SQL Server 2008 R2 in Visual Studio 2022?
I am making a simple WinForms application for a client. The application's database does not run on their PC because they get the message
...MDF file cannot be opened because it is version 904. The ...
0
votes
2
answers
1k
views
Database trigger when a table is created with a particular name
I've reviewed (and tried to use) SQL Server 2008 trigger on create table without success. I currently upload a CSV file to a table called DataTMP. The data in this file is ETL'd into another table ...
-1
votes
1
answer
588
views
Join temp table with existing query
I have 2 queries in SSMS which are executing fine.
I need to join them together, and I'm not sure how to (I'm a beginner at T-SQL).
The first script is pulling data from a database and transforming ...
0
votes
0
answers
154
views
SQL Pivot on non-numeric values on multiple rows
I have the following data:
Employee
Date
Amount
Emp 1
01/01/2023
1.50
Emp 1
01/01/2023
7.5 LB
Emp 1
02/01/2023
0.00
Emp 1
02/01/2023
1.5 LB
Emp 1
03/01/2023
7.5 LB
I would like to pivot the table such ...
0
votes
0
answers
35
views
Query with where condition on the filestream blob table never returning only on some servers
strong textaI have a query that returns at most one row from a table with a FILESTREAM column, using the following condition:
select * from TABLE_WITH_FILESTREAM_BLOBS
where BLOB IS NULL AND ID_BLOB = ...
0
votes
1
answer
209
views
SQL Invalid Column Name Issue
I am getting an invalid column name error and I can't understand why...
SELECT TOP (1000) i.[t207f005_classification_code]
,i.[t207f010_sort_key]
,i.[t207f015_date_effective]
,i.[...
0
votes
0
answers
108
views
How to assign SQL @Action flag in ASP.NET MVC DAL class using single stored procedure?
Here is my SQL query:
CREATE PROCEDURE User_CRUD
@Action varchar(20),
@eno int,
@ename varchar(50),
@salary money
AS
IF @Action = 'Insert'
BEGIN
INSERT INTO employee (...
0
votes
1
answer
92
views
Finding Max of dates in SQL Query
CType
Material
CoCd
Plnt
SOrg
SoldTo
ShipTo
Customer
Vendor
SerProv
POrg
Year
per
UoM
NSapRel
Amount
Crcy
ChangedOn
Time
Changedby
SAPdate
SAPTime
SAPUser
PB00
775515
100
GA
7500000678
PO04
2022
100
...
0
votes
1
answer
894
views
How to get first row value from each group and apply to first record only, rest will be 0 or null in SQL Server
This is our output:
category
Rev
trandate
BankAccNo
Fee
Credit Cards
1
01-09-2022
10000175090
576
Credit Cards
1
01-09-2022
10000175090
576
Loan
2.2
01-01-2022
10000175090
678
Loan
2.2
01-02-2022
...
0
votes
2
answers
365
views
Adding a count variable as a suffix in sql
I want to create a new view in SQL Server 2008 R2.
Given is a col called "ADRESS", based on which I want to create a col called "CompanyID".
I want to add a suffix, which counts +1 ...
0
votes
1
answer
36
views
Group Items together that share the same ID Code, then indicate that the item is part of a group
Suppose I have items in a table that resemble the following:
Item
FamilyCode
ABR123
ABR
ABR456
ABR
BCL369
BCL
BCL987
BCL
AEL877
AEL
I would like to notate whether an item is part of a family based on ...
-1
votes
1
answer
394
views
How to pass parameter values to OBJECTID in SQL Server?
I am writing a stored procedure with DB name as input parameter. I am creating some physical tables dynamically. If a table already exists then I need to delete the Table.
DECLARE @TargetDBName ...
-2
votes
1
answer
149
views
Update query updating only 100 characters to database from 153 characters
I have a update statement that will update one column in the database.
The column is defined as varchar(500) and the string contains 153 characters.
But while updating, it updates only 100 characters.
...
0
votes
0
answers
232
views
In SQL server 2019, one encryptionkey and multiple decryptionkeys (one decryptionkey per user) to encrypt/Decrypt Columns of a table
In SQL server 2019, I have a table having 10 columns. There are 10 user logins. Each user should see only three columns as per their choice.
I need to keep the data encrypted in the database. Even ...
0
votes
1
answer
194
views
How to sequence SQL commands to execute a series of transformations?
I'm used to Powerquery's sequential command structure where each new step references the output of the previous one, like ...
Declare source Table1 with columns a, b, c. [RESULT: a, b, c]
Calculate ...
0
votes
1
answer
83
views
Troubleshooting Conditional Grouping with CASE (SQL Server 2008)
I'm hoping that someone is willing to help. I'm new to SQL and struggling to get a simple query debugged.
I want to create a simple frequency table to see how many values are missing (i.e. = 00000000) ...
0
votes
0
answers
80
views
SQL query omits records in the process of being committed
I'm running a query every 5 minutes to extract records created/updated in the 5 minutes leading up to the scheduled job. Occasionally the query will omit records that appear to be in the process of ...
1
vote
1
answer
406
views
T-SQL SUBSTRING with CHARINDEX AS LENGTH part is returning too much text
I have ploughed through the massive amount of queries on here relating to SUBSTRING and CHARINDEX but I cannot find one that answers my query.
I am extracting a single part of a long piece of text but ...
1
vote
1
answer
100
views
RTrim is not working when sentence is Arabic
RTrim is not working when sentence is Arabic.
Below is the example
declare @name nvarchar(50);
set @name = N' لللييب بي ';
select rtrim(ltrim(@name));
English one is working
declare @name nvarchar(...
-3
votes
1
answer
99
views
The error is in the first ORDER BY which is in second line. The code runs perfectly fine if i remove the first ORDER BY [closed]
The error is in the first ORDER BY which is on the second line. The code runs perfectly fine, if I remove the first ORDER BY.
Here is the code :
SELECT
dea.continent,
dea.location,
dea....
0
votes
1
answer
107
views
Restoring a DB with FullTextSearch To a Different DB same server
I need to make a copy of a production Database and restore it to a different database on the same production server. I do not have a development SQL Server to practice on. The DB to be copied has Full ...
1
vote
2
answers
256
views
Get Sub-String from third or forth specific character to end of string
I have a number of records in the table as shown below, where I have put the structure of the table and the records that are in conflict for you.
CREATE TABLE [dbo].[TblHilfeStrings]
(
[Id] [int] ...