on 01-21-2015 4:30 PM
I can't seem to find where I can alter the template used for creating a column's default value. Is this something the SQL Server does or is it something I can control? Below is a screen shot of 2 constraints that I've altered the constraint name template for and 6 constraints that pertain to column default values that I haven't named.
Thanks,
Mark
PD 16.5
SQL Server 2012
Hello Mark,
you can cchange the generation setting under
* edit DBMS
* ANSI 2::Script\Objects\Column\ConstName
change it to
CK_%.U17:COLUMN%_%.U8:TABLE%
or whatever meets your requirements
You should take the table name into the Constraintname because most times ( i dont know exactly for MSSQL-Sever) the Constrantname must be unique within the DB
Your example above looks like your template doesnt gives unique names within the db and MSSQL-Server then gives his own names to the not unique ones.
Generate everthing to a file instead directly to the Server and you´ll see if there are duplicates in the Constraint names.
it is also possible that you use the default clause in your table create statement without giving a name for this constraint and the Server then creates internally the names ( the DF_ leads me to that possebility)
HTH
dj
Message was edited by: dirk jaeckel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dirk,
I can't find the "ANSI 2" entry but here are my settings for the SQL Server constname...
Those settings are what get me the first two constraints. I suspect your last statement is spot on.
Here is the generated SQL from PD. There are no constraint names for the default values...
So I guess the question is where do you specify the template to do that since the one I specified above doesn't?
Thanks,
Mark
Sorry for the confusion about ansi2 i just opend a diffrent xdb because of laziness
to solve your "problem" :
its seemes it is like i wrote at the end of my last message:
you have unnamed defaults in your model which are automatically named from MSSQL-Server
IMO you can avoid them only by creating constraint-names in your model and use them:
you would go to the Microsoft Tab on the column level:
the following:
would create this:
/*==============================================================*/
/* Table: TABLE_1 */
/*==============================================================*/
CREATE TABLE TABLE_1 (
TEST_COL CHAR(10) CONSTRAINT or here NULL
)
go
But unfortunatly it doesnt looks like ther is an autmatiion for giving names here!
hth
dj
I found an solution for you:
the logic ist behind the extended attributes for Microsoft:
you can extend the extended attrib definition by setting the value field to computed and edit the getterfunction:
Function %Get%(obj)
' Implement your getter method on <obj> here
' and return the value
%Get% = "NL_" & replace(obj.name,".","_") 'in obj.name there ist table.columnname
End Function
do this for both variables:
ExtDeftConstName %Get% = "DF_" & replace(obj.name,".","_") 'in obj.name there ist table.columnname
ExtNullConstName %Get% = "NL_" & replace(obj.name,".","_") 'in obj.name there ist table.columnname
cheers
dj
Hi Dirk,
I did the following for ExtDeftConstName...
I'm not sure I need it for ExtNullConstname. If I do I will add the same script.
Since I only needed a Get method I checked the Read only button instead of the Read/Write button. Is this correct?
This is the result...
One last question. I don't know VBScript or the inner workings of PD so other than searching in the code examples and guessing how or where would I find the properties of classes such as the obj parameter passed in to the Get method?
Thanks again,
Mark
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.