Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Sql server query syntax left() function

Posted on 2013-10-22
2
Medium Priority
?
234 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 2000 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

721 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