Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

Sql server query syntax left() function

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
gbnorton
Asked:
gbnorton
1 Solution
 
DcpKingCommented:
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
 
gbnortonAuthor Commented:
Thank you.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now