SQL Server : does NEWID() always gives a unique ID?

Both NEWID() and NEWSEQUENTIALID() give globally unique values of type uniqueidentifier. NEWID() involves random activity, thus the next value is unpredictable, and it’s slower to execute. NEWSEQUENTIALID() doesn’t involve random activity, thus the next generated value can be predicted (not easily!) and executes faster than NEWID(). So, if you’re not concerned about the next value … Read more

Cannot implicitly convert type ‘bool’ to ‘system.threading.tasks.task bool’

You need to be specific whether you want this operation happen asynchronously or not. As an example for Async Operation : public async Task<bool> login(string usn, string pwd) { DataClasses1DataContext auth = new DataClasses1DataContext(); var message = await (from p in auth.Users where p.usrName == usn && p.usrPass == pwd select p); if (message.Count() > … Read more

SQL: subquery has too many columns

You are projecting three columns in your subquery, but comparing a single one of them in the IN clause. Select just the required column (r1.king) for the IN in the subquery: SELECT kingdom.king, dinasty.birth, dinasty.death FROM kingdom, dinasty WHERE kingdom.king = dinasty.name AND kingdom.king NOT IN ( SELECT DISTINCT R1.king FROM ( SELECT DISTINCT R1.king, … Read more

Will multiple calls to `now()` in a single PostgreSQL query always give the same result?

The documentation says about now(): now() is a traditional PostgreSQL equivalent to transaction_timestamp() And about transaction_timestamp(): These SQL-standard functions all return values based on the start time of the current transaction So within one SQL statement, now() will always return the same value.

SQL Show most recent record in GROUP BY?

Start with this: select StudentId, max(DateApproved) from tbl group by StudentId Then integrate that to main query: select * from tbl where (StudentId, DateApproved) in ( select StudentId, max(DateApproved) from tbl group by StudentId ) You can also use this: select * from tbl join (select StudentId, max(DateApproved) as DateApproved from tbl group by StudentId) … Read more

Truncate multiple tables in one MySQL statement

No, you can only truncate a single table with TRUNCATE command. To truncate multiple tables you can use T-SQL and iterate through table names to truncate each at a time. DECLARE @delimiter CHAR(1), @tableList VARCHAR(MAX), @tableName VARCHAR(20), @currLen INT SET @delimiter=”,” SET @tableList=”table1,table2,table3″ WHILE LEN(@tableList) > 0 BEGIN SELECT @currLen = ( CASE charindex( @delimiter, … Read more

Closing connection when using Dapper

I am assuming that you are using latest version of Dapper. With Dapper, there are two ways to manage connection: Fully manage yourself: Here, you are fully responsible for opening and closing connection. This is just like how you treat connection while working with ADO.NET. Allow Dapper to manage it: Dapper automatically opens the connection … Read more

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