Inserting value on all rows in a column

advertisements

I am using VB.net 2013 and SQL Server 2012. I have a table tblEmployeeInfo with two columns, EmployeeName and Date:

EmployeeName   Date
--------------------
Jay            Null
Mike           Null
Paul           Null

When I input a date value in Textbox1 like 3/20/2017, it would insert that value into all rows into column Date.

EmployeeName   Date
-------------------------
Jay            3/20/2017
Mike           3/20/2017
Paul           3/20/2017

Please anyone help me out. Still no idea how to code using VB.net. My idea just to insert only using WHERE clause. But how to insert at once? Thank you guys.


A simple approach

DECLARE @NewDate DATETIME=GETDATE();
UPDATE tblEmployeeInfo SET [Date][email protected];

Will set all rows to the same value. Is it really this you are trying to achieve?

If you want to hit only rows, where this value is NULL you can add

UPDATE tblEmployeeInfo SET [Date][email protected] WHERE [Date] IS NULL;

You - quite probably - have there some kind of grouping field where you want to set the new value selectively...? In this case just add an appropriate WHERE clause.