What are the integer values for Microsoft.SqlServer.Management.SqlParser.Parser.Tokens enumeration?

Hi Experts,

I am using Microsoft.SqlServer.Management.SqlParser.Parser classes in.NET to do some parsing in SQL statements. The
Scanner.GetNext() function returns an integer values, and the documentations told that it is a Token. When I get the returned integer value I found that I don't know what it means, and I cannot find any documentation mapping this integer value into meaningful Microsoft.SqlServer.Management.SqlParser.Parser.Tokens value.

How shall I do that?
Thank you!

I am using SQL Server 2012 and using the .NET classes in Powershell
huangs3Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

louisfrCommented:
Did you try casting the integer into a Tokens value?
Tokens token = (Tokens)yourvalue;

Open in new window

louisfrCommented:
Parser is not an enumeration but Tokens is.
And I'm sure the GetNext method returns one of its values.
MlandaTCommented:
To get the values of that enum:
Dim tokens As System.Array = [Enum].GetValues(GetType(Microsoft.SqlServer.Management.SqlParser.Parser.Tokens))
For Each token in tokens
   Console.Writeline(String.Format("{0}, {1}", CInt(token).ToString, token.ToString))
Next

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

MlandaTCommented:
**not seeing my attachment with the values above***

127, error
128, EOF
129, NON_EMPTY
130, Lowest
131, error_1_discard_max
132, error_unlimited_discard
133, lower_than_left_paren
134, lower_than_grant
135, TOKEN_OR
136, TOKEN_AND
137, TOKEN_NOT
138, TOKEN_DOUBLECOLON
139, TOKEN_ELSE
140, TOKEN_WITH
141, TOKEN_WITH_CHECK
142, TOKEN_GRANT
143, TOKEN_REVOKE
144, TOKEN_CREATE
145, TOKEN_DENY
146, TOKEN_DROP
147, TOKEN_ADD
148, TOKEN_SET
149, TOKEN_FETCH
150, TOKEN_CROSS
151, TOKEN_FULL
152, TOKEN_INNER
153, TOKEN_OUTER
154, TOKEN_LEFT
155, TOKEN_RIGHT
156, TOKEN_UNION
157, TOKEN_JOIN
158, TOKEN_PIVOT
159, TOKEN_UNPIVOT
160, Highest
161, TOKEN_GRAMMAR_STANDARD_TSQL
162, TOKEN_GRAMMAR_SPCURSOROPEN
163, TOKEN_GRAMMAR_SPCURSOROPEN_PROC
164, TOKEN_GRAMMAR_SPCURSORDML
165, TOKEN_GRAMMAR_RECOMPILE
166, TOKEN_GRAMMAR_OPTION_CLAUSE
167, TOKEN_GRAMMAR_XEVENT_PREDICATE
168, TOKEN_GRAMMAR_FILTERED_INDEXES
169, TOKEN_GRAMMAR_FILTERED_INDEX_EXPR
170, TOKEN_GRAMMAR_COMPUTED_COLS
171, TOKEN_ID
172, TOKEN_QUOTED_ID
173, TOKEN_VARIABLE
174, TOKEN_STRING
175, TOKEN_PSEUDOCOL
176, TOKEN_TEXT_LEX
177, TOKEN_IMAGE
178, TOKEN_BINARY
179, TOKEN_LABEL
180, TOKEN_INTEGER
181, TOKEN_GLOBAL_VAR
182, TOKEN_REAL
183, TOKEN_MONEY
184, TOKEN_NUMERIC
185, TOKEN_REQJOIN
186, TOKEN_ODBC_PREFIX
187, TOKEN_ODBC_TERMINATOR
188, TOKEN_ADD_EQ
189, TOKEN_SUB_EQ
190, TOKEN_MULT_EQ
191, TOKEN_DIV_EQ
192, TOKEN_MOD_EQ
193, TOKEN_BW_AND_EQ
194, TOKEN_BW_OR_EQ
195, TOKEN_BW_XOR_EQ
196, TOKEN_ALL
197, TOKEN_ALTER
198, TOKEN_SCHEMA
199, TOKEN_AUTHORIZATION
200, TOKEN_ANY
201, TOKEN_AS
202, TOKEN_VARYING
203, TOKEN_ASC
204, TOKEN_BEGIN
205, TOKEN_BETWEEN
206, TOKEN_BREAK
207, TOKEN_BROWSE
208, TOKEN_BULK
209, TOKEN_BY
210, TOKEN_CASE
211, TOKEN_CHECKPOINT
212, TOKEN_CLUSTERED
213, TOKEN_COALESCE
214, TOKEN_COLLATE
215, TOKEN_COMMIT
216, TOKEN_COMPUTE
217, TOKEN_CONTINUE
218, TOKEN_CASCADE
219, TOKEN_CONVERT
220, TOKEN_TRY_CONVERT
221, TOKEN_DATABASE
222, TOKEN_RESTRICT
223, TOKEN_DBCC
224, TOKEN_DECLARE
225, TOKEN_DEFAULT
226, TOKEN_DELETE
227, TOKEN_DESC
228, TOKEN_DISTINCT
229, TOKEN_DOUBLE
230, TOKEN_DUMP
231, TOKEN_END
232, TOKEN_ERRLVL
233, TOKEN_EXCEPT
234, TOKEN_ESCAPE
235, TOKEN_EXECUTE
236, TOKEN_EXISTS
237, TOKEN_EXIT
238, TOKEN_EXTERNAL
239, TOKEN_FILE
240, TOKEN_FILLFACTOR
241, TOKEN_FOR
242, TOKEN_FROM
243, TOKEN_FUNCTION
244, TOKEN_GOTO
245, TOKEN_GROUP
246, TOKEN_HAVING
247, TOKEN_HOLDLOCK
248, TOKEN_IDENTITY
249, TOKEN_IDENTITYCOL
250, TOKEN_IF
251, TOKEN_IN
252, TOKEN_INDEX
253, TOKEN_INSERT
254, TOKEN_INTERSECT
255, TOKEN_INTO
256, TOKEN_IS
257, TOKEN_KILL
258, TOKEN_LIKE
259, TOKEN_LINENO
260, TOKEN_LOAD
261, TOKEN_TSEQUAL
262, TOKEN_NATIONAL
263, TOKEN_NONCLUSTERED
264, TOKEN_NOT_FOR
265, TOKEN_NULL
266, TOKEN_NULLIF
267, TOKEN_OFF
268, TOKEN_OFFSETS
269, TOKEN_ON
270, TOKEN_LOG_ON
271, TOKEN_OPTION
272, TOKEN_ORDER
273, TOKEN_OVER
274, TOKEN_PLAN
275, TOKEN_PRINT
276, TOKEN_PROCEDURE
277, TOKEN_PUBLIC
278, TOKEN_RAISERROR
279, TOKEN_READTEXT
280, TOKEN_RECONFIGURE
281, TOKEN_RETURN
282, TOKEN_ROLLBACK
283, TOKEN_ROWCOUNT
284, TOKEN_RULE
285, TOKEN_SAVE
286, TOKEN_SELECT
287, TOKEN_SETUSER
288, TOKEN_IDENTITY_INSERT
289, TOKEN_SHUTDOWN
290, TOKEN_STATISTICS
291, TOKEN_TABLE
292, TOKEN_TABLESAMPLE
293, TOKEN_THEN
294, TOKEN_TO
295, TOKEN_TRANSACTION
296, TOKEN_TRIGGER
297, TOKEN_TEXTSIZE
298, TOKEN_TRUNCATE
299, TOKEN_UNIQUE
300, TOKEN_UPDATE
301, TOKEN_UPDATETEXT
302, TOKEN_USEDB
303, TOKEN_VALUES
304, TOKEN_VIEW
305, TOKEN_WAITFOR
306, TOKEN_WHERE
307, TOKEN_WHEN
308, TOKEN_WHILE
309, TOKEN_WRITETEXT
310, TOKEN_CURSOR
311, TOKEN_OF
312, TOKEN_OPEN
313, TOKEN_CURRENT
314, TOKEN_CLOSE
315, TOKEN_DEALLOCATE
316, TOKEN_READ
317, TOKEN_CONSTRAINT
318, TOKEN_PRIMARY
319, TOKEN_KEY
320, TOKEN_REFERENCES
321, TOKEN_CHECK
322, TOKEN_ROWGUIDCOL
323, TOKEN_FOREIGN
324, TOKEN_NOCHECK
325, TOKEN_REPLICATION
326, TOKEN_USER
327, TOKEN_CURRENT_USER
328, TOKEN_SESSION_USER
329, TOKEN_SYSTEM_USER
330, TOKEN_CURRENT_DATE
331, TOKEN_CURRENT_TIME
332, TOKEN_CURRENT_TIMESTAMP
333, TOKEN_DISTRIBUTED
334, TOKEN_TOP
335, TOKEN_PERCENT
336, TOKEN_PROC_SEMI
337, TOKEN_OPENQUERY
338, TOKEN_OPENROWSET
339, TOKEN_OPENDATASOURCE
340, TOKEN_OPENXML
341, TOKEN_COLUMN
342, TOKEN_START_UPDATE
343, TOKEN_CONTAINSTABLE
344, TOKEN_FREETEXTTABLE
345, TOKEN_CONTAINS
346, TOKEN_FREETEXT
347, TOKEN_c_MOVE
348, TOKEN_c_RECEIVE
349, TOKEN_c_GET
350, TOKEN_c_SEND
351, TOKEN_c_ENABLE
352, TOKEN_c_DISABLE
353, TOKEN_c_SERVICE
354, TOKEN_c_LOGIN
355, TOKEN_c_QUEUE
356, TOKEN_c_CERT
357, TOKEN_c_XMLSCHEMA
358, TOKEN_c_SERVER
359, TOKEN_c_INCLUDE
360, TOKEN_c_MASTER
361, TOKEN_c_SYMMETRIC
362, TOKEN_c_SIGNATURE
363, TOKEN_c_ASYMMETRIC
364, TOKEN_c_ASSEMBLY
365, TOKEN_c_NAME
366, TOKEN_c_TYPE
367, TOKEN_c_DIALOG
368, TOKEN_c_CONVERSATION
369, TOKEN_c_THROW
370, TOKEN_BEGIN_CATCH
371, TOKEN_BEGIN_TRY
372, TOKEN_c_NEXTVALUE
373, TOKEN_c_WITHIN_GROUP
374, TOKEN_c_LOG
375, TOKEN_c_COUNTERSIGNATURE
376, TOKEN_c_CUBE
377, TOKEN_c_ROLLUP
378, TOKEN_DOLLAR_PARTITION
379, TOKEN_REVERT
380, TOKEN_c_REVERT
381, TOKEN_MERGE
382, TOKEN_c_USING
383, TOKEN_AUDIT_SPECIFICATION
384, TOKEN_ENCRYPTION_KEY
385, TOKEN_SEMANTICSIMILARITYTABLE
386, TOKEN_SEMANTICKEYPHRASETABLE
387, TOKEN_SEMANTICSIMILARITYDETAILSTABLE
388, TOKEN_WITH_GB_HINT
389, START_LEFT_PAREN_COMPAT_SUBTOKENS
390, TOKEN_LEFT_PAREN_80
391, TOKEN_LEFT_PAREN_90
392, END_LEFT_PAREN_COMPAT_SUBTOKENS
393, START_CREATE_DROP_ALTER_SUBTOKENS
394, TOKEN_s_CDA_TYPE
395, TOKEN_s_CDA_ASSEMBLY
396, TOKEN_s_CDA_AGGREGATE
397, TOKEN_s_CDA_EVENT
398, TOKEN_s_CDA_PARTITION
399, TOKEN_s_CDA_FULLTEXT
400, TOKEN_s_CDA_SERVICE
401, TOKEN_s_CDA_MESSAGE
402, TOKEN_s_CDA_ENDPOINT
403, TOKEN_s_CDA_SYNONYM
404, TOKEN_s_CDA_SEQUENCE
405, TOKEN_s_CDA_LOGIN
406, TOKEN_s_CDA_APPLICATION
407, TOKEN_s_CDA_ROLE
408, TOKEN_s_CDA_QUEUE
409, TOKEN_s_CDA_CONTRACT
410, TOKEN_s_CDA_ROUTE
411, TOKEN_s_CDA_XML
412, TOKEN_s_CDA_REMOTE
413, TOKEN_s_CDA_CERT
414, TOKEN_s_CDA_MASTER
415, TOKEN_s_CDA_SYMMETRIC
416, TOKEN_s_CDA_SIGNATURE
417, TOKEN_s_CDA_CREDENTIAL
418, TOKEN_s_CDA_ASYMMETRIC
419, TOKEN_s_CDA_COUNTER
420, TOKEN_s_CDA_BROKER
421, TOKEN_s_CDA_SESSION
422, TOKEN_s_CDA_NOTIFICATION
423, TOKEN_s_CDA_TARGET
424, TOKEN_s_CDA_SERVER
425, TOKEN_s_CDA_RESOURCE
426, TOKEN_s_CDA_WORKLOAD
427, TOKEN_s_CDA_POOL
428, TOKEN_s_CDA_GOVERNOR
429, TOKEN_s_CDA_SPATIAL
430, TOKEN_s_CDA_SELECTIVE
431, TOKEN_s_CDA_CRYPTOGRAPHIC
432, TOKEN_s_CDA_SEARCH
433, TOKEN_s_CDA_AVAILABILITY
434, TOKEN_s_CDA_COLUMNSTORE
435, TOKEN_s_CDA_AUDIT
436, END_CREATE_DROP_ALTER_SUBTOKENS
437, START_AFTER_END_SUBTOKENS
438, TOKEN_s_AE_CATCH
439, TOKEN_s_AE_CONVERSATION
440, TOKEN_s_AE_TRY
441, END_AFTER_END_SUBTOKENS
442, START_AFTER_WITH_SUBTOKENS
443, TOKEN_s_AW_XMLNAMESPACES
444, TOKEN_s_AW_CHANGE_TRACKING_CONTEXT
445, TOKEN_s_AW_ID
446, END_AFTER_WITH_SUBTOKENS
447, START_AFTER_WITH_EXEC_OPTION_SUBTOKENS
448, TOKEN_s_AWEO_RESULT
449, TOKEN_s_AWEO_RECOMPILE
450, END_AFTER_WITH_EXEC_OPTION_SUBTOKENS
451, START_CREATE_DB_OPT_SUBTOKENS
452, TOKEN_s_CREATEDBOPT_FILESTREAM
453, TOKEN_s_CREATEDBOPT_OTHER
454, END_CREATE_DB_OPT_SUBTOKENS
455, START_ALTER_DB_OPT_SUBTOKENS
456, TOKEN_s_ALTDBOPT_CHANGE_TRACKING
457, TOKEN_s_ALTDBOPT_FILESTREAM
458, TOKEN_s_ALTDBOPT_OTHER
459, TOKEN_s_ALTDBOPT_DIST_POLICY
460, TOKEN_s_ALTDBOPT_HADR
461, TOKEN_s_ALTDBOPT_CONTAINEDDB
462, TOKEN_s_ALTDBOPT_RECOVERY
463, TOKEN_s_ALTDBOPT_QUERY_STORE
464, TOKEN_s_ALTDBOPT_AUTO_CRT_STATS
465, END_ALTER_DB_OPT_SUBTOKENS
466, START_DUMP_OPT_SUBTOKENS
467, TOKEN_s_DUMPOPT_ENCRYPTION
468, TOKEN_s_DUMPOPT_OTHER
469, END_DUMP_OPT_SUBTOKENS
470, START_DUMP_ENCRYPTION_OPT_SUBTOKENS
471, TOKEN_s_DUMPOPT_ENCRYPTION_ALGORITHM
472, TOKEN_s_DUMPOPT_ENCRYPTION_SERVER
473, TOKEN_s_DUMPOPT_ENCRYPTION_CERTIFICATE
474, TOKEN_s_DUMPOPT_ENCRYPTION_ASYMMETRIC
475, END_DUMP_ENCRYPTION_OPT_SUBTOKENS
476, START_LOAD_OPT_SUBTOKENS
477, TOKEN_s_LOADOPT_FILESTREAM
478, TOKEN_s_LOADOPT_OTHER
479, END_LOAD_OPT_SUBTOKENS
480, START_TAB_OPT_NAME_SUBTOKENS
481, TOKEN_s_TABOPTNAME_FILESTREAM_ON
482, TOKEN_s_TABOPTNAME_LOCK_ESCALATION
483, TOKEN_s_TABOPTNAME_FILETABLE_DIRECTORY
484, END_TAB_OPT_NAME_SUBTOKENS
485, START_TAB_LOCK_OPT_SUBTOKENS
486, TOKEN_s_TABLOCKOPT_MAX_DURATION
487, TOKEN_s_TABLOCKOPT_ABORT_AFTER_WAIT
488, END_TAB_LOCK_OPT_SUBTOKENS
489, START_INDEX_SORT_OPT_SUBTOKENS
490, TOKEN_s_IDXSORTOPT_SORTED_DATA
491, TOKEN_s_IDXSORTOPT_SORTED_DATA_REORG
492, END_INDEX_SORT_OPT_SUBTOKENS
493, START_OPT_STORAGE_ID_SUBTOKENS
494, TOKEN_s_OSI_SPARSE
495, TOKEN_s_OSI_COLUMN_SET
496, END_OPT_STORAGE_ID_SUBTOKENS
497, START_IND_OPTIONS_SUBTOKENS
498, TOKEN_s_IO_DATACOMPRESSION
499, TOKEN_s_IO_MAXDOP
500, TOKEN_s_IO_STATSONLY
501, TOKEN_s_IO_ONOFFOPTION
502, TOKEN_s_IO_DISTRIBUTION
503, TOKEN_s_IO_BUCKETCOUNT
504, TOKEN_s_IO_ONLINE
505, END_IND_OPTIONS_SUBTOKENS
506, START_ALTTAB_ACTIONS_SUBTOKENS
507, TOKEN_s_ALTTAB_DISABLE_ENABLE
508, TOKEN_s_ALTTAB_REBUILD
509, TOKEN_s_ALTTAB_SWITCH
510, END_ALTTAB_ACTIONS_SUBTOKENS
511, START_SEQUENCE_OPTIONS_SUBTOKENS
512, TOKEN_s_seq_RESTART
513, TOKEN_s_seq_START
514, TOKEN_s_seq_INCREMENT
515, TOKEN_s_seq_MINVALUE
516, TOKEN_s_seq_MAXVALUE
517, TOKEN_s_seq_CYCLE
518, TOKEN_s_seq_CACHE
519, TOKEN_s_seq_NO
520, END_SEQUENCE_OPTIONS_SUBTOKENS
521, START_ALTTAB_ENABLE_DISABLE_SUBTOKENS
522, TOKEN_s_ALTTAB_EN_CHANGE_TRACKING
523, TOKEN_s_ALTTAB_EN_FILETABLE_NAMESPACE
524, END_ALTTAB_ENABLE_DISABLE_SUBTOKENS
525, START_AFFINITY_TYPE_SUBTOKENS
526, TOKEN_s_aff_CPU
527, TOKEN_s_aff_NUMA
528, END_AFFINITY_TYPE_SUBTOKENS
529, START_POOL_AFFINITY_TYPE_SUBTOKENS
530, TOKEN_s_paff_SCHED
531, TOKEN_s_paff_NUMA
532, END_POOL_AFFINITY_TYPE_SUBTOKENS
533, START_ALTER_SERVER_TYPE_SUBTOKENS
534, TOKEN_s_altserv_AUDIT
535, TOKEN_s_altserv_CONFIG
536, TOKEN_s_altserv_ROLE
537, END_ALTER_SERVER_TYPE_SUBTOKENS
538, START_FULLTEXT_SEARCH_SUBTOKENS
539, TOKEN_s_FTS_CATALOG
540, TOKEN_s_FTS_CHANGE_TRACKING
541, TOKEN_s_FTS_POPULATION
542, TOKEN_s_FTS_STOPLIST
543, TOKEN_s_FTS_NO
544, TOKEN_s_FTS_SEARCH
545, END_FULLTEXT_SEARCH_SUBTOKENS
546, START_FTS_PROPERTY_SUBTOKENS
547, TOKEN_s_FP_PROPERTY
548, TOKEN_s_FP_LIST
549, END_FTS_PROPERTY_SUBTOKENS
550, START_AFTER_FTS_WITH_SUBTOKENS
551, TOKEN_s_AFW_PROPERTY_SET_GUID
552, TOKEN_s_AFW_PROPERTY_INT_ID
553, TOKEN_s_AFW_PROPERTY_DESCRIPTION
554, END_AFTER_FTS_WITH_SUBTOKENS
555, START_CREATE_USER_WITH_SUBTOKENS
556, TOKEN_s_CUW_PASSWORD
557, TOKEN_s_CUW_PROPERTY
558, END_CREATE_USER_WITH_SUBTOKENS
559, START_ALTER_USER_WITH_SUBTOKENS
560, TOKEN_s_AUW_PASSWORD
561, TOKEN_s_AUW_PROPERTY
562, TOKEN_s_AUW_SID
563, END_ALTER_USER_WITH_SUBTOKENS
564, START_AG_REPLICA_OPTION_SUBTOKENS
565, TOKEN_s_AG_ROLE_AGNOSTIC_OPTION
566, TOKEN_s_AG_ROLE_SPECIFIC_OPTION
567, END_AG_REPLICA_OPTION_SUBTOKENS
568, START_ALTER_SERVER_CONFIG_SET_SUBTOKENS
569, TOKEN_s_altserv_config_set_PROCESS
570, TOKEN_s_altserv_config_set_FAILOVER
571, TOKEN_s_altserv_config_set_DIAGNOSTICS
572, TOKEN_s_altserv_config_set_HADR
573, TOKEN_s_altserv_config_set_BUFFER_POOL_EXTENSION
574, END_ALTER_SERVER_CONFIG_SET_SUBTOKENS
575, START_ALTER_SERVER_CONFIG_SET_DIAG_LOG_SUBTOKENS
576, TOKEN_s_altserv_config_set_diaglog_PATH
577, TOKEN_s_altserv_config_set_diaglog_MAX_SIZE
578, TOKEN_s_altserv_config_set_diaglog_MAX_FILES
579, TOKEN_s_altserv_config_set_diaglog_ON
580, TOKEN_s_altserv_config_set_diaglog_OFF
581, END_ALTER_SERVER_CONFIG_SET_DIAG_LOG_SUBTOKENS
582, START_ALTER_SERVER_CONFIG_SET_HADR_CLUSTER_SUBTOKENS
583, TOKEN_s_altserv_config_set_hadr_cluster_CONTEXT
584, END_ALTER_SERVER_CONFIG_SET_HADR_CLUSTER_SUBTOKENS
585, START_OVER_CLAUSE_SUBTOKENS
586, TOKEN_s_PARTITION
587, TOKEN_s_UNBOUNDED
588, END_OVER_CLAUSE_SUBTOKENS
589, START_AFTER_BEGIN_SUBTOKENS
590, TOKEN_s_AB_ATOMIC
591, END_AFTER_BEGIN_SUBTOKENS
592, START_FILESTREAM_DB_OPT_SUBTOKENS
593, TOKEN_s_FSD_NON_TRANSACTED_ACCESS
594, TOKEN_s_FSD_DIRECTORY_NAME
595, END_FILESTREAM_DB_OPT_SUBTOKENS
596, START_CREATE_TAB_OPT_SUBTOKENS
597, TOKEN_s_CTO_FILESTREAM_ON
598, TOKEN_s_CTO_TEXTIMAGE_ON
599, TOKEN_s_CTO_FEDERATED
600, END_CREATE_TAB_OPT_SUBTOKENS
601, START_CREATE_TAB_WITH_OPT_SUBTOKENS
602, TOKEN_s_CTW_DATA_COMPRESSION
603, TOKEN_s_CTW_FFT_FILETABLE_DIRECTORY
604, TOKEN_s_CTW_FFT_COLLATE_FILENAME
605, TOKEN_s_CTW_FFT_PRIMARY_KEY_CONSTRAINT_NAME
606, TOKEN_s_CTW_FFT_STREAMID_UNIQUE_CONSTRAINT_NAME
607, TOKEN_s_CTW_FFT_FULLPATH_UNIQUE_CONSTRAINT_NAME
608, TOKEN_s_CTW_MEMORY_OPTIMIZED
609, TOKEN_s_CTW_DURABILITY
610, END_CREATE_TAB_WITH_OPT_SUBTOKENS
611, START_OPT_SXI_PATH_KIND_SUBTOKENS
612, TOKEN_s_SXI_XQUERY
613, TOKEN_s_SXI_SQL
614, END_OPT_SXI_PATH_KIND_SUBTOKENS
615, START_OPT_SXI_PATH_OPTION_SUBTOKENS
616, TOKEN_s_SXI_MAXLENGTH
617, TOKEN_s_SXI_SINGLETON
618, END_OPT_SXI_PATH_OPTION_SUBTOKENS
619, START_IN_INLINE_INDEX_SYNTAX_SUBTOKENS
620, TOKEN_s_IIIS_HASH
621, TOKEN_s_IIIS_FILESTREAM_ON
622, END_IN_INLINE_INDEX_SYNTAX_SUBTOKENS
623, TOKEN_LEADING_DOT_NUMERIC
624, TOKEN_TRAILING_DOT_NUMERIC
625, TOKEN_EMBEDED_DOT_NUMERIC
626, START_MISSING_TOKENS
627, TOKEN_MISSING_ON
628, TOKEN_MISSING_RIGHT_PAREN
629, TOKEN_MISSING_WHEN
630, TOKEN_MISSING_THEN
631, TOKEN_MISSING_END
632, TOKEN_MISSING_EQUAL
633, TOKEN_MISSING_AND
634, TOKEN_MISSING_STRING_VAR
635, TOKEN_MISSING_LITERAL
636, TOKEN_MISSING_SET
637, TOKEN_MISSING_SQLID
638, TOKEN_MISSING_INSERT_SOURCE
639, TOKEN_MISSING_COMMA
640, TOKEN_MISSING_VARIABLE
641, END_MISSING_TOKENS
642, LEX_ERROR
643, TOKEN_BEGIN_CS
644, TOKEN_END_CS
645, START_DEPRECATED_TOKENS
646, TOKEN_X_DUMP
647, TOKEN_X_LOAD
648, TOKEN_X_TRANSACTION
649, END_DEPRECATED_TOKENS
650, maxParseToken
651, LEX_WHITE
652, LEX_END_OF_LINE_COMMENT
653, LEX_MULTILINE_COMMENT
654, LEX_BATCH_SEPERATOR
655, SQL_CMD_MODE_TOKEN
656, accumulators
657, LEX_ACCUMULATE_ID
658, LEX_ACCUMULATE_STRING
659, LEX_ACCUMULATE_BINARY
660, LAST_TOKEN

