Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
I was wondering if newid() value is different even if newid() is used in 2 different places in the same sql statement, i.e, one newid() is select clause and another newid() in where clauseSELECT *, ABS(CAST( (BINARY_CHECKSUM (tbl1.col1, NEWID())) as int)) % 100 FROM table1 tbl1 WHERE (ABS(CAST( (BINARY_CHECKSUM (tbl1.col1, NEWID())) as int)) % 100) < 20The reason for my question: The results of the select do not seem to match with the where condition.Thank you.
russell
Pyro-ma-ni-yak
5072 Posts
Posted - 2010-09-01 : 11:49:48
it will return 2 distinct values, so your query won't work. but you can do this