Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

String

Posted on 1998-09-04
7
Medium Priority
?
241 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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
What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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.

730 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