Open in new window

louisfrCommented:
Getting a list of all values is certainly informative but you don't need to do that to match one numeric value with the corresponding Tokens value.

You can cast it. Not sure the PowerShell syntax is right but it should be close to this:
$token = [Microsoft.SqlServer.Management.SqlParser.Parser.Tokens]$scanner.GetNext()

Open in new window

huangs3Author Commented:
I got this working for me by casting a Tokens constant into integer and compare with the GetNext() result.
int]$t = $scanner.GetNext([ref]$state, [ref]$start, [ref]$end, [ref]$isPairMatch, [ref]$isExecAutoParamHelp)
if ($t -eq [int][Microsoft.SqlServer.Management.SqlParser.Parser.Tokens]::TOKEN_DROP){
                Write-Output "error!!!!!!!!!!!!"
               # break
            }

Open in new window

huangs3Author Commented:
MlandaT:

Using code to enumerate is a good idea, but is there any official documentation? The way we get it work in this state looks like hacking, and I am trying to do it in a more straight forward way.
huangs3Author Commented:
Louisfr:

casting from integer to Token will not work, but another way around works as the code I posted.
MlandaTCommented:
If I understand correctly, the objective here is addressing this: When I get the returned integer value I found that I don't know what it means, and I cannot find any documentation mapping this integer value into meaningful Microsoft.SqlServer.Management.SqlParser.Parser.Tokens value.

