Click here to Skip to main content
15,885,365 members
Home / Discussions / Database
   

Database

 
AnswerRe: Code: 1292 SQL State: 22007 --- Incorrect datetime value Pin
RedDk8-Mar-23 8:30
RedDk8-Mar-23 8:30 
QuestionEF Core 6 Question Pin
Kevin Marois1-Feb-23 16:24
professionalKevin Marois1-Feb-23 16:24 
AnswerRe: EF Core 6 Question Pin
Dave Kreskowiak2-Feb-23 2:34
mveDave Kreskowiak2-Feb-23 2:34 
GeneralRe: EF Core 6 Question Pin
Kevin Marois2-Feb-23 5:45
professionalKevin Marois2-Feb-23 5:45 
Questionexecute an update  using --> "Exec sp_executesql @Sql1" Pin
Member 115338921-Feb-23 4:55
Member 115338921-Feb-23 4:55 
AnswerRe: execute an update  using --> "Exec sp_executesql @Sql1" Pin
Victor Nijegorodov1-Feb-23 5:48
Victor Nijegorodov1-Feb-23 5:48 
AnswerRe: execute an update  using --> "Exec sp_executesql @Sql1" Pin
David Mujica2-Feb-23 4:31
David Mujica2-Feb-23 4:31 
AnswerRe: execute an update  using --> "Exec sp_executesql @Sql1" Pin
Eddy Vluggen10-Mar-23 12:17
professionalEddy Vluggen10-Mar-23 12:17 
QuestionQuestion On SQL Query Result Pin
crmfghtr20-Jan-23 5:13
crmfghtr20-Jan-23 5:13 
AnswerRe: Question On SQL Query Result Pin
Richard Deeming20-Jan-23 5:33
mveRichard Deeming20-Jan-23 5:33 
PraiseRe: Question On SQL Query Result Pin
crmfghtr20-Jan-23 5:41
crmfghtr20-Jan-23 5:41 
AnswerRe: Question On SQL Query Result Pin
Mycroft Holmes20-Jan-23 11:34
professionalMycroft Holmes20-Jan-23 11:34 
GeneralRe: Question On SQL Query Result Pin
crmfghtr20-Jan-23 12:41
crmfghtr20-Jan-23 12:41 
QuestionEF Core 6 Exclude Columns Pin
Kevin Marois19-Dec-22 8:47
professionalKevin Marois19-Dec-22 8:47 
AnswerRe: EF Core 6 Exclude Columns Pin
Dave Kreskowiak19-Dec-22 15:47
mveDave Kreskowiak19-Dec-22 15:47 
GeneralRe: EF Core 6 Exclude Columns Pin
Kevin Marois23-Dec-22 7:36
professionalKevin Marois23-Dec-22 7:36 
QuestionUsing SQL Native Backup URL, multiple databases to Azure Blob Storage Pin
Jaime Maccou9-Dec-22 1:00
Jaime Maccou9-Dec-22 1:00 
AnswerRe: Using SQL Native Backup URL, multiple databases to Azure Blob Storage Pin
jschell12-Dec-22 10:33
jschell12-Dec-22 10:33 
QuestionEntity Framework Core 6 VARCHAR(MAX) Pin
Kevin Marois8-Dec-22 12:54
professionalKevin Marois8-Dec-22 12:54 
AnswerRe: Entity Framework Core 6 VARCHAR(MAX) Pin
Victor Nijegorodov8-Dec-22 18:24
Victor Nijegorodov8-Dec-22 18:24 
GeneralRe: Entity Framework Core 6 VARCHAR(MAX) Pin
Kevin Marois9-Dec-22 11:47
professionalKevin Marois9-Dec-22 11:47 
GeneralRe: Entity Framework Core 6 VARCHAR(MAX) Pin
jschell12-Dec-22 10:35
jschell12-Dec-22 10:35 
QuestionSOLVED - Pivot a result set Pin
Richard Andrew x6428-Nov-22 5:46
professionalRichard Andrew x6428-Nov-22 5:46 
AnswerRe: SOLVED - Pivot a result set Pin
Richard Deeming28-Nov-22 21:24
mveRichard Deeming28-Nov-22 21:24 
QuestionTSQL - JOIN cancels out my date filter Pin
jkirkerx27-Nov-22 13:53
professionaljkirkerx27-Nov-22 13:53 
Well today was a crappy day, thinking I can hit and run this small web page and clean it up. I spent hours modeling this in SQL Manager finally getting it to work, and then used it my PHP code, it worked but fell apart. Maybe I have it backwards, and I should call "Project" first, and then join "commission_Summary"

