I have a table tblGeoLocation having 4 Columns Lat,Long,RunDate,LocType
Want to insert values from tbl1 into tblGeoLocation table. if @geolocation=0 then NULL values else the Lat,Long,LocType,RunDate values
insert into tblGeoLocation(Lat,Long,LocType,RunDate)
Select Case when @geolocation = '0' Then Null Else tbl1.GoogleLatitude END,
Case when @geolocation = '0' Then Null Else tbl1.GoogleLongitude END,
Case when @geolocation = '0' Then Null Else tbl1.GoogleLocationType END,
Case when @geolocation = '0' Then Null Else tbl1.RunDate END,
From tbl1 where Id=@Id
Please let me know how this can be done with out multiple else,for example case when @geolocation='0' then null is same,i do not want to write this multiple times for multiple columns. how can this be avoided.

Amit MohantyPosted Jun 16, 2022, 10:35 AM
Abhishek ChadhaPosted Jun 16, 2022, 8:44 AM
Nitin SontakkePosted Jun 16, 2022, 8:23 AM