January 23, 2012 at 3:16 pm
Im new to SqlServer I was wondering if you had a record with a field that is an Integer which allows null and has a value of 1 can you do an Update Statement on that record and set that field to null
January 23, 2012 at 3:17 pm
As long as it allows NULLs, yes.
Jared
CE - Microsoft
January 23, 2012 at 3:20 pm
Thanks for you're quick response the reason why I asked is because I have a cte of posts and it checks if the parentId is null and loops through the table of related posts. Then if i wanted to move a thread to another forum I wanted to be able to update the parentID to null so it becomes the root thread
January 23, 2012 at 6:11 pm
kirkdm01 (1/23/2012)
Im new to SqlServer I was wondering if you had a record with a field that is an Integer which allows null and has a value of 1 can you do an Update Statement on that record and set that field to null
Yes, but the syntax is a bit weird: you need to write = NULL...
DECLARE @test-2 TABLE (column1 integer NULL);
INSERT @test-2
(column1)
VALUES
(100),
(200),
(300);
SELECT * FROM @test-2;
UPDATE @test-2
SET column1 = NULL
WHERE column1 = 200;
SELECT * FROM @test-2;
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply