Getting error creating view
I am creating a view over multiple tables. I am getting an error on a field that says it's invalid but it does exist in the table. field name is udHCSSE360WO and I have verified the spelling against the table. The same field exists in a different…
![](https://techprofile.blob.core.windows.net/images/edgpvxyqsUelLHw2VJInfQ.png?8D8504)
best way to query
Hi, I have the below query.I am passing the param to SP and @month is of yyyy-MM format.Basically whenever the @month is any month other than quarter end month,i calculate value from previous quarter end else i calculate the value for quarter end…
Why I am not able to restore TDE database?
Hello, I am running into an issue regarding restoring a TDE database and I just keep getting the "thumbprint not found error". I don't know what's causing it. Here are some details. I'm hoping someone can help me. I have many…
SQL Server Aggregate Query
I need to write a query that returns the ID of the items counted to find duplicates. I have a Transaction table with Procedures and need to find accounts where COUNT(Procedure)>1 GROUP BY Account. That part I can do. I don't know how to return the…
Help with Transact SQL
Hello all, I have a table with columns as below DECLARE @meter TABLE (prop_id int, min_calc_date datetime, max_calc_date datetime, fuel_rate int ) INSERT INTO @meter VALUES (123,'01-01-2020','08-19-2020', 50) , (123,'01-01-2020','08-19-2020',…
Select top 1 column along with CSV column
Hi All, I've a table as below: TableId SId Data DataOwner 1 10 aaaa 1001 2 10 aaaa 1000 3 20 bbbb 1000 4 10 ccc 2000 Declare @table1 table(TableId int, SId int, Data varchar(200), DataOwner int) insert into @table1 values(1, 10, 'aaaa', 1001)…
BCP date format
I am attempting to import data using bcp. The data contains dates formated as Jan 03 2019 12:00:00:00.000000AM. BCP rejects this data, saying this is an invalid date format. I believe BCP expects a date formatted as 2019-01-03 12:00:00:00.000000. …
![](https://techprofile.blob.core.windows.net/images/h1mBf06OwkKu0Wjn8RgUeg.png?8D844B)
Native Bcp file is converting special characters in the column value
Hi, I am generating bcp file in Sybase ASE with -n (native) and delimiter "|" and trying to load in SQL SERVER 2016. I know native file is not compatible with MSSQL Server . Is there any way or option i should explore to handle special…
![](https://techprofile.blob.core.windows.net/images/h1mBf06OwkKu0Wjn8RgUeg.png?8D844B)
Return null values if there is no record for top n selected
I am trying to get the top ‘n’ rows from the following query: SELECT TOP 1 ImageName FROM (SELECT TOP 5 * FROM ClientKeywordMedia where keywordid=1147 ORDER BY ID) z ORDER BY ID DESC The above query is working fine if top 5 is used in subquery as…
![](https://techprofile.blob.core.windows.net/images/h1mBf06OwkKu0Wjn8RgUeg.png?8D844B)
Query with Exist
Hello team, I have written a query as below: ;With myCTETable AS ( SELECT ShipCountry, CustomerID, OrderID, OrderDate, Rank() Over(Partition by shipCountry Order by Shipcountry, OrderDate Asc) AS FirstOrderDate From Orders ) SELECT…
![](https://techprofile.blob.core.windows.net/images/h1mBf06OwkKu0Wjn8RgUeg.png?8D844B)
Database design for friends relationships
Hallo! Can you help me design database for friends social relations with 1000 requests per second. Bob->Mary John->Bob Serg->Francis Francis->Bob Result: Bob->Francis->Serg Thanks.
![](https://techprofile.blob.core.windows.net/images/h1mBf06OwkKu0Wjn8RgUeg.png?8D844B)
Return one record per criteria
Hello folks, I am struggling with a solution for getting one record per criteria. In the attached example, I would like to get one record per "nbr". I have started with this, but obviously something does not work as it should :) SELECT…
Updating a table based on values in the table
I have a temp table #XX that looks like this" ID KWID NAME ORDER 1447 1144 SW_6368_58_55.png NULL 1450 1145 SW_6942_58_55.png NULL 1451 1147 Arb3_43_55.jpg NULL 1452 1147 Arb1_43_55.jpg NULL 1453 1147 Arb2_43_55.jpg NULL 1598 1152…
Delete duplicated lines based on 2 primary key
Greeting guys i want to delete duplicated primary keys in a table based on update date : Ex i have this table : i want to delete the duplicated lines based on the primary key (ID1 and ID 2 are my primary key ) . i want to keep the…
SSRS - STORED PROCEUDURE WITH TABLE VALUED PARAMETERS
Hi, How can we use Stored Procedure with Table Valued Parameter in SSRS Dataset ? CREATE TYPE DBO.MultiFilter AS TABLE ( filterVal VARCHAR(200) ) CREATE PROCEDURE DBO.USP_multiFilterTest @position DBO.MultiFilter READONLY …
New sqlserver server performance cpu issue
I am having issues with a new sqlserver 2019 server. It is a virtual server running on 2 cores and 6 logical cores with 64GB ram. It seems to not be maxing out the cpus, for example when I do a rebuild of a clustered column store index on the old…
![](https://techprofile.blob.core.windows.net/images/ctcyKX4BnU-r4fRclNq-Ww.png?8D9AB2)
Trying to show a row total as percentage of the whole
I've looked at several examples of using the windowing functions to achieve what I am aiming for and as far as I can tell, I have my syntax correct according to those. However, I'm still getting an error : Column…
![](https://techprofile.blob.core.windows.net/images/40JWhpM8gkqT4EKoi_NHQQ.png?8D94BB)
![](https://techprofile.blob.core.windows.net/images/40JWhpM8gkqT4EKoi_NHQQ.png?8D94BB)
How to Reset DENSE_RANK for new group
Hi All, How to reset DENSE_RANK for new set DDL and sample data population, start drop table if exists #t select * into #t from (select 1 as ID, 'a1' as address,'p1' as phone) p insert into #t select 1, 'a1', 'p2' union select…
sql if value is null not equal does not work
I have the below query, but the AND pd.FROMLOC <> 'DMS' does not work if the column has {null} is there a workaround? SELECT pd.wavekey, pd.orderkey, o.externorderkey, pd.pickdetailkey, pd.status, pd.fromloc, pd.loc, pd.sku, pd.qty,…
Display current hour Production
CREATE TABLE dbo.RAWTable(Time_Stamp datetime , Date date , Shift_Id varchar(5) , Line_Code varchar(10) , Machine_Code varchar(10) , Variant_Code varchar(20) , Machine_Status varchar(30) , OK_Parts int , NOK_Parts int , …