When designing SQL Server datasheets in PowerDesigner, the following functionality is required through VBScript scripting:
Primary key: Pk_tablename
FOREIGN key: Fk_tablename_foreignkeycolumnlist
When the field is a primary key and the type is Smallint,int,bigint, set the identity =true.
When the field is a primary key and the type is uniqueidentifier, set the default value to NEWID () and set the extended property ROWGUIDCOL.
Option ExplicitValidationmode=TrueInteractivemode=Im_batchDimmdl'The current modelSetMDL =ActivemodelIf(MDL is Nothing) Then MsgBox "There is no current Model"ElseIf notmdl. IsKindOf (Pdpdm.cls_model) Then MsgBox "The current model isn't an physical Data model."ElseProcessFolder MDLEnd IfPrivate SubProcessFolder (folder)'Tables Dim Tab for each Tab inchFolder.tablesDimCol for eachColinch Tab. Columns'Auto Setup Identity ifCol.primary =true and(Col.datatype ="smallint" orCol.datatype ="int" orCol.datatype ="bigint") Thencol.identity=true 'Auto Setup rowguidcol ElseIfcol.primary=true andCol.datatype="uniqueidentifier" ThenCol. Defaultvaluedisplayed="newid ()"Col. Setextendedattributetext"Extrowguidcol",true End if Next 'Auto Setup Key DimKY for eachKyinch Tab. KeysifKy.primary =true ThenKy. Name="Pk_"+Tab. Name Ky. Code=Ky. Name Ky. ConstraintName=Ky. Name Ky. Clustered=true End if Next Next 'Auto Set external keys Dimref for eachRefinchfolder. References Ref.name="Fk_"+ref. Childtable.name +"_"+Ref. Foreignkeycolumnlist Ref. Code=Ref. Name Ref. Foreignkeyconstraintname=Ref.nameNext 'go into the sub-packages DimF'Running Folder for eachFinchfolder. Packagesif notF.isshortcut ThenProcessFolder FEnd if NextEnd Sub