Using C# and the JET OleDB driver (Microsoft.Jet.OLEDB.4.0) to connect to an old Access database (think Access 97). The following SQL statements work fine: But terminating the statement with a semi-colon (;) causes problems: Can SQL statements with DEFAULT be terminated? Answer Default values can (and probabl…
Tag: sql
Poweshell retrieve sql query result
I am quite new to PowerShell. I have multiple SQL queries which I am executing from a PS script using SQL adapter. I need to retrieve the common results based on a column from the queries without changing existing queries or writing another one. How to achieve this with PowerShell using the results stored in …
‘WITH’ clause does not work with in operator
I have a simple query: It should create a MaxSal temporary table and then in the WHERE section it should check whether the Salary, DepId are inside said table. Unfortunately, this query gives me ORA-00920: invalid relational operator which I guess is referring to the in operator. If I put the Sub-query direct…
What is mean name after variable name in t-sql
I have the next query: Сan you please explain what it means instruction: Is a variable called startdate assigned a different name? But why? Answer First, I would write this as: The two are equivalent, but this is clearer in intent (and less likely to cause problems). In any case, @startdate is not a valid col…
Change all bit columns to int with default value NULL
I have a database where we would store Yes/No questions as bits. However, as the project is going to a different path, we need to change all bit data types to int with default value NULL. Trying the following query, I get object is dependent of column error. To fix this I try doing: However, the fact that the…
Insert query: Column name or number of supplied values does not match table definition
This is a table that auto increments the ID, takes the time input, and sets the default of the total column as zero and the date column with getdate() So the only value that I have to insert is the time. However on insertion SQL Server gives me this error: Column name or number of supplied values does not mat…
Is start transaction always needed with Mariadb storedprocedure?
I have a mariadb database and a stored procedure. If a select statement is true then a delete query is done. Like this: My question is, do I need to place the start transaction at the beginning before the select statement or is the following possible? This second code doesn’t require a rollback and only…
How to check if two dates are the same with timestamp
I have two dates. One I get from the database, the other is which one I want to pass. How can I check if these two are the same? These are timestamp with time zones In this case they are the same. Answer
How can I query with NOT IN in a many-to-many relationship including NULLs
Given I have 3 tables and I need to retrieve all the rows where there is no relationship with a specific record and include the rows where there are zero relationships, how can I build this query? I need all books where the author Dewey (id = A2) has no relation at all. Because B4 has a relation with author
Invalid number when converting a date to another format
I have this query, and i am trying to format all dates for the two columns mentioned in the query below to the format mentioned: and i want to convert the results from timeone and timetwo to another date format DD-MM-YYYY HH:MIPM but when I run the query I got back invalid number. The datatype of the timeone …