July 19, 2018 at 1:15 pm
Hello experts,
Following the code sample at this link:
https://stackoverflow.com/questions/8976414/get-structure-of-temp-table-like-generate-sql-script-and-clear-temp-table-for
I ran this kind of code to get the structure of my temp table:select *into #myTempTable -- creates a new temp table
from tMyTable -- some table in your database
exec tempdb..sp_help '#myTempTable'
Most of it makes sense to me, but a few columns have this for the varchar data type in them:
varchar no -1
Does anyone know what -1 means? The columns all have integer data in them, so maybe this is sometimes what happens when integer data gets tagged as varchar?
Thanks for any help!
- webrunner
-------------------
A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
July 19, 2018 at 1:22 pm
That means VARCHAR(MAX) I guess.
See here for details,
https://www.sqlservercentral.com/Forums/Topic647815-145-1.aspx
July 19, 2018 at 1:25 pm
To confirm, yes, the length -1 is used to designate the MAX data type: varchar(max), nvarchar(max), varbinary(max), and xml.
July 19, 2018 at 1:26 pm
Here is the information on sys.types:
https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-types-transact-sql?view=sql-server-2017
July 19, 2018 at 1:31 pm
Lynn Pettis - Thursday, July 19, 2018 1:26 PMHere is the information on sys.types:
https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-types-transact-sql?view=sql-server-2017
Thanks, Lynn!! That is a cool table. I never knew it existed.
- webrunner
-------------------
A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply