I have a sql dump file from MySQL that I use to create SQL Server (2005) tables out of.
I need to change the column declarations that are greater than varchar(8000), the max for sql server 2005, to varchar(max).
I am using a Visual Basic script to parse through the dump file and make these changes. It just looks at the whole file as a string. I only want to change if the number is greater than 8000, but I don't know how to do this. Is there a way to check what that number is inside of the declaration and change it? I've made a regular expression to find the number inside the declaration. But I don't know of a way to say:
For all strings that match varchar(int>8000), change to varchar(max).
Regex to match a number greater than (or equal to) 8000: /^([89]\\d{3}|\\d{5,})$/
Where /
is a delimiter for the regex, followed by start ( ^
) followed by either ( (...|...)
) an 8 or 9 and 3 more digits ( [89]\\d{3}
) or five or more digits ( \\d{5,}
) followed by the end of the string ( $
) and regex delimiter ( /
).
To use in your context, something like this should do it...
/varchar\(\s*([89]\d{3}|\d{5,})\s*\)/
This has escaped braces \\(...\\)
and optional spaces \\s*
and your keyword varchar
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.