Since Microsoft.SqlServer.Management.SqlParser.Parser.Tokens is an enum (documented here), and there isn't proper documentation, I'd go with GetNext method as shown by Louis.

Here is a complete PowerShell example:
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Management.SqlParser") | Out-Null
$ParseOptions = New-Object Microsoft.SqlServer.Management.SqlParser.Parser.ParseOptions
$ParseOptions.BatchSeparator = 'GO'

$Parser = new-object Microsoft.SqlServer.Management.SqlParser.Parser.Scanner($ParseOptions)
$Sql = "Create Procedure MyProc as Select top(10) * from dbo.Table"
$Parser.SetSource($Sql,0)
$Token=[Microsoft.SqlServer.Management.SqlParser.Parser.Tokens]::TOKEN_SET
$Start =0
$End = 0
$State =0 
$IsEndOfBatch = $false
$IsMatched = $false
$IsExecAutoParamHelp = $false
while(($Token = $Parser.GetNext([ref]$State ,[ref]$Start, [ref]$End, [ref]$IsMatched, [ref]$IsExecAutoParamHelp ))-ne [Microsoft.SqlServer.Management.SqlParser.Parser.Tokens]::EOF) {
    try{
        ($TokenPrs =[Microsoft.SqlServer.Management.SqlParser.Parser.Tokens]$Token) | Out-Null
        $TokenPrs
        
        $Sql.Substring($Start,($end-$Start)+1)
    }catch{
        $TokenPrs = $null
    }    
}

Open in new window

huangs3Author Commented:
MlandaT  is the most to the point and find a way to get what the returned numbers means, I think this is the best solution for the current condition.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.