Questions tagged [sql-server-2008-r2]
Use this tag for questions specific to the 2008 R2 version of Microsoft's SQL Server.
11,322
questions
-1
votes
1
answer
98
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
29
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
51
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
16
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
55
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
97
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
37
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
58
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
48
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
70
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 ...
0
votes
1
answer
113
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
128
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
123
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
121
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
115
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
78
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 ...
0
votes
0
answers
22
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
90
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
87
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
55
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
...
0
votes
1
answer
442
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
171
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
0
answers
106
views
SQL Server 2008 R2 - database file is 10GB, can't shrink it
I've got a database on SQL Server 2008 R2 that has grown to 10GB (log file is tiny). Users cannot work because they get the message about not being able to allocate space, filegroup PRIMARY being full....
0
votes
1
answer
32
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 ...
-1
votes
1
answer
211
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
90
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
64
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
89
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
62
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
56
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
249
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
66
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
77
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
51
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
131
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] ...
0
votes
1
answer
83
views
Get Consecutive time slots per Employee
I have a table called slots with identity (id).
ID Employee Times Available
1 Anna 1900-01-01 07:00:00.000 0
2 Anna 1900-01-01 07:15:00.000 0
3 Anna ...
0
votes
0
answers
26
views
Can we install SSIS Services successfully on existing SQL Server 2008 R2 SP2
Can we install SSIS Services successfully on existing SQL Server 2008 R2 SP2? Please advice
0
votes
1
answer
35
views
Adding an inner join in a subquery gives a strange error in where of a subquery [closed]
I have the following query
SELECT PI.QUANTIDADE AS QTD_ORIGINAL, (COALESCE((SELECT SUM(CI.QUANTIDADE)
FROM COMPRA_ITEM CI INNER JOIN COMPRA C ON (CI.ID_COMPRA = C....
0
votes
1
answer
36
views
tsql LIKE wildcard comparison finds what = does not
This:
select casenumber from case where casenumber = '21-CR-1019'
Returns:
Nothing
While this:
select casenumber from case where casenumber like '%21-CR-1019%'
Returns:
21-CR-1019
The table column ...
-2
votes
1
answer
1k
views
How to convert weekly data into monthly data in sql?
I have a table that has weekly effort hrs and I need to report data on a monthly basis. for most of the cases, the week start date and end date lie in the same month and those records are easy to ...
2
votes
2
answers
303
views
snowflake sql - lateral flatten function compare with sql server - Split_String()
I have task to compare the counts and see if it's > 0
snowflake sql below
select 'abc'
from tableA
where
(SELECT count(T1.value) as val
from tableA,
lateral flatten(input=>split(abc, ',')) ...
0
votes
1
answer
284
views
Using the Table Type input Parameter in the 'IN' clause
I am using the table type as my input parameter in my stored procedure and I am passing in a list of comma separated Catalog Ids from my C# application.
But there is also an option on the web page ...
-1
votes
2
answers
101
views
Convert and merge two string as a table
Assume we have two below strings:
DECLARE @AllowedCardBoardIds NVARCHAR(MAX) = '1,2,3,4,5,6'
DECLARE @AllowedCardBoardIdsAccessTypes NVARCHAR(MAX) = '11,22,33,44,55,66'
Also, assume we have a ...
0
votes
1
answer
38
views
Count columns that ends with the same value starting with a value you choose
I have a table which is like:
Identfier
Abc XY: a(123)
Abcd XY: a(123)
Abcde XY: b(123)
dfe XY: b(123)
dfeg XY: b(123)
dfegh XY: c(123)
ijk XY: c(123)
I want to count columns
that they end ...
0
votes
1
answer
174
views
Concatenate XML Attributes SQL Server
I have an XML data set that which defines a list of Customers and all the Products the customer has purchased
<Info>
<Customer CustomerId="1">
<Product Name="A"...
0
votes
1
answer
72
views
Free memory when using geometry in SQL Server 2008 R2
This text was translated in Google Translate.
When using the geometry functions in SQL Server 2008 R2, I have noticed that my server memory is increasing, and I have no way to release used memory.
I ...
0
votes
0
answers
85
views
Auto clear SQL Server SSIS custom Log table once it is reaching its maximum limit
We have a SSIS custom log table where we insert log entries for each step & every step performed by the job. We have plenty of jobs in place running in different frequencies. Each job fills the ...
-1
votes
2
answers
488
views
Cast/Convert Arithmetic Overflow Why?
This works
select top(1786519) CONVERT(Decimal(8,2), Cost)
from table
This does not
select top(1786520) CONVERT(Decimal(8,2), Cost)
from table
Msg 8115, Level 16, State 6, Line 1
Arithmetic ...
0
votes
1
answer
563
views
Store any transaction in log table SQL Server
I have lots of tables in my SQL Server database. When any action happens, like an Insert, Update, Delete, I want to store the data in a Log table as shown here:
Product table:
| ID | Name | Other |...
1
vote
1
answer
1k
views
Serverless VPC Access connector with a "VPC with multiple Subnets"
I have the following scenario:
VPC network with one subnet that has 2 VMs with SQL Server installed (both have same data).
Serverless VPC Access connector
Cloud Run Service (Django container)
My ...