Skip to main content

Parse text field in sql server

Parsing TEXT field with Long String

ALTER PROCEDURE [dbo].[DrawMap_KMLImport]
@ProcedureID int,
@ProjectID int,
@Shape varchar(30) = null,
@ObjName varchar(100) = null,
@Notes varchar(1000) = null,
@Allcoords text = null,
@Fillcolor int = null,
@ForeColor int = null

AS
declare @selectByte int
declare @coords varchar(7600)
declare @startI int
set @selectByte = 7600
if @ProcedureID =0
begin


if right(@coords,1) <> ' '
set @coords = @coords + ' '
declare @libID integer
declare @objID varchar(40)
if @shape = 'point'
set @libID = 58
else if @shape = 'polyline'
set @libID = 32
else
set @libID = 30
set @objID = NEWID()
insert into drawmap_objects (ObjID, objName, ProjectID, libID, visible, fillcolor, forecolor)
values(@objID, @objName, @projectID, @libID, 1, @fillcolor, @forecolor)

declare @latlong varchar(30)
declare @long varchar(30)
declare @lat varchar(30)
declare @index int
declare @pointID varchar(40)
declare @i int
set @i = 0
set @startI = 1
while @startI + @selectByte - 1 <= datalength(@Allcoords) begin set @coords = substring(@Allcoords, @startI, @selectByte) WHILE CHARINDEX(',0 ',@coords) > 0
BEGIN
set @i = @i + 1
set @index = CHARINDEX(',0 ',@coords)
SELECT @latlong = ltrim(rtrim(SUBSTRING(@coords,1,@index -1)))
select @long = substring(@latlong, 1, CHARINDEX(',',@latlong)-1)
select @lat = substring(@latlong, CHARINDEX(',',@latlong)+1, datalength(@latlong))

set @pointID = NEWID()
insert into drawmap_point(pointID, objID, pointindex, lat, long)
values(@pointID, @objID, @i,@lat, @long)

SELECT @coords = SUBSTRING(@coords,@index+3,DATALENGTH(@coords))
END
set @startI = @startI + @selectByte
end
set @coords = @coords + substring(@Allcoords, @startI, datalength(@Allcoords) - (@starti) + 1)

WHILE CHARINDEX(',0 ',@coords) > 0
BEGIN
set @i = @i + 1
set @index = CHARINDEX(',0 ',@coords)
SELECT @latlong = ltrim(rtrim(SUBSTRING(@coords,1,@index -1)))
select @long = substring(@latlong, 1, CHARINDEX(',',@latlong)-1)
select @lat = substring(@latlong, CHARINDEX(',',@latlong)+1, datalength(@latlong))

set @pointID = NEWID()
insert into drawmap_point(pointID, objID, pointindex, lat, long)
values(@pointID, @objID, @i,@lat, @long)

SELECT @coords = SUBSTRING(@coords,@index+3,DATALENGTH(@coords))
END

return
end

Comments

Popular posts from this blog

Android Developer Learning Resource

Developing In Eclipse, with ADT http://developer.android.com/guide/developing/eclipse-adt.html Signing Your Applications http://developer.android.com/guide/publishing/app-signing.html Compile and sign with Eclipse ADT To create a signed and aligned .apk in Eclipse: Select the project in the Package Explorer and select File > Export . Open the Android folder, select Export Android Application, and click Next . The Export Android Application wizard now starts, which will guide you through the process of signing your application, including steps for selecting the private key with which to sign the .apk (or creating a new keystore and private key). Complete the Export Wizard and your application will be compiled , signed , aligned , and ready for distribution. DroidDraw is a graphical user interface (GUI) builder for the Android platform http://code.google.com/p/droiddraw/

RMO programming

http://msdn2.microsoft.com/en-us/library/ms151819.aspx SQL Server Express does not include SQL Server Agent, which is typically used to run replication agents. If you use a pull subscription (in which agents run at the Subscriber), you must synchronize the subscription using Windows Synchronization Manager or RMO. For more information, see the following topics: Windows Synchronization Manager RMO programming: How to: Synchronize a Pull Subscription (RMO Programming) Replication does not support the Run As Normal User (RANU) feature of SQL Server Express. For more information about this feature, see the SQL Server Express documentation.