Hi All, I was trying to use partitioned index for a slow query but I was stopped with following response from my manager : [b][i] "There are few cases where partitioning seems logical and looks promising but then we found that with right set of indexes and tweaks, performance was equal or even better as any partition scheme would otherwise offer. I think we had external SQL consultants who were of same opinion we well."[/i][/b] If you please share your experience with partitioning, it would be a great help.Regards
↧
Issues with partitioning...
↧
Need help with my tsql code
I have the following query where I need to set a variable to the value of a column in a row in a table. But depending on the circumstances which column to set it equal to. My code follows and executes but it just keeps running:[code="sql"] DECLARE @DayOfWeek Tinyint DECLARE @OrderEntryDate datetime DECLARE @retval Tinyint DECLARE @retvalOUT TinyInt DECLARE @ParmDefinition nvarchar(500); SET @ParmDefinition = N'@retvalOUT int OUTPUT' Set @OrderEntryDate = '01/04/2012' SET @DayOfWeek = 1 DECLARE @TSQLQuery nvarchar(max) SET @TSQLQuery = CASE @DayOfWeek WHEN 1 THEN N'Select @retvalOUT = Convert(TinyInt,Sunday) from [dbo].[SLADCSchedule] where ScheduleStart <= ''' + Convert(varchar(50),@OrderEntryDate) + ''' and ScheduleEnd >= ''' + Convert(varchar(50),@OrderEntryDate) + ''' and BranchID = 99' WHEN 2 THEN N'Select @retvalOUT = Convert(TinyInt,Monday) from [dbo].[SLADCSchedule] where ScheduleStart <= ''' + Convert(varchar(50),@OrderEntryDate) + ''' and ScheduleEnd >= ''' + Convert(varchar(50),@OrderEntryDate) + ''' and BranchID = 99' WHEN 3 THEN N'Select @retvalOUT = Convert(TinyInt,Tuesday) from [dbo].[SLADCSchedule] where ScheduleStart <= ''' + Convert(varchar(50),@OrderEntryDate) + ''' and ScheduleEnd >= ''' + Convert(varchar(50),@OrderEntryDate) + ''' and BranchID = 99' WHEN 4 THEN N'Select @retvalOUT = Convert(TinyInt,Wednesday) from [dbo].[SLADCSchedule] where ScheduleStart <= ''' + Convert(varchar(50),@OrderEntryDate) + ''' and ScheduleEnd >= ''' + Convert(varchar(50),@OrderEntryDate) + ''' and BranchID = 99' WHEN 5 THEN N'Select @retvalOUT = Convert(TinyInt,Thursday) from [dbo].[SLADCSchedule] where ScheduleStart <= ''' + Convert(varchar(50),@OrderEntryDate) + ''' and ScheduleEnd >= ''' + Convert(varchar(50),@OrderEntryDate) + ''' and BranchID = 99' WHEN 6 THEN N'Select @retvalOUT = Convert(TinyInt,Friday) from [dbo].[SLADCSchedule] where ScheduleStart <= ''' + Convert(varchar(50),@OrderEntryDate) + ''' and ScheduleEnd >= ''' + Convert(varchar(50),@OrderEntryDate) + ''' and BranchID = 99' WHEN 7 THEN N'Select @retvalOUT = Convert(TinyInt,Saturday) from [dbo].[SLADCSchedule] where ScheduleStart <= ''' + Convert(varchar(50),@OrderEntryDate) + ''' and ScheduleEnd >= ''' + Convert(varchar(50),@OrderEntryDate) + ''' and BranchID = 99' --ELSE 'Not for sale' END --Print @TSQLQuery --Set @DayCounter = @DayCounter + --EXECUTE(@TSQLQuery) exec sp_executesql @TSQLQuery, N'@retvalOUT Tinyint OUTPUT', @retvalOUT = @retval OUTPUT; print @retval[/code]
↧
↧
Joining Tables
I am trying to join three tables together to get a sum from one table, count from second table, and the third table is just a reference. So here is some examples of my tables:Listcode Table:Listcode DNISAM 5425566EL 5425563Calls Table:Date DNIS Offered7/20/2013 5425566 1257/20/2013 5425563 757/19/2013 5425566 123Sales Table:purchdate Listcode7/20/13 AM7/20/13 AM7/20/13 AM7/20/13 EL7/19/13 AM7/19/13 ELNow you can probably tell which columns match which between the three. So now what I am trying to do is have a query, which I am trying to put into PHP, I want to select Listcode "AM". Here is what my query results I want to see:Date Offered Sales7/20/13 125 37/19/13 123 1I cannot seem to join or get selects within a join to work. Any help would be appreciated! Let me know if there is any other information needed?
↧
EXCEPT vs NOT IN vs LEFT OUTER JOIN
The system I'm working on uses a lot of subqueries, and sums the results using UNIONS, which seems very fast. However, sometimes it also needs to exclude data sets as well. It is currently using EXCEPT, and this seems a lot slower.I am looking at redeveloping this part of the code to make it more efficient, but I don't know which method will be the fastest. SQL 2012 often seems to be fairly smart when it comes to optimising queries, so I'm wondering if I will see any significant improvement by trying to use a JOIN or NOT IN instead.My subqueries typically return 10's of millions of records, but only has one numeric column in each one.Any suggestions are very gratefully recieved
↧
How to Call Function In SP
Hi All,I have created a function (Func_GetSeqValue) which is creating a Sequential number. Here is my Query[quote]Create Function GetSeqValue (@limit int)returns @TableVar table (GetSequecValue Varchar(20))asbegindeclare @var int = 1declare @var1 varchar (20)while (@var < @limit)beginif @var < 10set @var1= 'ABCD' + '00' +CAST(@var as varchar)else if @var < 100set @var1= 'ABCD' + '0' +CAST(@var as varchar)elseset @var1= 'ABCD' + CAST(@var as varchar)insert into @TableVar values (@var1)set @var = @var+1endreturnend[/quote]When I am executing this function with a parameter ti is working fine. Now I have created another table (InsertedEmpdetails)[quote]create table InsertedEmpdetails(Emp_id Varchar,Emp_Name varchar(30),Emp_Age tinyint,Emp_Course varchar (15),Emp_Gender varchar,Emp_Sal Float,)[/quote]Now I want to insert the data in the table using an SP. Here is my SP[quote]CREATE PROC usp_InsertDetails( @id varchar (20), @name varchar(30), @age tinyint, @course char(21), @gender char(1), @empSal Float)ASBEGININSERT INTO InsertedEmpdetails VALUES(@id, @name, @age, @course, @gender, @empSal)END[/quote]Now For ID Field I want to insert the data from my Function (Func_GetSeqValue). How will I do that?Please help!
↧
↧
Searching Address by Ranges
I have a scenario where I have been given a table full of address ranges that I need to compare against an existing table containing addresses. The address range table is structured with the following columns: StreetName, RangeFrom, RangeTo.A particular example is that I need to find an address that looks like 1516 Adams St by using the address range table with the following: StreetName = 'Adams', RangeFrom = 1200, RangeTo = 1599. In this case I can use a like statement using '1[2-5][0-9][0-9]' + StreetName + '%' to capture the desired records. However, it becomes a bit more tricky when the ranges are some thing like 1505-1629 or 12-158.Does anyone know of a good way to perform this function?Thanks for any assistance you can provide.Tony Willms
↧
Query help with unpivot qry
Need a query help, on unpivoting columnsHave the data as below...create table #Test (itemNo int,Cat1 int,SubCat11 int,SubCat12 int,Cat2 int,SubCat21 int,Cat3 int,SubCat31 int)---Insert into #Test select 888,3,97,245,4,272,5,128Insert into #Test select 999,1,20,200,3,211,6,455--Need the results asItem CatID SubCatID888 3 97888 3 245888 4 272888 5 128999 1 20999 1 200999 3 211999 6 455Tried the following query...SELECT ItemNo, CategoryID ,SubCatIDFROM ( SELECT ItemNo, Cat1,Cat2,Cat3, Subcat11,Subcat12,Subcat21,Subcat31FROM #Test ) Main UNPIVOT ( CategoryID FOR Categories IN (Cat1,Cat2,Cat3) ) Sup UNPIVOT ( SubCatID For SubCats IN (Subcat11,Subcat12,Subcat21,Subcat31) ) Ct WHERE RIGHT(Categories,1) = RIGHT(SubCats,1)The SubCatID is repeated for cat column combinations...showing wrong results...Any help appreciated...
↧
kill sessions through linked server
I am trying to run dynamic SQL, which will kill all sessions with particular login on remote server. I have following now, but how could I do "exec(@dsql)" part against the remote SQL server?declare @dsql nvarchar(max)=''select @dsql = 'kill ' + cast(spid as varchar(20)) + ';' from [linkedserver].sys.sysprocesseswhere loginame='XXXX'exec(@dsql)
↧
Help with SQL Code..
I have a table with cols as follows ID Unit location col1 col2 userID1 A AA a a Lan11 A AA a a Lan21 C AA a a Lan32 A BB a a Lan1i would like to have the data displayed as1 A AA a a Lan1,Lan21 C AA a a Lan32 A BB a a Lan1it will be a group by on ID, Unit and Location with Userid getting concatenated. Does anyone have any suggestion how to get the result displayed as above. any help will be greatly appreciated. TIA
↧
↧
OFFSET and FETCH NEXT, inconsistent execution plan
Hi All,I've been doing some testing with some of the new features of SQL 2012, and I've found some strange inconsistencies in the way SQL is generating it's execution plans. In certain situations it's not using indexes when it could, and I can't figure out why.I've got the following simple table...[ID] [uniqueidentifier] (primary key, non-clustered)[Title] [nvarchar](150)[DateCreated] [datetime] (indexed, non-clustered)I've added 100,000 test rows.The following 2 queries I would think should be equivalent....-Query 1------select * from [Table_2]ORDER BY datecreated ascOFFSET 50000 ROWSFETCH NEXT 40000 ROWS ONLY;-------Query 2------declare @StartRow bigintdeclare @NumRows bigintset @StartRow = 50000set @NumRows = 40000select * from [Table_2]ORDER BY datecreated ascOFFSET @StartRow ROWSFETCH NEXT @NumRows ROWS ONLY;------The odd thing is that the 1st query runs much slower. According to the execution plan it's relative cost is 96% compared to 4%.The plan shows that the first query is using table scan + sort, but the second query is using an index scan.I'm a bit confused as to why SQL server isn't using the index for datecreated for the first query, but it is for the second.The cost for the query is actually the same as if I order by the non-indexed column "title".The other odd thing is that even if I force SQL to use the index with...WITH (INDEX(IX_Table_2))... this doesn't help, and actually increases the cost slightly, even though the execution plan then looks the same for both queriesMind you having the variables makes things a lot more flexible, but I would really like to know why the other version of the query is less efficient, when logically I would think, if anything, it should be the other way around.Any thoughts?Eugene
↧
When I put my Where clause on Qry will not return data
Not sure why but any suggestions?Select Distinct M.Memid,M.Fullname,E.enttype,EK.planid,Ek.Carriermemid HICN,EK.effdate EffectiveDate,BP.upid ContractPBP, PA.CreateDate,PA.Comment,PA.[Source],PA.CompleteDateFrom dbo.Member M Left Join dbo.Entity E on E.entid=M.entityid Join dbo.EnrollKeys Ek on EK.Memid=M.Memid Join dbo.BenefitPlan BP on BP.Planid=EK.planID Join dbo.PlanAction PA on PA.secondid=E.planactionsecid WHERE PA.CompleteDate is Null and PA.[Source]='ID Card' and (ek.termdate > GETDATE())
↧
Replacement for a whole mess of left joins?
Hi,A bit of a general question:I have a query with 28 LEFT JOINS. 20 of them join one table to the original query in order to break information out into separate columns, so data is distinguishable. The next 8 do the same thing with a third table. I was thinking about using PIVOT to replace them, but since I've never used it before, I wasn't entirely sure it would be the best route to go. I was also considering a CTE, because I'm more familiar with them. Again though, not sure it would be the best route. Any suggestions or opinions?
↧
Assign a unique ID to a group of data that repeats...
Hi,I'm trying to create a unique id, it's easier to show than explain i think...So I need the result to show the UNIQUE_ID as shown below...I thought one of the rank functions might work, but I'm not sure how to use a CASE Statement within it, or even if a CASE is allowed???ACTIVITY_ID is the key... also, pat_id1 is patients, so I can have many unique PAT_ID1 (it doesn't matter to me when doing the unique_id if the count starts over at each new pat_id1 is continues the count)Appreciate any ideas!Thanks,JohnPAT_ID1 COMPLETION DATE ACTIVITY ACTIVITY_ID LEAD_ACTIVITY_ID UNIQUE_ID10910 1/7/2011 Referral Date 1 NULL 110910 1/7/2011 Billing Start Date 3 4 110910 4/29/2011 Billing End Date 4 3 110910 5/25/2011 Billing Start Date 3 4 210910 6/30/2011 Billing End Date 4 3 210910 7/25/2011 Billing Start Date 3 4 310910 8/26/2011 Billing End Date 4 3 310910 10/17/2011 Billing Start Date 3 4 410910 10/31/2011 Billing End Date 4 3 410910 11/9/2011 Billing Start Date 3 4 510910 11/24/2011 Billing End Date 4 NULL 5[code="sql"]CREATE TABLE #TEMP_RANK ( PAT_ID1 INT , COMPLETION_DATE DATETIME , ACTIVITY VARCHAR(100) , ACTIVITY_ID INT , LEAD_ACTIVITY_ID INT )INSERT INTO #TEMP_RANK (PAT_ID1, COMPLETION_DATE, ACTIVITY, ACTIVITY_ID, LEAD_ACTIVITY_ID) VALUES (10910,CAST('1/7/2011' AS DATE), 'Referral Date', 1, NULL)INSERT INTO #TEMP_RANK (PAT_ID1, COMPLETION_DATE, ACTIVITY, ACTIVITY_ID, LEAD_ACTIVITY_ID) VALUES (10910,CAST('1/7/2011' AS DATE), 'Billing Start Date', 3, 4)INSERT INTO #TEMP_RANK (PAT_ID1, COMPLETION_DATE, ACTIVITY, ACTIVITY_ID, LEAD_ACTIVITY_ID) VALUES (10910,CAST('4/29/2011' AS DATE), 'Billing End Date', 4, 3)INSERT INTO #TEMP_RANK (PAT_ID1, COMPLETION_DATE, ACTIVITY, ACTIVITY_ID, LEAD_ACTIVITY_ID) VALUES (10910,CAST('5/25/2011' AS DATE), 'Billing Start Date', 3, 4)INSERT INTO #TEMP_RANK (PAT_ID1, COMPLETION_DATE, ACTIVITY, ACTIVITY_ID, LEAD_ACTIVITY_ID) VALUES (10910,CAST('6/30/2011' AS DATE), 'Billing End Date', 4, 3)INSERT INTO #TEMP_RANK (PAT_ID1, COMPLETION_DATE, ACTIVITY, ACTIVITY_ID, LEAD_ACTIVITY_ID) VALUES (10910,CAST('7/25/2011' AS DATE), 'Billing Start Date', 3, 4)INSERT INTO #TEMP_RANK (PAT_ID1, COMPLETION_DATE, ACTIVITY, ACTIVITY_ID, LEAD_ACTIVITY_ID) VALUES (10910,CAST('8/26/2011' AS DATE), 'Billing End Date', 4, 3)INSERT INTO #TEMP_RANK (PAT_ID1, COMPLETION_DATE, ACTIVITY, ACTIVITY_ID, LEAD_ACTIVITY_ID) VALUES (10910,CAST('10/17/2011' AS DATE), 'Billing Start Date', 3, 4)INSERT INTO #TEMP_RANK (PAT_ID1, COMPLETION_DATE, ACTIVITY, ACTIVITY_ID, LEAD_ACTIVITY_ID) VALUES (10910,CAST('10/31/2011' AS DATE), 'Billing End Date', 4, 3)INSERT INTO #TEMP_RANK (PAT_ID1, COMPLETION_DATE, ACTIVITY, ACTIVITY_ID, LEAD_ACTIVITY_ID) VALUES (10910,CAST('11/9/2011' AS DATE), 'Billing Start Date', 3, 4)INSERT INTO #TEMP_RANK (PAT_ID1, COMPLETION_DATE, ACTIVITY, ACTIVITY_ID, LEAD_ACTIVITY_ID) VALUES (10910,CAST('11/24/2011' AS DATE), 'Billing End Date', 4, NULL)[/code]
↧
↧
Does anyone else...
Use selects to build syntax? For instance, the other day I had to build a variable based on some column information in my table, so I did this:[code="sql"]select 'when quota = ' + quota + ' and center = ''' + center + ''' and pfield5 = ''' + pfield5 + '''' + ' then 'from tablegroup by quota, center, pfield5order by quotacell, center, pfield5[/code]The result was the meat of a case statement that coded a variable from 1-60. I was pretty happy with myself. I wish I had thought ahead a little bit and used something like below to fill in the THEN, rather than going back and doing it by hand after pasting.I just used it again to build an update based on those 60 variables after making a lookup type table of the information:[code="sql"]select 'update table set reps = 3 where id in (select top '+ cast(records as varchar) + ' id from table where view = ' + cast(view as varchar) + ' and status = 0 and reps is null order by sortid)'from table_lookup[/code]Of course, I'm also interested in hearing if this is a bad idea for some reason that I'm unaware of.
↧
Massive Merge
Hi peeps,looking at using a MERGE on a table with circa 100 million rows. Will be using all three parts of the merge i.e. insert, update and delete.Problems I am encountering is the time taken and the fact that the drive with the log files on runs out of space. I also suspect that space impacts on the performance.Is there an easy way for the Merge to be run in chunks? My grip of transaction log files is patchy but as we are in SIMPLE recovery mode the transaction log file should be re-usable once the transaction is committed so if we can do the Merge in multiple transactions then the size of the file should not be as big. At the moment the log file bloats to > 50GB. Now if that Merge was done in ten individual transactions then once the first transaction is completed the space in the log file would be re-used by the second transaction and so on.Or have I got this wrong.CheersEPS have indexed the tables to try and improve performance.:w00t:
↧
Need to iterate through sets
I have a Project master table (tblProjects). Each project has zero or more Work Orders in the work order table (tblWorkOrders) (FK). Each Work Order has zero or more timesheet entries in the Timesheet (tblSA) table.I need to write a (probably stored procedure) that, for a given ProjectID (PK), there are no Timesheet entries, thenDelete all Work Orders for that ProjectID (FK on tblWorkOrders.) None of the FKs are set to cascading delete, all are set to Referential Integrity.What's the strategy for doing this?
↧
Lost permissions
I recently moved the location of the tempdb databases to another drive from the C: to F: following BOL step by step. After restarting the SQL service my backups would not work giving the following error: The job failed. Unable to determine if the owner (DC\gchappell) of job Backup-bbbbbbbbb-Full has server access (reason: Could not obtain information about Windows NT group/user 'DC\gchappell', error code 0x6e. [SQLSTATE 42000] (Error 15404)).Before the move of tempdb and restart of services everything completed no problem. Has anyone else encountered anything like this? It appears the restart may have wiped out my permissions.Any help is appreciated.
↧
↧
and x is NULL <> and x = 'NULL'
Just when I thought [url=http://stackoverflow.com/questions/4456438/how-can-i-pass-the-string-null-through-wsdl-soap-from-actionscript-3-to-a-co?rq=1]this[/url] was about the silliest thing I'd seen...I had someone using NULL as a string in an Excel file that I imported, which made some count queries go b-a-n-a-n-a-s.Some days I think those Amish are on to something.
↧
Fulltextsearch in varbinary field
Hi, we have a database which should store different files (doc, pdf, XML ,...) with filestream. We would like to implement fulltext search for the documents stored in varbinary field.[code="sql"]create database dbKnowledgebase on primary ( name = 'dbKnowledgebase', filename = 'D:\DB\MSSQL11.MSSQLSERVER\MSSQL\DATA\dbKnowledgebase.mdf', size = 10 MB ),Filegroup KnowledgeFS contains filestream ( name = 'KnowledgeFS', filename = 'D:\DB\MSSQL11.MSSQLSERVER\MSSQL\DATA\KnowledgeFS' )LOG ON (NAME = dbSoftysoft1_log1, FILENAME = 'D:\DB\MSSQL11.MSSQLSERVER\MSSQL\DATA\dbKnowledgebase.ldf', SIZE = 2MB, FILEGROWTH = 20% ) GOcreate table tblRessources( IDRessource int identity(1,1) primary key, FKUser int not null references tblUser, Url varchar(500), ID UNIQUEIDENTIFIER ROWGUIDCOL NOT NULL UNIQUE default newid(), Files varbinary(max) Filestream , Notice varchar(500))exec sp_fulltext_database 'enable';select FULLTEXTSERVICEPROPERTY('IsFulltextInstalled')CREATE FULLTEXT CATALOG [fulltextCatalogue]CREATE UNIQUE INDEX fullIndex ON tblRessources (IDRessource); GOcreate fulltext index on tblRessources(Files) key index fullIndex on [fulltextCatalogue] with stoplist = system, change_tracking = manual alter fulltext index on tblRessources start update population[/code]If we create the index we receive an error:Meldung 7655, Ebene 16, Status 1, Zeile 1The Option TYPE COLUMN has to be specified for a column from type 'image' oder 'varbinary(max)'.Your help would be appreciated,thanks a lot.
↧
SQL Server Spatial - STIntersection
I am having an issue with STIntersection. I want to intesect a polygon with a linestring an have it return the cut linestrings. I assumed STIntersection would do this and it will in certain situations. What I am running into as in the example below is that instead of keeping the integrity of the original linestrings, STIntersection is creating a new linestring for the clipped area and also for each time a line intersects another line. So instead of getting 5 new linestrings in a Multilinestring geography, I am getting 20 representing each intersection of the linestrings with themselves. I really need a way to only cut the linestring where it intersects the polygon and not create a linestring for each intersection against itself. I tried to figure a way to reassemble them, but I cannot tell which pieces should go together. ESRI can handle this and so far I haven't found anything that I can do in ESRI that I could not do in SQL Spatial.Thanks in advance for any help or advice.declare @POLYGON geographydeclare @LINESTRING geographyset @POLYGON = geography::STGeomFromText('POLYGON ((3.4293073891935575 56.665143418074329, 3.4186112463339011 56.670796145703463, 3.4074210497749329 56.676152105069448, 3.395763821883333 56.6811982646792, 3.3836677560585464 56.685922341716854, 3.3711621477806868 56.690312832864493, 3.3582773225608427 56.694359043211691, 3.3450445609810724 56.698051113171722, 3.3314960210228053 56.701380043328655, 3.3176646578930211 56.70433771714422, 3.3035841415676708 56.706916921459893, 3.2892887722809538 56.709111364734895, 3.2748133941975 56.710915692968015, 3.2601933075119414 56.7123255032568, 3.2454641792268695 56.713337354955279, 3.2306619528656695 56.71394877839748, 3.2158227573811824 56.714158281161446, 3.20098281552452 56.713965351855627, 3.1861783519406206 56.713370461416453, 3.1714455012582783 56.712375061913377, 3.1568202164424273 56.710981582864918, 3.1423381776753252 56.709193425076286, 3.1280347020310897 56.70701495201677, 3.1139446542046794 56.70445147876174, 3.1001023585520233 56.701509258531559, 3.0865415126925551 56.698195466866316, 3.073295102918904 56.694518183482117, 3.0603953216511233 56.69048637186124, 3.04787348716445 56.686109856634829, 3.0357599658104149 56.681399298822576, 3.0240840969411535 56.676366169000254, 3.012874120736055 56.67102271847083, 3.0021571091185115 56.665381948520583, 2.9919588999386639 56.659457577846609, 2.9823040345855336 56.653264008246154, 2.973215699179153 56.646816288663288, 2.9647156694800696 56.640130077691374, 2.9568242596401886 56.633221604634329, 2.9495602749052541 56.626107629231974, 2.9429409683655421 56.618805400157925, 2.9369820018375936 56.611332612401256, 2.9316974109460419 56.603707363644375, 2.9270995744610118 56.59594810975193, 2.9231991879331152 56.588073619486778, 2.9200052416548661 56.5801029285696, 2.9175250029644264 56.572055293199767, 2.9157640028950511 56.563950143155182, 2.9147260271614197 56.55580703458871, 2.9144131114623195 56.54764560263834, 2.9148255410678807 56.53948551396774, 2.9159618546488235 56.531346419352623, 2.9178188522949182 56.523247906427223, 2.9203916076602088 56.515209452703409, 2.9236734841634164 56.507250378973559, 2.9276561551633735 56.4993898032057, 2.9323296280213964 56.491646595037722, 2.9376822719550661 56.484039330974511, 2.9437008495810848 56.47658625038963, 2.9503705520385903 56.469305212429859, 2.9576750375785781 56.462213653918354, 2.9655964734999007 56.455328548348682, 2.9741155813076343 56.448666366058873, 2.9832116849653878 56.442243035671225, 2.9928627621094273 56.436073906879912, 3.0030454980891959 56.430173714665209, 3.0137354753850834 56.424556478619756, 3.024906846178145 56.419235676754752, 3.0365327683785304 56.414224001006986, 3.048585349184711 56.409533401124051, 3.0610357111406761 56.405175057055828, 3.0738540601590087 56.401159353164, 3.0870097553612377 56.397495854301049, 3.1004713805860185 56.394193283806167, 3.1142068174150674 56.391259503461335, 3.1281833195662361 56.388701495446988, 3.1423675885027404 56.386525346332157, 3.1567258501073088 56.384736233130489, 3.1712239322697577 56.3833384114487, 3.1858273432364483 56.38233520575055, 3.2005013505699105 56.381729001754962, 3.2152110605669244 56.381521240982636, 3.2299214979833208 56.381712417461969, 3.2445976859136914 56.382302076600183, 3.2592047256742709 56.383288816222041, 3.2737078765371903 56.384670289774114, 3.2880726351643377 56.386443211688423, 3.3022648145890794 56.388603364895339, 3.3162506225940911 56.3911456104712, 3.3299967393336507 56.394063899402283, 3.3434703940487704 56.397351286442365, 3.356639440723733 56.400999946037167, 3.3694724325327354 56.405001190284892, 3.3819386949256693 56.409345488897657, 3.3940083972024166 56.414022491124939, 3.40565262242552 56.419021049595841, 3.41684343552179 56.4243292460328, 3.4275539494241882 56.42993441878555, 3.4377583891063819 56.435823192130307, 3.4474321533635863 56.44198150727437, 3.45655187419488 56.448394655003383, 3.4650954736439457 56.455047309904074, 3.4730422179573286 56.461923566091308, 3.48037276892179 56.469006974364937, 3.487069232245207 56.476280580718061, 3.4931152028487005 56.48372696611451, 3.4984958069414134 56.491328287449981, 3.5031977407535515 56.499066319608126, 3.5072093058079021 56.506922498518954, 3.5105204406152741 56.514877965124413, 3.5131227486849848 56.522913610152557, 3.5150095227477567 56.531010119599046, 3.5161757650952268 56.539148020812071, 3.5166182039476088 56.547307729074056, 3.5163353057690534 56.55546959457169, 3.5153272834587197 56.563613949643262, 3.5135961003547331 56.571721156190812, 3.5111454699977958 56.579771653142835, 3.5079808516115003 56.587746003852168, 3.5041094412670568 56.595624943312416, 3.4995401587114432 56.603389425075889, 3.4942836298496731 56.611020667755305, 3.4883521648840192 56.618500200991377, 3.4817597321256026 56.62580991076922, 3.4745219275066122 56.632932083966296, 3.4666559398346579 56.639849452015987, 3.4581805118441489 56.646545233572482, 3.449115897113225 56.653003176063407, 3.43948381292849 56.659207596019776, 3.4293073891935575 56.665143418074329))', 4326)set @LINESTRING = geography::STGeomFromText('LINESTRING (5.5973166666666669 58.92883333333333, 5.5860166666666666 58.92625, 5.5431166666666662 58.9217, 5.523533333333333 58.892616666666669, 5.504083333333333 58.863266666666668, 5.4654666666666669 58.8392, 5.4279666666666664 58.8154, 5.3912333333333331 58.7925, 5.3546166666666668 58.76958333333333, 5.3203166666666668 58.7458, 5.2917 58.719883333333335, 5.2632833333333338 58.69251666666667, 5.2357666666666667 58.664883333333336, 5.2087166666666667 58.63805, 5.1827833333333331 58.611083333333333, 5.1574833333333334 58.5834, 5.132366666666667 58.55595, 5.1058166666666667 58.528466666666667, 5.0795 58.501233333333332, 5.05285 58.473883333333333, 5.0265166666666667 58.44636666666667, 4.9989333333333335 58.418983333333337, 4.9722166666666663 58.393466666666669, 4.9455166666666663 58.368366666666667, 4.9185 58.343033333333331, 4.8899 58.317283333333336, 4.8600166666666667 58.29078333333333, 4.8303333333333338 58.2635, 4.8021833333333337 58.235616666666665, 4.7775333333333334 58.210016666666668, 4.7528500000000005 58.1847, 4.7277166666666668 58.15978333333333, 4.7030166666666666 58.1354, 4.6779833333333336 58.110483333333335, 4.65235 58.08605, 4.6089833333333337 58.034816666666664, 4.5846333333333336 58.009966666666664, 4.4019 57.836283333333334, 4.3755666666666668 57.810966666666666, 4.29825 57.7348, 4.2723333333333331 57.709183333333335, 4.2463333333333333 57.683733333333336, 4.22025 57.65826666666667, 4.1941166666666669 57.632583333333336, 4.1683833333333329 57.60693333333333, 4.1428833333333337 57.58125, 4.11775 57.555183333333332, 4.0926166666666663 57.52945, 4.0676 57.503816666666665, 4.0422333333333329 57.47815, 4.01685 57.452683333333333, 3.99135 57.427433333333333, 3.9656666666666665 57.402116666666664, 3.9400833333333334 57.377, 3.9142166666666665 57.351833333333332, 3.8881666666666668 57.326866666666668, 3.8621 57.301916666666664, 3.8360666666666665 57.277166666666666, 3.810083333333333 57.252633333333335, 3.7841166666666668 57.2281, 3.75835 57.203666666666663, 3.7327 57.179283333333331, 3.7070166666666666 57.1552, 3.6814333333333336 57.131133333333331, 3.6555833333333334 57.10715, 3.6300333333333334 57.08335, 3.2284166666666665 56.548733333333331, 3.2232666666666665 56.546183333333332, 3.2177666666666669 56.54845, 3.23455 56.55916666666667, 3.2298166666666668 56.559283333333333, 3.2124666666666668 56.553233333333331, 3.2140166666666667 56.536616666666667, 3.2364666666666668 56.521033333333335, 3.2199666666666666 56.54345, 3.2206333333333332 56.54475, 3.2166166666666665 56.5337, 3.2176833333333335 56.4181, 3.2202333333333333 56.41895, 3.2347 56.402816666666666, 3.24895 56.389733333333332, 3.25415 56.3835, 3.2564166666666665 56.380833333333335, 3.2621333333333333 56.381266666666669, 3.26735 56.381183333333333, 3.2731 56.381466666666668, 3.2715166666666669 56.3849, 3.27415 56.37965, 3.2761 56.37853333333333, 3.2675666666666667 56.378066666666669, 3.2650166666666669 56.376633333333331, 3.2616166666666668 56.381483333333335, 3.2533 56.378666666666668, 3.2457833333333332 56.376116666666668, 3.24885 56.376316666666668, 3.2393666666666667 56.38133333333333, 3.2397 56.37851666666667, 3.2411666666666665 56.37545, 3.2462666666666666 56.364416666666664, 3.2253333333333334 56.545966666666665, 3.21505 56.563983333333333, 3.2134333333333331 56.553666666666665, 3.22545 56.544933333333333, 3.2181333333333333 56.54815, 3.2911 56.583016666666666, 3.2850666666666668 56.542866666666669, 3.2835166666666664 56.527483333333336, 3.283 56.519933333333334, 3.2825333333333333 56.512866666666667, 3.21895 56.5476, 3.2117166666666668 56.54485, 3.3095499999999998 56.62795, 3.32665 56.641766666666669, 3.30435 56.63388333333333, 3.2691333333333334 56.610233333333333, 3.2308 56.585183333333333, 3.2100666666666666 56.566033333333337, 3.2102333333333335 56.564666666666668, 3.18685 56.54781666666667, 3.1955666666666667 56.543533333333336, 3.2032 56.54295, 3.2304666666666666 56.527633333333334, 3.2371666666666665 56.5187, 3.2393833333333335 56.517983333333333, 3.2468166666666667 56.516166666666663, 3.2298833333333334 56.539566666666666, 3.21135 56.54848333333333, 3.2364166666666665 56.53705, 3.2376833333333335 56.557916666666664, 3.2416166666666668 56.5537, 3.2339833333333332 56.549633333333333, 3.2331 56.54885, 3.26125 56.558033333333334, 3.2715333333333332 56.560216666666669, 3.27915 56.562, 3.2829166666666669 56.565233333333332, 3.2820666666666667 56.567933333333336, 3.2633333333333332 56.5755, 3.2705666666666668 56.582233333333335, 3.2709 56.580916666666667, 3.26615 56.58005, 3.2642166666666665 56.57755, 3.2619666666666669 56.575516666666665, 3.2495 56.5654, 3.21675 56.55833333333333, 3.1614 56.53455, 3.1814666666666667 56.53425, 3.2033333333333331 56.53585, 3.2245166666666667 56.536366666666666, 3.2460833333333334 56.5385, 3.2647166666666667 56.585033333333335, 3.21665 56.544066666666666, 3.2207666666666666 56.544200000000004, 3.2149166666666669 56.556933333333333, 3.22195 56.55766666666667, 3.2241333333333335 56.55915, 3.2271 56.563966666666666, 3.22975 56.56816666666667, 3.2292666666666667 56.564966666666663, 3.22985 56.56315, 3.23005 56.5609, 3.2293833333333333 56.55898333333333, 3.2285666666666666 56.556616666666663, 3.2528333333333332 56.549233333333333, 3.2724333333333333 56.467483333333334, 3.274 56.437583333333336, 3.2553 56.378616666666666, 3.23885 56.5397, 3.2315833333333335 56.544733333333333, 3.22975 56.5462, 3.2253833333333333 56.54465, 3.2282 56.547, 3.4930833333333333 56.9171, 3.5147333333333335 56.9432, 3.5362999999999998 56.969, 3.5585166666666668 56.9954, 3.5800833333333335 57.021433333333334, 3.6016333333333335 57.04761666666667, 3.62355 57.073966666666664, 3.6454166666666667 57.100616666666667, 3.66775 57.127366666666667, 3.6893833333333332 57.154, 3.71165 57.180733333333336, 3.7349333333333332 57.20725, 3.7611499999999998 57.233066666666666, 3.7868166666666667 57.258783333333334, 3.8127666666666666 57.284683333333334, 3.8383833333333333 57.310333333333332, 3.8638666666666666 57.335783333333332, 3.88985 57.36163333333333, 3.9161333333333332 57.387383333333332, 3.94155 57.412916666666668, 3.9677 57.43845, 3.9938666666666665 57.4641, 4.0198666666666663 57.48975, 4.045633333333333 57.5153, 4.0710833333333332 57.540666666666667, 4.0964666666666663 57.5664, 4.12255 57.591966666666664, 4.1485666666666665 57.617233333333331, 4.1749666666666663 57.64306666666667, 4.2013 57.668466666666667, 4.2271666666666663 57.693483333333333, 4.2532833333333331 57.7186, 4.2793666666666663 57.743783333333333, 4.4644666666666666 57.9133, 4.4914666666666667 57.93716666666667, 4.51815 57.960966666666664, 4.5451166666666669 57.984833333333334, 4.5717166666666671 58.008766666666666, 4.5973833333333332 58.03295, 4.6212666666666671 58.05683333333333, 4.6442833333333331 58.080966666666669, 4.6689 58.105, 4.691816666666667 58.129783333333336, 4.71415 58.15465, 4.734633333333333 58.179033333333336, 4.7527333333333335 58.204016666666668, 4.7701166666666666 58.22975, 4.7886666666666668 58.2559, 4.8092333333333332 58.281383333333331, 4.830283333333333 58.3065, 4.8521 58.33175, 4.8741166666666667 58.356716666666664, 4.8970333333333329 58.381116666666664, 4.921 58.4052, 4.9451666666666672 58.42985, 4.9706166666666665 58.454283333333336, 4.9948 58.478183333333334, 5.015366666666667 58.5027, 5.03575 58.5289, 5.0606333333333335 58.555016666666667, 5.0892833333333334 58.580216666666665, 5.1181166666666664 58.605766666666668, 5.1484333333333332 58.6312, 5.1807333333333334 58.656033333333333, 5.2141833333333336 58.68035, 5.2447333333333335 58.701866666666668, 5.2617666666666665 58.715866666666663, 5.2897333333333334 58.734583333333333, 5.3170833333333336 58.7534, 5.3563833333333335 58.77706666666667, 5.4008666666666665 58.803666666666665, 5.45125 58.82865, 5.4961 58.849683333333331, 5.5255166666666664 58.876066666666667, 5.5421333333333331 58.90725, 5.5577333333333332 58.9275, 5.5837 58.926016666666669, 5.592483333333333 58.927266666666668, 5.5940833333333337 58.927633333333333, 5.5972333333333335 58.92881666666667)', 4326)select @POLYGON.STIntersection(@LineString) as Intersection, @POLYGON.STIntersection(@LineString).STAsText() as IntersectionText, @POLYGON.STIntersection(@LineString).STNumGeometries() as GeometryCount
↧