The first example works, but when I join the "project" table, it cancels out my "commission_summary.startup_check_date" filter. I get that or think that my JOIN is wrong, or that my JOIN is calling up all records and overriding my date filter. I tried different types of JOINs, but with no success.
SELECT 
    commission_summary.project_no,
    commission_summary.EC, 
    commission_summary.TC, 
    CONVERT(CHAR(10), commission_summary.startup_check_date, 120) AS StartDate, 
    CONVERT(CHAR(10), commission_summary.finished_check_date, 120) AS StopDate      
FROM commission_summary
WHERE CAST(commission_summary.startup_check_date AS SMALLDATETIME) >= CAST('2022-01-01 00:00:00' AS SMALLDATETIME)
ORDER BY commission_summary.startup_check_date DESC 

I tried adding one join at a time, and it worked or produced my desired results using just JOIN. I don't understand why this returns all the records, well I know it's JOIN related, just not sure why. My theory, is that the "Project" JOIN may have a duplicate column name. I wonder if I should of used a wildcard for testing, like SELECT * FROM. This returns all the records
SELECT 
    commission_summary.project_no,
    commission_summary.EC, 
    commission_summary.TC, 
    CONVERT(CHAR(10), commission_summary.startup_check_date, 120) AS StartDate, 
    CONVERT(CHAR(10), commission_summary.finished_check_date, 120) AS StopDate,
    project.Status, 
    project.Sales_no,
    project.swan_job, 
    employee.Employee_ID, 
    employee.FName, 
    employee.LName, 
    customer.Customer_no, customer.LName, 
    customer.FName, 
    customer.City 
FROM commission_summary 
JOIN project on commission_summary.project_no = project.project_no 
JOIN employee on commission_summary.employee_id = employee.Employee_Id 
JOIN customer on customer.Customer_No = project.Customer_no 
WHERE CAST(commission_summary.startup_check_date AS SMALLDATETIME) >= CAST('2022-01-01 00:00:00' AS SMALLDATETIME)
AND project.status = 'construction' OR project.status = 'finished' 
ORDER BY commission_summary.startup_check_date DESC 

I'm confused by how this works, because it produces my desired results, of about 12 records in 2022.
SELECT 
commission_summary.project_no, 
commission_summary.EC, 
commission_summary.TC, 
CONVERT(CHAR(10), 
commission_summary.startup_check_date, 120) AS StartDate, 
CONVERT(CHAR(10), commission_summary.finished_check_date, 120) AS StopDate, 
project.Status, 
project.Sales_no, 
project.swan_job, 
employee.Employee_ID, 
employee.FName, 
employee.LName, 
customer.Customer_no, 
customer.LName, 
customer.FName, 
customer.City 
FROM commission_summary 
JOIN project on commission_summary.project_no = project.project_no 
JOIN employee on commission_summary.employee_id = employee.Employee_Id 
JOIN customer on customer.Customer_No = project.Customer_no 
WHERE (CAST(commission_summary.startup_check_date AS SMALLDATETIME) >= CAST('2022-01-01 00:00:00' AS SMALLDATETIME)) 
AND project.status = 'construction' OR project.status = 'finished' 
AND commission_summary.employee_id = '91' 
ORDER BY commission_summary.startup_check_date DESC 

Any point in the right direction would be appreciated, or even a simple explanation.
If it ain't broke don't fix it
Discover my world at jkirkerx.com

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.