Solved

String

Posted on 1998-09-04
7
235 Views
Last Modified: 2010-03-19
I know this maybe a dumb question but the word 'STRING'confuses me in SQL. What is a 'STRING'in SQL, is it just a word discribing a data type or is it a system word?
0
Comment
Question by:bufordk
  • 4
  • 2
7 Comments
 
LVL 2

Expert Comment

by:odessa
ID: 1089927
String is not a data type or System word, it only describe String as String
0
 
LVL 5

Accepted Solution

by:
mayhew earned 50 total points
ID: 1089928
As Odessa suggested, string is not a datatype.  What it refers to is any character data like data of types char and varchar.  Or a string could be a literal that you use, for example, in a where clause.  Eg.

SELECT * FROM <table> WHERE <name> = 'buford'

The 'buford' could be considered a string.

It also refers to a set of 'string functions'.  These are functions you can use to manipulate data of types char, varchar, binary and varbinary.  I've never personally used these functions for binary data, but I know they will work

An example would be the substring function which (as you may know) finds a sub-string in string str that begins on position m and has a length of n.

SUBSTRING(str,m,n)

str is a string and either of the following function calls would be valid:

SUBSTRING('buford',3,4)
SUBSTRING(<col_name>,3,4)

'buford' and a column from a table of type char (for example) would both be considered strings.

You can also concatenate strings with a '+' sign.  For example:

SELECT <name> + ' is smart' FROM <table>

Hope that's helpful!   :)
0
 

Author Comment

by:bufordk
ID: 1089929
Thank You for your helpful answer. Just one more thing to maybe clarify things.
when i execute

sp_addtype zipcode, 'char(10)'  

 vs.
                       
sp_addtype longstring, 'varchar(60)'

is 'longstring' discribing varchar(60) like 'zipcode' discribes char(10) the user datatype?
i understand substrings and etc. but that word '%string' in a user datatype scares me.
Maybe i'm just looking to deep into the word and not seeing a simple answer.
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 5

Expert Comment

by:mayhew
ID: 1089930
Yes, if you execute

sp_addtype longstring, 'varchar(60)'

you are going to have a column named longstring.  I think I understand your concern.  SQL Server will give you an error if you use any kind of reserved word for a column name.

In SQL Server, the word 'string' is more of a concept than datatype.  You should have no trouble naming anything %string%.

Let me know if you have any further questions.  :)
0
 
LVL 5

Expert Comment

by:mayhew
ID: 1089931
Sorry, I meant to say you would have a datatype named longstring, not a column.
0
 

Author Comment

by:bufordk
ID: 1089932
thank you for your clear and understandable answer.
0
 
LVL 5

Expert Comment

by:mayhew
ID: 1089933
Glad I could help!   :)
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question