I have some evaluations that are numbered something "A-05-10-0015" and secondary evaluations numbered something like "A-05-10-0015.A" or "A-05-10-0015.B" Regardless as to which record I am on at the time, the initial evaluation or .A or .B I am wanting to bring back all values in the database that could be different between each record based on the evaluation number being like "A-05-10-0015". Can anyone help me? Any help would be appreciated.
>> numbered something "A-05-10-0015"
It is looks like string and not numbers. It is probably NVARCHAR/CARCHAR type. the DDL will show us this.
>> Regardless as to which record I am on at the time
Databases usually works on SETs, not record by record. If you post your DML + what result you want to return we could help more.
>> I am wanting to bring back all values in the database that could be different between each record based on the evaluation number being like "A-05-10-0015".
It looks like you need query that use LEFT function or that it use LIKE filter, but until I see the DDL+DML I can not be sure.
Please post DDL+DML,
so we will be able to understand better and we will have the option to reproduce the issue in our environment.
* I mean that we need queries to create the tables +
insert some sample data, instead of description of what you have :-)
* In addition please post the result that you expects to get
Thanks.
Select ... FROM ... WHERE thecolumn Like 'A-05-10-0015%'
- Marked as answer by mrbill65 9 hours 18 minutes ago
>> I have some evaluations that are numbered [sic] something "A-05-10-0015" and secondary evaluations numbered [sic] something like "A-05-10-0015.A" or "A-05-10-0015.B" <<
Those are not numbers; they are names. This is a nominal scale and it needs a regular expression for validation. And where is the DDL and the name of this column? Have you ever read a book on data modeling?
>> Regardless as to which record [sic] I am on at the time, the initial evaluation or .A or .B I am wanting to bring back all values in the database that could be different between each record [sic] based on the evaluation number being like "A-05-10-0015". <<
Rows are not records. This is a fundamental concept in RDBMS. Hre is a guess at DDL. '
CREATE TABLE Evaluations
(eval_id CHAR(16) NOT NULL PRIMARY KEY
CHECK (eval_id
LIKE '[A-Z]-[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9].[AB ]'),
..);
SELECT eval_id
FROM Evaluations
WHERE ..;
>> Can anyone help me? Any help would be appreciated. <<
Please learn to help yourself. Forums are not for basic education.
My apologies and thanks for your response. I thought I had added more explanation and an example of my sql query but evidently my copy and paste did not work. Long story short the following query worked after I added the "- 1" :
SELECT LEFT(EvaluationNumber, CHARINDEX('.', EvaluationNumber + '.') - 1) AS EvaluationNumber
FROM dbo. Evaluations
WHERE EvaluationId = '!PrimaryKey!'
My apologies and thanks for your response. I thought I had added more explanation and an example of my sql query but evidently my copy and paste did not work. Long story short the following query worked after I added the "- 1" :
SELECT LEFT(EvaluationNumber, CHARINDEX('.', EvaluationNumber + '.') - 1) AS EvaluationNumber
FROM dbo. Evaluations
WHERE EvaluationId = '!PrimaryKey!'
My apologies and thanks for your response. I thought I had added more explanation and an example of my sql query but evidently my copy and paste did not work. Long story short the following query worked after I added the "- 1" :
SELECT LEFT(EvaluationNumber, CHARINDEX('.', EvaluationNumber + '.') - 1) AS EvaluationNumber
FROM dbo. Evaluations
WHERE EvaluationId = '!PrimaryKey!'