Solved

String

Posted on 1998-09-04
7
233 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how the fundamental information of how to create a table.

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now