Solved

Substring issues

Posted on 2006-11-20
2
307 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
2 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
>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 500 total points
Comment Utility
The syntax is fine, except you have a single quotation mark before "prefix"
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
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…
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.
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.

772 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

10 Experts available now in Live!

Get 1:1 Help Now