Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
spidyboy
Starting Member
1 Post |
Posted - 2012-07-26 : 02:13:06
|
| well i have seen the codeSELECT name ColumnName, OBJECT_NAME(c.object_ID) AS TableName FROM sys.columns cWHERE name IN(SELECT name FROM sys.columnsGROUP BY name having count(name) > 1)ORDER BY Namebut it only give result something like this ColumnName TableNamedeptid mstEmployeedeptid mstDepartmentDesignationID mstEmployeeDesignationID mstDesignationcan i have the result something likemstEmployee 1..* mstDepartmentmstEmployee 1..1 mstDesignation |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-07-26 : 06:08:06
|
| Sort of.Would have to implement the relationships using foreign keys.mstEmployee 1..* mstDepartmentwould be a foreign key on a nullable not-unique column on mstDepartment referencing mstEmployeeThat would give you the ..* bit.The 0,1.. would be via a unique index on the columns in mstEmployeeThen you have to get the covering 1.. part of the relationship.That would probably be implemented via a trigger which makes things difficult as you would have to parse it.Another option is to always implement relationships via a conjoint table (table for relationship).That might make it easier.Probably a better option would be to create a spreadsheet to hold your database design.(I usually create my databases like this as it gives consistent coding).This could have these relationships indicated and the database schema created from it.You don't actually have to create the database from this - just have a process to compare with what is there.Once you are doing that you might think about using a product like ErWin.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|