?
Solved

Substring issues

Posted on 2006-11-20
2
Medium Priority
?
366 Views
Last Modified: 2012-05-05
I have been trying to combine 2 fields together.  I have tried several different permutations of the substring command and am having no luck.  

I have defines all fields involved in this command as char.  Here is what I am trying:

insert
into lcs_out
substring('prefix,1,2)+substring(class_subject_cd,1,10)as Unique_id
from temp_table

this should be easy, but I am knocking my head against the wall.

any advice is appreciated.  

0
Comment
Question by:ericsberr
[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
2 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17981345
>I have been trying to combine 2 fields together.

possibly you want to update an existing table/field/row:
update temp_table
set lcs_out =  substring(prefix,1,2)+substring(class_subject_cd,1,10)

or update another table:
update lcs_out
set uniqueid=  substring(t.prefix,1,2)+substring(t.class_subject_cd,1,10)
from  lcs_out l
join temp_table t
  on <some join condition>

0
 
LVL 9

Accepted Solution

by:
gpompe earned 2000 total points
ID: 17981346
The syntax is fine, except you have a single quotation mark before "prefix"
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
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, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Suggested Courses

743 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