I have a table with a date field called oppo_installdate. This is a date in the future, and I basically want to select records where this date is 7 or fewer days from the current date. I have tried to do this with the query below but it is older returning dates from 2019 as well, and I’m not sure
Tag: sql-server
T-SQL Equivalent of regular expression ‘b’
I’m in the process of converting a CLR function that utilizes regex to a SQL function. I know that SQL Server does not fully support regex, but i just need one case to work which is a word search. Search Field Value: {“Id”:1234, “Title”: “The quick brown”} Regex Patte…
Merge two tables in SQL, with one common column
I’m trying to merge to tables in MSSQL, as in the sample below. My situation is similiar to this question. T-SQL merging two tables with common and uncommon columns I have tried using the following query: But it results in this, where the rows that have the same value in column a, merges in the same row…
Pass a table variable using table type into a stored procedure?
I have a table employee with around 1000 entries, I have to create a stored procedure which accepts a parameter. The parameter will most likely be of the type which I created ‘AS Table’. Upon passing …
Using SQL Server Always Encrypted feature in stored procedure
I am using SQL Server Always Encrypted feature of Azure SQL with .NET code. While it works like charm inside Entity Framework where the data can be decrypted, not sure how do I use it in stored procedures? Let’s say I have a column called Department Id and I have encrypted the same using Always Encrypte…
TSQL – Conditionally “Cross Join” Records
Code (staging sample data): Detail: @LookupTab is basically a filter that will have either 0, 1, or both values (111 – Option 1 and 112 – Option 2). @DataTab is the actual data in the table (can be huge). The Val field in this table can either be 111 (Option 1), 112 (Option 2), or 223 (Both Option…
Sql check range exist between a range
i have a table like and i have a range value for example i want to get row who’s value matchs the range from database table Example minV = 5 , maxV = 15 should return first and second record Example minV = 5 , maxV = 35 should return all record Example minV = 5 , maxV = 9
Identity column as part of primary key
Suppose, I have a composite primary key that consists of 3 columns: [ShardKey], [SiteId] and [ServiceId]. Column [ServiceId] is an identity column and should start from 1 for a new combination of [ShardKey] and [SiteId], but SQL server fails – the column [ServiceId] never starts from 1, it just incremen…
Selecting variables as individual rows in table [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 2 y…
Are the table indexes used in the select on the resultset of a subquery in the FROM clause?
I have a table in the SQL Server with more than 50 millions rows, so I have some compound indexes in my table. Indexes with 3, 4 columns. There is a situation where I really need to use a subquery in the FROM clause. example of the structure( the index is: column2, column3, column4 ): The example is only to