SQL Server Agent Weirdness
Hello Running SQL Server version Microsoft SQL Server 2017 14.0.3281.6 (X64) I have a query which when run in SSMS finishes exactly when I want it to, what it does it goes to a different server and checks if a job has completed ether successfully or…
Query SQL Error Log with T-SQL
Hi Team, I am treying to query SQL error log using T-sql. There is some issue with T-SQL. I am not getting error logs from last 24 hrs. CREATE TABLE #ErrorLogInfo ( ID INT…
Why can't I use the Import Data Wizard (on SSMS) to alter the default schema for new destination tables?
Hello, I hope this question is clear. I am still in the process of adding an image of the error message. I am using the wizard to import a flat file source into my database. I have SQL Server Express 2019. My goal is to create a table with…
Create a cursor that update field type char value in Sql Server
Hello , i want create a cursor that update column of my table Schools with more than three levels of education are level A, Schools with two levels of education are leveled with category B and other schools are leveled with category C. I tried…
not able to put is equal to sign (=) in query,
When i am inserting is equal sign= in query code sample then sign (=) in query is not showing in preview, what can be the issue
Convert comma seperate string into individual rows
Hi Team, I have a requirement that need to convert comma separated string into individual records in DB table. Below I mentioned sample data. From below screenshot input columns C3&C4 are independent columns, where as C5& c6 are dependent on each…
coalesce error
Hi , It got this error The conversion of a date data type to a datetime data type resulted in an out-of-range value from the statement 1 below. 1: coalesce(e1.[ResDate],e2.[ReDate],case when year(c.mydct)!=1970 then dateadd(minute,-360,c.mydct) else…
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…
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. …
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…
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…
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…
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.
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…