variables in SQL script

Hi team,

anyone could give any clue how that variable in SQL Script works?

That is a variable assigned by SWE?

Best

SolidworksElectrical
Comments 6
RY
RY 2021-04-08

Oh, my bad. It is not in the list. Where is the column function BTW?

Any comment on how these variable should be used?

Thanks for sharing. will give it a try.

cheers,

JJ
JJ 2021-04-08

Which variable are you referring to Roland?  %ELEMENT_COUNT% is not in the list, but is an environment variable that is used by the 'eltcount' function call in the column function.

My warning about the syntax between SSMS and SWE's query editor was specifically aimed at what you're suggesting.  You'll find that SSMS syntax does not match SWE for some of these variable calls/definitions, so YMMV, but it's still best practice (as far as I'm concerned) to develop in SWE until you'd like to use the Query Designer/etc in SSMS, then use SSMS and edit those environment variables back in once you're back in SWE.

RY
RY 2021-04-08

it seems that variable is part of the list from the Expert Mode.

any clue how these variables should be used?

Likely the we have to pick one place from another. thinking of use the SSMS because of the enriched feature and copy paste to SWE. any best practice suggestions?

cheers,
Roland

RY
RY 2021-04-08

Thank you Daniel for sharing.

JJ
JJ 2021-04-08

%ELEMENT_COUNT% is the variable established for the default BOM reports.  Reports using the column function of 'eltcount'.  Merge the rows and quantities will be totaled. 

Note: this doesn't translate to SSMS scripts - in SSMS you'd establish your own variable, and call it whatever you want.  The SWE context won't work in SSMS and the SSMS context won't work in SWE, so be cautious writing/testing your scripts in one place or the other.

DM
DM 2021-04-08

I believe that's used when you are trying to get a sum of values in a table.  it appears to be aliasing the number 1 as the first counter.