Solved

Sql server query syntax left() function

Posted on 2013-10-22
2
217 Views
Last Modified: 2013-10-22
My goal:  Select all records from table Part_Serial_Number, column Part_No,  where the first character of Part_No = "P" and create a new table PS_Serial_Number with those records.

My current query fails with "Invalid column name "P":

SELECT Part_No
INTO PS_Serial_Number
FROM  Part_Serial_Number
WHERE (LEFT(Part_Serial_Number.Part_No,1)) = "P"

Part_No is type nvarchar

I know this must be obvious, but I'm floundering...

Thanks,
Brooks
0
Comment
Question by:gbnorton
2 Comments
 
LVL 16

Accepted Solution

by:
DcpKing earned 500 total points
Comment Utility
select *
from Part_Serial_Number
into PS_Serial_Number
where len(Part_No) >= 1
and substring(Part_No, 1, 1) = 'P'

(Strings are delimited by ticks, not quotes!)

hth

Mike
0
 

Author Closing Comment

by:gbnorton
Comment Utility
Thank you.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

744 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

18 Experts available now in Live!

Get 1:1 Help Now