Tuesday, August 17, 2010

Find owner of database thru T-SQL

For all the database

select suser_sname(owner_sid) from sys.databases

For specific database

select suser_sname(owner_sid) from sys.databases where name = 'Northwind'

Update Multiple Column

MS SQL Update Multiple Column in single shot

*****************

UPDATE MyTable
SET (Col1, Col2, Col3, Col4) = (SELECT a, b, c, d FROM Mytable2 WHERE e =Mytable.Col5)
WHERE Col5 IN (SELECT d FROM Table2 )

*****************