Solved

Sql server query syntax left() function

Posted on 2013-10-22
2
232 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
[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 16

Accepted Solution

by:
DcpKing earned 500 total points
ID: 39591003
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
ID: 39591079
Thank you.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

617 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