My colleague shared me a good trick on how you can copy a file with cmd, means you can do it even if it is half way being written by a program. But you will only have the content as per the moment it is duplicated.
1) C:\yourUsers > pushd \\TheFolderPath
2) D:\THePath> type fileName.txt > newFileName.txt
DONE!
Thursday, May 2, 2019
Finding a table based on the table name in MSSQL
Here a code I googled on how you can find a table based on its name.
create table #t (
DBName sysname not null
)
go
exec sp_MSforeachdb 'use [?]; if OBJECT_ID(''dbo.mytable'') is not null insert into #t (DBName) select ''?'''
go
select * from #t
go
drop table #t
create table #t (
DBName sysname not null
)
go
exec sp_MSforeachdb 'use [?]; if OBJECT_ID(''dbo.mytable'') is not null insert into #t (DBName) select ''?'''
go
select * from #t
go
drop table #t
Monday, April 15, 2019
Selecting all columns and alter or replace one column for all row
if you would like to do a select all and altering a column without visiting each element or
select * replace a column value without looping , here are what you can do
a very good post in stackOverflow can be found here:
in an Ienumerable list / the Linq way:
1) collection.Select(c => {c.PropertyToSet = value; return c;}).ToList();
2) collection.ToList().ForEach(c => c.PropertyToSet = value);
in data table:
make the good use of the .Expression , you can find MSDN documentation here :
1) column.Expression = "price * 0.0862";
2) column.Expression = anotherColumn's Name;
select * replace a column value without looping , here are what you can do
a very good post in stackOverflow can be found here:
in an Ienumerable list / the Linq way:
1) collection.Select(c => {c.PropertyToSet = value; return c;}).ToList();
2) collection.ToList().ForEach(c => c.PropertyToSet = value);
in data table:
make the good use of the .Expression , you can find MSDN documentation here :
1) column.Expression = "price * 0.0862";
2) column.Expression = anotherColumn's Name;