July 12, 2016 at 2:08 pm
In sql server 2012, I would like to know what datatype can hold the maximum number of characters? (The datatype will need to contain letters, numbers, and potentially any special characters.)
In addition, to insert, update and delete data from this datatype, is there any special t-sql that is required?
I am asking this question since I know sql server 2000 had the blob datatype and that required some 'special' t-sql to update the data in this data type.
In addition, would you tell me what other few datatypes are available and what the maximum number of characters each datatype can hold?
**Note, I do not need any data that contains 'N' values since I am only working with data where people speak English.
July 12, 2016 at 2:26 pm
I say you could go with varchar(MAX). "max" for varchar(max) indicates a maximum storage of 2^31-1 bytes. SQL 2012 does support text datatype, MSDN recommends using varchar(max) instead.
July 12, 2016 at 3:34 pm
I wouldn't use TEXT. It's on the deprecation list.
Here are the data types in the SQL Server documentation. You're describing what is CHAR, VARCHAR or TEXT, only you shouldn't use TEXT. You can click on each of the data types in the list to get the details of the type.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
July 12, 2016 at 3:50 pm
I agree with Grant 100000% on not using text. My only change would one of not being as subtle as "you shouldn't use the text datatype". I would say you need to run away from that datatype like it is an atomic bomb. It is awful to work with, you can't search it unless you cast it first. You can't index it. The only good about it is that I have never had an issue with inplace data change to a varchar. 😛
Many times I see tables using varchar(max) but it is serious overkill. The columns contain 1-2k characters. The varchar datatype can hold up to 8,000 characters which is an awful lot of information. Unless you actually need to store that much information you don't need the max datatype.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
July 12, 2016 at 5:32 pm
wendy elizabeth (7/12/2016)
In sql server 2012, I would like to know what datatype can hold the maximum number of characters? (The datatype will need to contain letters, numbers, and potentially any special characters.)In addition, to insert, update and delete data from this datatype, is there any special t-sql that is required?
I am asking this question since I know sql server 2000 had the blob datatype and that required some 'special' t-sql to update the data in this data type.
In addition, would you tell me what other few datatypes are available and what the maximum number of characters each datatype can hold?
**Note, I do not need any data that contains 'N' values since I am only working with data where people speak English.
My recommendation would be to stop whatever you're doing and read up on two things from "Books Online"...
1. All datatypes
2. All functions
You may not use all of either but 1) you'll learn how to find the answers to such basic questions and 2) you'll at least be familiar to the point of knowing something is at least possible.
--Jeff Moden
Change is inevitable... Change for the better is not.
July 12, 2016 at 11:35 pm
text datatype is supported in SQL 2012 but will be deprecated in future versions.
alternative is to use varchar(max) and if you need multilingual support use nvarchar(max) datatype.
Thanks,
Durga
July 13, 2016 at 7:18 am
durga.palepu (7/12/2016)
text datatype is supported in SQL 2012 but will be deprecated in future versions.alternative is to use varchar(max) and if you need multilingual support use nvarchar(max) datatype.
Thanks,
Durga
Actually it has been deprecated since SQL 2005. They should have removed it by now but for some reason it is still around.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
July 13, 2016 at 7:40 am
Sean,
Don't some of the Internal Diagnostic views still use TEXT data types or have they all been changed to (n)varchar(max) datatypes?
I also believe that when you pipe an SQL trace log into a table rather than file the TEXTDATA column is classified as an NTEXT
_________________________________________________________________________
SSC Guide to Posting and Best Practices
July 13, 2016 at 7:45 am
durga.palepu (7/12/2016)
text datatype is supported in SQL 2012 but will be deprecated in future versions.alternative is to use varchar(max) and if you need multilingual support use nvarchar(max) datatype.
Thanks,
Durga
Yeah, trace is still there too. Wish they would clean out some of the stuff they tell us they're going to clean out.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
July 13, 2016 at 8:15 am
Jason-299789 (7/13/2016)
Sean,Don't some of the Internal Diagnostic views still use TEXT data types or have they all been changed to (n)varchar(max) datatypes?
I also believe that when you pipe an SQL trace log into a table rather than file the TEXTDATA column is classified as an NTEXT
Yes I believe some of them still do. This is probably why they haven't actually removed it, because they can't bother to fix their own code.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
July 13, 2016 at 8:20 am
Sean Lange (7/13/2016)
Jason-299789 (7/13/2016)
Sean,Don't some of the Internal Diagnostic views still use TEXT data types or have they all been changed to (n)varchar(max) datatypes?
I also believe that when you pipe an SQL trace log into a table rather than file the TEXTDATA column is classified as an NTEXT
Yes I believe some of them still do. This is probably why they haven't actually removed it, because they can't bother to fix their own code.
Thanks for the clarification.
What Microsoft not removing depreciated features in their own code, I'm shocked!!!!! :crazy:
_________________________________________________________________________
SSC Guide to Posting and Best Practices
July 13, 2016 at 3:23 pm
What other data type would you recommend? That is large but not as large as varchar(max) is?
July 13, 2016 at 3:29 pm
wendy elizabeth (7/13/2016)
What other data type would you recommend? That is large but not as large as varchar(max) is?
Define large. A varchar can be as large as varchar(8000). That is quite a bit of data. If you need more than 8,000 characters you would need to use varchar(max).
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
July 13, 2016 at 3:41 pm
wendy elizabeth (7/13/2016)
What other data type would you recommend? That is large but not as large as varchar(max) is?
I'm curious now, what are you trying to store? And which data type is not large enough?
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 14 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply