How to Replace NULL column values

Posted by Naeem2049 under Sql Server on 1/17/2011 | Points: 10 | Views : 10871 | Status : [Member] | Replies : 5
Hi,

How to replace null column values with other column values in SQL Server (Is there any hot key function to do this without writing Queries).

In MS Access we have done this using Find and Replace Hot key functions very easily to replace one column values with other column values....

But in SQL Server how can we do that without using queries.....

How to Replace null column values with another column values in SQL Server tables?????????

Please Help me in this...........

Thanks for advance help...

Regards
NAEEM




Responses

Posted by: Karthikanbarasan on: 1/17/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,

If you not using the queries then when can make the tables column value to DEFAULT some standard value when its null.... So when ever its inserting it can add a value if the record column is gng to be empty.

Thanks
Karthik
www.f5Debug.net

Naeem2049, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: T.saravanan on: 1/17/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi,

without using query means why you goto Sql Server just copy all the values into Excel then replace the null value into your value after replace copy the value paste into the table.other wise refer the Karthik answer when you create a table at the time set the default value into that column means when ever pass the empty value into that column means automatically store the default value in that column.

Note: Insert condition do not pass the empty value into the column.

For example.... Table have Id,Name,City, in this table we set default value ('Chennai') into city column means
with value...
 insert into table (Id,Name,City) values (1,'Ram','Mumbai') 

with out value..
.insert into table (Id,Name) values (2,'Sam')  // Now automatically set Chennai value.

if we pass the empty value...
insert into table (Id,Name,City) values (3,'Raj','')  //Now store empty value in city column


If you already have the value in table means use update query..
update table set value =1 where value is null

its the simple way...

Cheers :)



Thanks,
T.Saravanan

Naeem2049, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naeem2049 on: 1/18/2011 [Member] Starter | Points: 25

Up
0
Down

Hi All,

My point is that I have already a table having More than 500 rows and Few Columns in it. How can i replace the each row of a particular Column value which have by default NULL written on it. Means that I have a column in other table i want to replace that complete column value with the column having NULL written on each row of it.
My Question is this is there any Replace function of SQL Server Control Bar to just copy complete Column values and replace with the column having NULL values.

I think got my point.

Thanks
NAEEM

Naeem2049, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: T.saravanan on: 1/18/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi Naeem,

I think there is no find control for the column value.Why are you avoid query... Refer the following syntax you will update the value from one table into another table.

Update tab2 set tab2.sValue = tab1.sValue from table1 tab1,table2 tab2 where tab1.Id = tab2.Id and tab2.sValue is null


Cheers :)

Thanks,
T.Saravanan

Naeem2049, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 1/18/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi Naeem,

You should post your requirement clearly, so that we should have given a positive direction immediately. You can refer to Saravanan's update statement. It will resolve your problem.

Thanks
Karthik
www.f5Debug.net

Naeem2049, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response