Stack Exchange
INSERT in stored proc after Parsing a data
I would like to ask for help on how to outright insert a parsed data which i parsed using select.
Here's my code guys
STORED PROCEDURE
USE [SMSGPS]
GO
/****** Object:  StoredProcedure [dbo].[ParsingProcedureR10V2]    Script Date: 11/12/2014 1:08:10 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[ParsingProcedureR10V2]
@ProductCode VARCHAR(500)
AS
SET NOCOUNT ON;
SELECT [Account]  = LEFT(@ProductCode,CHARINDEX(',',@ProductCode) - 1),
   [date&time] = SUBSTRING(@ProductCode, 27, 12),
   [Status] = SUBSTRING(@ProductCode, 40, 1),
   [Lat] = SUBSTRING(@ProductCode, 42, 10),
   [Long] = SUBSTRING(@ProductCode, 53, 11),
   [Speed] = SUBSTRING(@ProductCode, 65, 4),
       [HDOP] = SUBSTRING(@ProductCode, 74, 3),
   [statcode] = SUBSTRING(@ProductCode, 78, 8),
   [ENGINE] = SUBSTRING(@ProductCode, 78, 1),
   [KM2] = SUBSTRING(@ProductCode, 123,11);

Thank you for all those who will help me in advance and thanks for the site for letting me post.

What do you mean by outright insert.?

insert into tablename(col1,col2,..)select col_parsed1,col_parsed2..

do u have a table with columns Account, date&time, Status..etc.,

Yes Vera I do have a table ready with the columns same as the parsed data.

Try the answer I posted. Just added insert query along with select query.

Had you find the answer useful.

Try this:  Replace the TABLENAME with your table name and run it.
USE [SMSGPS]
GO
/****** Object:  StoredProcedure [dbo].[ParsingProcedureR10V2]    Script Date: 11/12/2014 1:08:10 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[ParsingProcedureR10V2]
@ProductCode VARCHAR(500)
AS
SET NOCOUNT ON; 

INSERT INTO TABLENAME (Account, date&time, Status, Lat, Long, Speed, HDOP,  
      statcode, ENGINE, KM2) 
SELECT [Account]  = LEFT(@ProductCode,CHARINDEX(',',@ProductCode) - 1),
   [date&time] = SUBSTRING(@ProductCode, 27, 12),
   [Status] = SUBSTRING(@ProductCode, 40, 1),
   [Lat] = SUBSTRING(@ProductCode, 42, 10),
   [Long] = SUBSTRING(@ProductCode, 53, 11),
   [Speed] = SUBSTRING(@ProductCode, 65, 4),
   [HDOP] = SUBSTRING(@ProductCode, 74, 3),
   [statcode] = SUBSTRING(@ProductCode, 78, 8),
   [ENGINE] = SUBSTRING(@ProductCode, 78, 1),
   [KM2] = SUBSTRING(@ProductCode, 123,11);

