Skip to content

Tag: sql-server

Get last and first record using rank()

I need to get first and last record (ordered by Date column) from table for certain SSID. It is not a problem if there is more records with same max or min date. All I need is union all. I am getting last record having max(date) with: How to I get first record (min(Date)) as well (same thing only with

How to import values from csv to SqlServer using c#

I have come across this problem.I am trying to import data into a database from a csv file.Normally the insert part works,but now I keep getting an error: Arithmetic overflow error converting int to data type numeric . The statement has been terminated.It is probably because I have id as the first property,bu…

TSQL – Fill in missing values as 0 for dates without a value

Apologies in advance for the pictures. I did these up as tables in Stack and they displayed fine in Preview but would not display properly once published. I have a sample dataset like below with many more KPIs. Picture Of Tables The dataset currently returned is just a join of these 2 tables and returns date …

Select range in SQL

I have a sql database that have InvoiceNumber column Now i need to select range between two numbers, but i don’t know what happened. I’ve tried “Between” and “<= , >=” Statements but the results are same. Table My query For example: If i need range between “1300…

Extracting hashtags by sql

I have this problem – currently I am extracting hashtags in a C# application but now I want to move it to SQL Server. In C# I have code using a regex: In T-SQL, I would like to have something like this: Answer Using the string_split