| Author |
Topic |
|
desi_nerd
Starting Member
2 Posts |
Posted - 2005-09-08 : 11:00:18
|
| Iam trying to create a geo-database.For that i need to have a spatial data type called polygon which takes in values as int. so it can be declared as:POLYGON(0 0, 100 0, 100 100, 0 100, 0 0)How do i do that.plz help.---Iam not real any moreIam just an Illusion--- |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
ryanston
Microsoft SQL Server Product Team
89 Posts |
Posted - 2005-09-08 : 13:22:06
|
| Not really doable in SQL 2000 without an add-on from a 3rd party company. In SQL Server 2005 you can create a user-defined type in a CLR language like C# and use it in the database.Thanks,----------------------Ryan StonecipherDeveloper, Microsoft SQL Server Storage Engine, DBCC(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.) |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2005-09-08 : 14:25:41
|
>>...or is that redrum? As a wacky workaround, until you upgrade to 2005, you could use a binary value (4 bytes per int, or 2 bytes for smallint, etc). Then use a function to convert your Polygon to the binary value and a view to get the parts back out. ie here is a three part version (binary(12) - 4 byte ints as each part):set nocount ongo--function to convert multiple integers to a binary value--each integer is assigned to a pre-designated position in--the binary valuecreate function dbo.fnSetPolygon(@p1 int, @p2 int, @p3 int)returns binary(12)asbegin declare @polygon binary(12) select @polygon = convert(binary(12), convert(varchar,convert(binary(4), @p1)) + convert(varchar,convert(binary(4), @p2)) + convert(varchar,convert(binary(4), @p3))) return @polygonendgocreate table Polygons_t (polygonid int identity(1,1) primary key ,Polygon binary(12))go--a view extracts the individual parts of the binary valuecreate view dbo.Polygons_vas select Polygonid ,convert(int,substring(polygon,1,4)) p1 ,convert(int,substring(polygon,5,4)) p2 ,convert(int,substring(polygon,9,4)) p3 from Polygons_tgoinsert Polygons_t (polygon)select dbo.fnSetPolygon(100,100,100) union allselect dbo.fnSetPolygon(200,200,200)select * from Polygons_tselect * from Polygons_vif object_id('dbo.fnSetPolygon') > 0 drop function dbo.fnSetPolygongoif object_id('dbo.Polygons_v') > 0 drop view dbo.Polygons_vgoif object_id('dbo.Polygons_t') > 0 drop table Polygons_tgoBe One with the OptimizerTG |
 |
|
|
ryanston
Microsoft SQL Server Product Team
89 Posts |
Posted - 2005-09-08 : 15:26:55
|
quote: Originally posted by X002548 OMGThere must be some slack time out in redmond...or is that redrum?Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Slack time? What's that?----------------------Ryan StonecipherDeveloper, Microsoft SQL Server Storage Engine, DBCC(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.) |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2005-09-08 : 16:12:13
|
| I had assumed Ryan was Paul's mild mannered alter ego.Be One with the OptimizerTG |
 |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2005-09-08 : 16:26:25
|
Store each coordinate in one row.Let the client format the information into the datatype representation it wants.The database only stores the information, preferably in a normalized manner.Since SQL Server 2K does not support "complex" datatypes you can break the data down into it's constituents./* Store these polygons */POLYGON(0 0, 100 0, 100 100, 0 100, 0 0)POLYGON(25 25,33 33,55 55)/* In a table like this */POLYGONS( PNBR INT ,XCOORD INT ,YCOORD INT ,PRIMARY KEY(PNBR,XCOORD,YCOORD))/* Like this */PNBR XCOORD YCOORD1 0 01 100 01 100 1001 0 1002 25 252 33 332 55 55 |
 |
|
|
ryanston
Microsoft SQL Server Product Team
89 Posts |
Posted - 2005-09-08 : 18:23:18
|
quote: Originally posted by TG I had assumed Ryan was Paul's mild mannered alter ego.Be One with the OptimizerTG
Yeah, Paul is my manager. Now that he's a big-time dev lead, he doesn't have a lot of time for DBCC, so I took it over from him. I'm not sure mild-mannered is exacly an apropo description, but I guess in comparison to Paul... ----------------------Ryan StonecipherDeveloper, Microsoft SQL Server Storage Engine, DBCC(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.) |
 |
