I have two table which has data as below Table1 I would like to create where clause to get rows with like operator. for ex. But my problem is that there are more than 15-20 different parameter in where clause, it can also increase latter. So I have decided to create a new table in database lets called it Tabl…
Tag: sql-server
Compare values in Different column and row
I have the following table: What I need is to select all rows where Col1 value is available in Col2 and vice versa. This case only ROW 4 or ROW 3 should be returned. They have same values (13 17). Take it as col1 is Buyer and col2 is Seller I want to know who are the users who bought
Use Like operator in Select query with results from another Select query
I have a query with inner joins that returns 4-5 rows – the query: select Table1.valstring Prefix from TestDB.dbo.SomeCompany PC INNER JOIN TestDB.dbo.CMCompany CMC ON PC.companyuid = CMC….
SQL Server 2016 TDE Encryption on big text column
We implemented SQL TDE (SQL 2016) successfully on columns smaller in text size, but will give error on large columns Table Structure ID – value 1 – wanted to confirm her order for the install, adv …
GROUP BY with nested case expression – is there better way?
SQL server 2012 I am taking fees received and multiplying them by different factors based on how long the Client has been a Client. The group by clause is fairly straight forward. However, my select gets awkward when I want to use this criteria in different ways: I suppose I should mention this is a simplifie…
SSIS import an excel file with multiple header rows
Newbie doing SSIS import of csv and excel files. Things have been going well until I ran into an excel file with multiple header rows. The number of rows between the headers varies. I only need to …
Ineffective generation of SQL queries when using expressions with LINQ
Consider the following code, where dbContext is a SQL Server database context and Examples is a DbSet: The first line works as expected and is converted to SQL in the following manner: However, the second line first fetches all rows and applies the Take operator afterwards. Why is that? Since I am using expre…
Change the format of joining date to month-day,year sql
Change the format of joining date to month-day,year for e.g. January 31,1992. Query Error Table emp_demo format Answer You seem to be looking to display your date in a given format (which is what to_char() does in Oracle). In SQL Server, you can use format(): Demo on DB Fiddle: Yields:
Is there a way to obtain linked server query information?
I’m trying to query information on a linked server. The code works fine when run on the machine but doesn’t when connected via a linked server: The error I get is: Purpose behind it is to keep a track of queries run across an estate of servers into 1 central so we can monitor impacts (basically bu…
Conversion failed when converting date and/or time from character string. Sql
I want to display data between the said date range but it is showing the conversion error. What could be he problem? Answer Try using the standard form for dates: Actually, the above uses ISO standard formats for dates, which almost always (but not always depending on internationalization settings) work in SQ…