Sunday, October 16, 2011

SQL Command to know Parent-Child tables relationship

SELECT ParentTable.Name AS PTable, PK.Name AS PrimaryKeyForParent, FK.name AS ForeignKeyOfChild, ChildTable.name AS CTable

FROM SYS.foreign_keys FK

INNER JOIN SYS.OBJECTS ChildTable ON FK.parent_object_id = ChildTable.object_id

INNER JOIN SYS.OBJECTS ParentTable ON FK.referenced_object_id = ParentTable.object_id

LEFT OUTER JOIN SYS.key_constraints PK ON ParentTable.object_id = PK.parent_object_id

ORDER BY PTable

How to know SQL table Properties

SELECT O.name AS TableName, C.Name As ColumnName,T.name AS DateType,T.max_length AS [Length], T.precision AS Precesion, T.scale AS Scale,

CASE WHEN C.is_identity = 1 THEN 'Y' ELSE 'N' END AS [Identity],

CASE WHEN C.is_nullable = 1 THEN 'Y' ELSE 'N' END AS Nullable

FROM SYS.OBJECTS O

INNER JOIN SYS.columns C ON C.object_id = O.object_id

INNER JOIN SYS.types T ON T.system_type_id = C.system_type_id

WHERE TYPE = 'U' AND T.name <> 'SYSNAME'

AND O.name <>'sysdiagrams'

ORDER BY O.name, C.column_id

Friday, October 7, 2011

Simple way to Restore Database

CREATE  DATABASE TestDB
 GO

RESTORE Database TestDB

FROM
DISK= 'D:\TESTDB.BAK'
WITH  REPLACE

Monday, October 3, 2011

How to reset password in SharePoint 2010

Wherever we change our windows password after that we face problems with SharePoint
Webapplication (cannot create webapplication or many more things so we need to change the password here as well. We have many ways to do this)

1. Go in Services and change the password for all SharePoint related service account
2. Go to IIS and update the servicepool password related to SharePoint

OR

The otherway which take cares of every thing. Which is easy and quick process...

Need to execute these commands from DOS prompt
(in SharePoint folder where if got installed)
(e.g. C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN)

Go to Run: Open cmd prompt to execute following commands one by one:

stsadm -o updatefarmcredentials -userlogin DomainName\UserName -password NewPassword -local


stsadm -o updateaccountpassword -userlogin DomainName\UserName -password NewPassword -noadmin

iisreset /noforce