Is there a trick for using TSQLMonitor with a TSQLConnection that uses the new ODBC dbExpress driver?

Try this out: procedure TForm2.Button1Click(Sender: TObject); begin try Connect; SQLMonitor1.SQLConnection := SQLConnection1; SQLMonitor1.Active := True; ExecuteQueries; SQLMonitor1.SaveToFile(‘D:\\Log.txt’); except on E: Exception do ShowMessage(‘Exception ocurred!: ‘ + E.Message); end; end; procedure TForm2.Connect; begin SQLConnection1 := TSQLConnection.Create(nil); SQLConnection1.ConnectionName := ‘odbcinterbaseconnection’; SQLConnection1.LoginPrompt := False; SQLConnection1.LoadParamsOnConnect := True; SQLConnection1.Connected := True; end; procedure TForm2.ExecuteQueries; var Query: String; begin try … Read more

How do you get the identity value after using MERGE when there is a match?

In the case when the record already exists, you can store the matched id into a variable like this: DECLARE @MatchedId INTEGER; MERGE MyTable as t …. …. WHEN MATCHED THEN UPDATE SET @MatchedId = t.MyTableId; UPDATE: Here’s a full example. This demonstrates one way: DECLARE @UpdateVariable bit DECLARE @ChangeResult TABLE (ChangeType VARCHAR(10), Id INTEGER) … Read more

using Switch like logic in T-SQL

You need to use If/Else If structure, like this: If @Type = 1 Begin INSERT INTO dbo.Credit ( CompanyName, PhoneNumber, City, State ) VALUES ( @CompanyName, @PhoneNumber, @City, @State) End Else If @Type = 2 Begin INSERT INTO dbo.Debit ( CompanyName, PhoneNumber, City, State ) VALUES ( @CompanyName, @PhoneNumber, @City, @State) End Else If @Type … Read more

Testing for inequality in T-SQL

These 3 will get the same exact execution plan declare @id varchar(40) select @id = ‘172-32-1176’ select * from authors where au_id <> @id select * from authors where au_id != @id select * from authors where not (au_id = @id) It will also depend on the selectivity of the index itself of course. I … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)