Solved

Substring issues

Posted on 2006-11-20
2
330 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]
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 500 total points
ID: 17981346
The syntax is fine, except you have a single quotation mark before "prefix"
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
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…
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.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

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