Thursday, May 2, 2019

Copy file with command prompt

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!

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