April 5, 2004 at 5:50 am
Hi Everyone,
First I need to say that i'm quite new to SQL, so please keep the eyplanations "Dummy-Compatible" 🙂
I have a small tool running called "Serial Logger Service" http://www.muconsulting.com. I listens to a serial port and writes the received data into a TXT-file. The Data is always 150 characters long. In that tool i can also give a SQL-Statement, for example insert into "table".......
The thing is, i cannot get it to split the Data over multiple Columns. I've tried the Substring (?,1,15), but it lets me execute only one statement.
The data which needs to go into the columns is always the same number of characters.
A Friend of mine told me to do this via a Stored procedure (Serial-Logger can call procedures and gives the data as first variable), but i dont seem to be able to get the syntax right. 🙁
Can anyone help me on this?
April 5, 2004 at 6:52 am
Not sure what you really after, but this procedure
CREATE PROCEDURE insert_data @input char(150)
AS
INSERT
INTO [yourtable]
(col1, col2, col3)
VALUES
(
SUBSTRING(@input,1,50),
SUBSTRING(@input,51,50),
SUBSTRING(@input,101,50)
)
GO
will split 150 character input into 3, 50 character columns.
Do not know the softeware you are using but assuming that you call the procedure like this
exec insert_data '?'
Far away is close at hand in the images of elsewhere.
Anon.
April 5, 2004 at 9:34 am
Thanks for the Quick answer. It works just like a charm!
Thanks for your help.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply