Skip to content
Advertisement

Tag: sql-server

Bulk insert csv file with semicolon as delimiter

I’m trying to import data from semicolon separated csv file into a SQL Server database. Here is the table structure The csv file is shown below: There are some columns that I don’t need, so I create a format file to import the data. The format file is shown as below Then I tried both bulk insert and bcp in

How to get record by Date in my case using SQL Server?

I have 2 tables ProductLog and Product ProductLog Product The select statement RegNo value to be ProductLog.RegNo , which is Product.Date <= ProductLog.TransDate I want to get a result like below Expected Output I tried by ranking order Date by ASC, and where rank =1, it set all to lowest date value. (I understand it is not a correct approach.)

Is there an UPDATE equivalent command to SELECT json data

Is there a way to update the data retrieved from the below select (in this case, change “MS220” to something else)? It’s difficult enough to do select from JSON in some cases. I’m not sure how to update just a single element. Answer Try JSON_MODIFY() with the path ‘$[0].Name’ Results: [ { “Categories”: [ { “QuerySourceNames”: [ “QAsset” ], “Id”:

While loop function union function end

I want to loop the code shown below. I would like to use the [getpublicholidays] function for a variable number of years and merge them (union). Unfortunately I don’t know how to use the function in a loop with union. Can someone help? Answer If you are looping for X years, each time you loop to a new year, you

Select all groups that contain all specified values in a certain column

Say I have the following table: CaseRef NotificationReason NotificationDate 123 SCHEDULED 2022-01-01 234 SCHEDULED 2022-01-02 312 SCHEDULED 2022-01-01 123 RESCHEDULED 2022-01-02 123 DECIDED 2022-01-03 234 DECIDED 2022-01-02 If I want to return only rows that have a CaseRef that has both a SCHEDULED and a DECIDED value in NotificationReason. CaseRef NotificationReason NotificationDate 234 SCHEDULED 2022-01-02 234 DECIDED 2022-01-02 123 SCHEDULED

@@ROWCOUNT shows as 0 when deleting using dynamic query SQL

I am facing a trouble when using dynamic query and when trying to get the number of deleted records using @@ROWCOUNT Here is my QUery Here after the dyanimic delete query (inside my cursor) I am trying to store the number of deleted records into another table using @@ROWCOUNT. But it shows as 0. I didnt understand what I did

SQL Server: show string majority

I am looking to make a query in SQL SERVER that will allow me to display in a grouping the string that appears in most cases. Not the amount, not the maximum, but the string that is displayed in most cases: colA colB colC A 10 ccc A 20 aaa A 35 bbb A 25 aaa A 10 aaa B

Advertisement