Friday, 24 July 2020

Tuesday, 21 July 2020

In SQL Server add database user to server after version upgrade and restoring database

1) Change user owned schemas to dbo
2) Delete database user
3) Delete server user
4) Recreate server user with user mapping to database
5) Reassign schemas owned by user

Sunday, 24 May 2020

In Windows get license information

slmgr /dli which means software license manager display license information

Thursday, 9 April 2020

In Postgres generate table structure of table

pg_dump --table=<schema>.<table> -h ip_address -p port -U username -d databasename -s

Monday, 30 September 2019

Postgres Update with From clause

In Postgres Update query with From clause can be used to update by catching between two or more tables.

The thing to keep in mind is the use of aliases in a certain way. For eg. the below example works where the alias before set is missing i.e. the alias for the 1st table to be compared is missing.

update schema.table1 set col1=v.col1 from schema.table2 v where ...
...
and table1.col2=v.col2 and table1.col3=value and table1.state_cd=v.state_cd;