There is a table Saleswith data from year 2005 to year 2015 I want to query data and filter column Sales_Date with datetime data type where the year is 2013 including all other columns is this correct or there is a function specifically to filter query by year of datetime data type Answer It is not correct as…
Tag: sql-server
How to merge tables returned by function called in select?
I created a function that takes a nvarchar and returns a table of one column and variable amount of rows. The problem is I need to call the funcion like this SELECT fn_My_Func(V.Value) FROM …
Reservation table query
when I execute my reservation table query, I get an error. Any help? This is my reservation table query CREATE TABLE RESERVATION ( NUMCHAMBRE INT FOREIGN KEY REFERENCES CHAMBRE (NUMCHAMBRE) , …
Create an index that only cares if a DateTime field is null or not?
I have many tables with a nullable DeletedDate column. Every query I write needs to check that the record is not deleted, but doesn’t care when it was deleted. I want to add an index to this column, …
How to remove rest of the ordered rows with the same ID after the first row which occurs more than once with that ID?
I have the following structure for the table DataTable: every column is of the datatype int, RowID is an identity column and the primary key. LinkID is a foreign key and links to rows of an other …
How to force extenal library to use SQL transaction
I have an external library to which I pass an instance of System.Data.SqlClient.SqlConnection and I want to wrap everything that library does on that connection in a transaction. When I was working …
How to get Average Salary of SQL HourlyPayRate Column?
I am working on creating a SSRS report and I want to get the Average of the HourlyPayRate Column that I have(in my case statement). I am a self learner of SQL and was wondering how I can get the AVG …
Returning all components multiple levels under a parent component
I have a hierarchical database out of which I would like to return all components in an asset with a specific common parent component. Components in table astComponents are linked to their parent …
Delete Result Rows from a Table in SQL
I have 2 tables named BM_Data1 & BM_Data1_May62019. Both Tables contains the same data as BM_Data1_May62019 is the copy of BM_Data1 table. But BM_Data1 has some extra rows, How can I delete those …
How to remove rest of the rows with the same ID starting from the first duplicate?
I have the following structure for the table DataTable: every column is of the datatype int, RowID is an identity column and the primary key. LinkID is a foreign key and links to rows of an other …