|
|
desi_nerd
Starting Member
2 Posts |
Posted - 2005-09-09 : 13:50:07
|
| Thanks for the help.I have decided to use MySQL instead which has the inbuilt data types that i need.---Iam not real any moreIam just an Illusion--- |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-09-09 : 13:56:44
|
now that's a solution....   Go with the flow & have fun! Else fight the flow |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2005-09-09 : 15:05:58
|
quote: Originally posted by desi_nerd Thanks for the help.I have decided to use MySQL instead which has the inbuilt data types that i need.---Iam not real any moreIam just an Illusion---
      Did they ever implement GROUP BY yet?Good LuckAnd remember, you get what you pay for.Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2005-09-09 : 15:09:11
|
quote: Originally posted by ryanston
quote: Originally posted by TG I had assumed Ryan was Paul's mild mannered alter ego.Be One with the OptimizerTG
Yeah, Paul is my manager. Now that he's a big-time dev lead, he doesn't have a lot of time for DBCC, so I took it over from him. I'm not sure mild-mannered is exacly an apropo description, but I guess in comparison to Paul... ----------------------Ryan StonecipherDeveloper, Microsoft SQL Server Storage Engine, DBCC(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.)
My Dad lives just South of Daytona....And when I drive by their community college, I always wanted to stop and get a tee shirthttp://www.dbcc.cc.fl.us/01_about.htmBrett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
paulrandal
Yak with Vast SQL Skills
899 Posts |
Posted - 2005-09-09 : 17:58:07
|
quote: Originally posted by ryanston
quote: Originally posted by TG I had assumed Ryan was Paul's mild mannered alter ego.Be One with the OptimizerTG
Yeah, Paul is my manager. Now that he's a big-time dev lead, he doesn't have a lot of time for DBCC, so I took it over from him. I'm not sure mild-mannered is exacly an apropo description, but I guess in comparison to Paul... ----------------------Ryan StonecipherDeveloper, Microsoft SQL Server Storage Engine, DBCC(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.)
You're lucky we've just done your annual review Paul RandalDev Lead, Microsoft SQL Server Storage Engine(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.) |
 |
|
|
paulrandal
Yak with Vast SQL Skills
899 Posts |
Posted - 2005-09-09 : 18:00:28
|
quote: Originally posted by X002548
Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Seen that before. I toyed with the idea of getting DBCC as a personalized plate 5 years ago but that would have made me seem uncharacteristically ego-centric so I stuck with the one I had.Paul RandalDev Lead, Microsoft SQL Server Storage Engine(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.) |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-09-09 : 19:10:55
|
quote: uncharacteristically ego-centric so I stuck with the one I had.
MSSQLGOD? |
 |
|
|
paulrandal
Yak with Vast SQL Skills
899 Posts |
Posted - 2005-09-09 : 19:22:10
|
quote: Originally posted by robvolk
quote: uncharacteristically ego-centric so I stuck with the one I had.
MSSQLGOD? 
No, it was my old nickname 'chewie', as in Chewbacca.Paul RandalDev Lead, Microsoft SQL Server Storage Engine(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.) |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-09-09 : 19:46:43
|
meaning you're 6 feet 5 inches with hair all over your body??   Go with the flow & have fun! Else fight the flow |
 |
|
|
ryanston
Microsoft SQL Server Product Team
89 Posts |
Posted - 2005-09-09 : 19:56:37
|
quote: Originally posted by spirit1 meaning you're 6 feet 5 inches with hair all over your body??   Go with the flow & have fun! Else fight the flow 
Please, let's stop this conversation before I get any more horrible images of Paul in my mind...----------------------Ryan StonecipherDeveloper, Microsoft SQL Server Storage Engine, DBCC(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.) |
 |
|
|
Next Page
|