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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-11-01 : 09:17:46
|
| Martin writes "Good day,Here is my small question.In MS SQL Server 2000 I've created table:CREATE TABLE test (x int)GOThen I've populated it with data:INSERT INTO test VALUES (1)INSERT INTO test VALUES (2)INSERT INTO test VALUES (3)INSERT INTO test VALUES (4)INSERT INTO test VALUES (5)GOThen I run this snippet of code:declare @t varchar(32)SELECT @t = x FROM testPRINT @tand got result:5This is obvious - SQL Server selected last inserted value fromthe table as it found it first in physical storage...Next snipped shocked me:declare @t varchar(1024)SELECT @t = ''SELECT @t = @t + CONVERT(varchar(12),x) FROM testPRINT @tResult:12345Why? Does SQL Server create an implicit cursor and loop throughthe table?Thanks,Martin" |
|
|
|
|
|