I have a closed polygon that coincidently is in the shape of Iowa :) I have a point that is within the state and a point WELL outside it, but I get weird results that I don't expect when I try to get it to tell me that the point is within the polygon. Here is some basic code, with long coordinates data.
(1 row(s) affected)As I read that there is a distance of about 7864 meters, this is close to what I would expect, so that's ok. The point outside I would expect a distance as well so that is confusing.. Then we have the intersects, it says that the point inside does NOT intersect but the one outside DOES, this is backed up by the intersection values.
ManagerID, ManagerID2, ManagerID3, ManagerID4 are all pointing to EmployeeID in the same table.
Now I want to select the all employee records where the manager NAME is like '%Raymond%'. (i.e. any of the four managers name is like '%Raymond%'.
How do I construct the select query? I tried this, but it does not work if there are more than 1 manager named 'Raymond'
DECLARE @Name varchar(50) SET @Name = '%Raymond%'
DECLARE @EmployeeNumber nvarchar(50) Select @EmployeeNumber = EmployeeID from Employee where [Name] like @Name
SELECT 'HumanResources.Employee' as TableName, E.[Name] as EmployeeName , isnull((Select [Name] from Employee E2 where E2.EmployeeID = E.ManagerID),'') as Manager1, isnull((Select [Name] from Employee E2 where E2.EmployeeID = E.ManagerID2),'') as Manager2, isnull((Select [Name] from Employee E2 where E2.EmployeeID = E.ManagerID3),'') as AppraisingManager, isnull((Select [Name] from Employee E2 where E2.EmployeeID = E.ManagerID4),'') as ModeratingManager, E.CurrentFlag as Active FROM HumanResources.Employee E
WHERE (E.[ManagerID] = @EmployeeNumber) or (E.[ManagerID2] = @EmployeeNumber) or (E.[AppraisingManagerID] = @EmployeeNumber) or (E.[ModeratingManagerID] = @EmployeeNumber))
Greetings everyone, I'm posting this thread with the hope that someone will notice it and might offer me a helping hand regarding one of my problems.I have the database named "DBEXAMPLE" with the table MEMB_INFO that contains two important columns that are named cur_points and points where cur_points column contains the total available points that a member can use/spend on a game and the points column stores the total of the points that a member used so far.So as i plan to wipe all data of the database, i need to keep the member login,password and total points that each member purchased.So i will somehow need to update the cur_points column with the total of current cur_points+points columns and then wipe points column.I've personally asked a friend regarding this and he said that this should be something complicated and it might require php also.Really appreciate if someone could help me regarding this.small schema:Database: DBEXAMPLETable: MEMB_INFOColumn cur_points -> total available points that a member can spendColumn points -> total points that the member has already spentColumn memb___id -> member login aka account idTODO -> update cur_points column with the total of cur_points+points columns for each member(buyer)With best regards.
I'm running the following SQL query from LabVIEW, a graphical programming language, using the built in capabilities it has for database connectivity:
   DECLARE @currentID int    SET @currentID = (SELECT MIN(ExperimentID) FROM Jobs_t WHERE JobStatus = 'ToRun');    UPDATE [dbo].[Jobs_t]    SET [JobStatus] = 'Pending'    WHERE ExperimentID = @currentID;    SELECT @currentID AS result <main.img>
This is the analogous code to main() is a C-like language. The first block, which has the "Connection Information" wire going into it, opens a .udl file and creates an ADO.NET _Connection reference, which is later used to invoke methods for the query.
<execute query.img>
This is the inside of the second block, the one with "EXE" and the pink wire going into it. The boxes with the gray border operate much like "switch" statements. The wire going into the "?" terminal on these boxes determines which case gets executed. The yellow boxes with white rectangels dropping down are invoke nodes and property nodes; they accept a reference to an object and allow you to invoke methods and read/write properties of that object. You can see the _Recordset object here as well. <fetch recordset.img>
Here's the next block to be executed, the one whose icon reads "FETCH ALL". We see that the first thing to execute on the far left grabs some properties of the recordset, and returns them in a "struct" (the pink wire that goes into the box that reads "state"). This is where the code fails. The recordset opened in the previous VI (virtual instrument) has a status of "closed", and the purple variant (seen under "Read all the data available") comes back empty.
The rest of the code is fairly irrelevant, as it's just converting the received variant into usable data, and freeing the recordset reference opened previously. My question is, why would the status from the query of the recordset be "closed"? I realize that recordsets are "closed" when the query returns no rows, but executing that query in SSMS returns good data. Also, executing the LabVIEW code does the UPDATE in the query, so I know that's not broken either.
What I need to do, is come up with a script that will determine which Polygon contains each point. I'd like to be able to assign a PolygonID to each record in the Point table, or give it a 0 if there is no polygon that contains that point.
I'm looking for a way to do this within SQL Server (or possibly with the use of an extended stored procedure if necessary).
I am working on a report which requires me to draw two polygons (rectangles) on a scatter chart to visually indicate "good" and "bad" ranges of plotted data. Is there a way to do this out-of-the-box?
Otherwise, if I must create a custom report item, how do I draw on the chart surface? I have looked at the following articles on Custom Report Items, but when I open the sample solutions I can't put the custom report items on the chart surface.
I have a table that contains spatial points and the name of the polygon they belong to (geography and varchar columns). I need to write a function to accept a point and determine which polygon contains that point. How can I write the query so that it will search through each polygon (derived from the geography points found in the table) and return the name of the polygon that contains that point?
Happy Friday! A while since I have posted a question, and this one is probably real easy. I am trying to store numeric values from a php form in MSSQL 2000 database. However, the columns are set to float and if the value is 1.00, when entered into the table it is saved as 1
If I change the column type to money, the query fails, with an error message of conversion of datatype varchar to datatype money statement terminated.
anybody know what I need to do? do I need to do something in my query to specify that this is NOT varchar data?
Not sure if this is possible, but maybe. I have a table that contains a bunch of logs. I'm doing something like SELECT * FROM LOGS. The primary key in this table is LogID. I have another table that contains error messages. Each LogID could have multiple error messages associated with it. To get the error messages. When I perform my first select query listed above, I would like one of the columns to be populated with ALL the error messages for that particular LogID (SELECT * FROM ERRORS WHERE LogID = MyLogID). Any thoughts as to how I could accomplish such a daring feat?
Hi, not exactly too sure if this can be done but I have a need to run a query which will return a list of values from 1 column. Then I need to iterate this list to produce the resultset for return. This is implemented as a stored procedure
declare @OwnerIdent varchar(7) set @OwnerIdent='A12345B'
SELECT table1.val1 FROM table1 INNER JOIN table2 ON table1. Ident = table2.Ident WHERE table2.Ident = @OwnerIdent
'Now for each result of the above I need to run the below query
SELECT Clients.Name , Clients.Address1 , Clients.BPhone, Clients.email FROM Clients INNER JOIN Growers ON Clients.ClientKey = Growers.ClientKey WHERE Growers.PIN = @newpin)
I know how to create mount point in windows 20003 cluster, I am not sure how to set it up with SQL 2005 running on the cluster. Does sql need to be dependant on any of the disks? I have tried looking for a guide, but cannot find.
current setup active active cluster running. I need to add san space which will hold the databases. The san will be carved up into drive letters. each drive letter will hold 3 mount points. ie. node 1 J:-2 mount point k:2 mount point l:2 mount point
node 2- r:-2 mount point s:2 mount point t:2 mount point
each node would be able to own the disk if the other node failed over.
any help is appreciate. I have tried books online etc.. cannot find a good step by step.;
HI All, I use MSSQL as my database and ASP.NET as my front application. I want to display Price value S$23.68. The dayatype I used is smallmoney, but it display: S$23.6800. HOw do I control the number of decimals point in the column of MSSQL?? Thanks a lot Suigion
I understand mount points help scalability in easier maintenance. By scalability do we mean more than 26 drive letters or it means adding more space to the same mount point letter on with more ease .
Can I add more space to a mountpoint if required later on by adding hard disks .
Also if one can give some pointers to good file group configuration guidelines / storage align partitions , it will be very much helpful
Further I my server CPU has 4 cores , will having 4 filegroups help me in improving system performance.
If SAN has 2 controllers , is it preferred to run data file partition on one controller and log file partition on another.
Hello, We have a requirement to be able to monitor mount points. The xp_fixeddrives does not support mount point monitoring. Is there another way to do it. Does microsoft working on updating the xp_fixeddrives. Let me know if anyone has any ideas how to monitor mount points.
When I run simple select against my view in Query Analyzer, I get result set in one sort order. The sort order differs, when I BCP the same view. Using third technique i.e. Select Into, I have observed the sort order is again different in the resulting table. My question is what is the difference in mechanisim of query analyzer, bcp, and select into. Thanks
Hi,I'm making a rating system that save the results in the database.I have 1 table with 3 columns:1) name2) points3) numberofvotesnow I want to select the 5 names with the best results. In other words the 5 best results when you do (points/numberofvotes)how can I say this in SQL? I hope someone can help me! thnx!
Previously I have posted about my problem with transaction logs. Threw my research I have found the truncate log at check point. I have also been lead to think that a check point could be a full back up. I have set this option to true and then performed a full back up. Afterward I have shrank the database to find the transaction log to still be over 43 gigs. Where have I gone astray?
Hi all, I'm trying to debug storedprocedures in query analyzer from workstation, login with server adminuser.Debugger is not stoping at break points. any help regarding this will be greatly appreciated. thanks.
DECLARE @EffLevels TABLE (ChangePoint int, Value Int)
INSERT@EffLevels SELECT'1000', '767' UNION ALL--Changed SELECT'1000', '675' UNION ALL SELECT'1001', '600' UNION ALL--Changed SELECT'1001', '545' UNION ALL SELECT'1001', '765' UNION ALL SELECT'1000', '673' UNION ALL--Changed SELECT'1002', '343' UNION ALL--Changed SELECT'1002', '413' UNION ALL SELECT'1002', '334' UNION ALL SELECT'1001', '823'--Changed
-- My Result should be -- ChangePointPrevChangePointValue -- 1000Null767 -- 1001 1000 675 -- 1000 1001 765 -- 1002 1000 343 -- 1001 1002 823
Hi allI have a large data set of points situated in 3d space. I have a simpleprimary key and an x, y and z value.What I would like is an efficient method for finding the group ofpoints within a threshold.So far I have tested the following however it is very slow.---------------select *from locations a full outer join locations bon a.ID < b.ID and a.X-b.X<2 and a.Y-b.Y<2 and a.Z-b.Z<2where a.ID is not null and b.ID is not null---------------If anyone knows of a more efficient method to arrive at this results itwould be most appreciated.Thanks in advanceBevan
Hi all, I am seeking your expertise to create SQL codes (SQL server 2005) that can help me to answer the problem below.
I have two tables (points and station), presented in form of SQL codes below. I€™d like to find the 6 closest panels for each of the station. As can be seen in the result table below, the 6 closest panel names are arranged from the first closest (P1) to the sixth closest (P6). Similar procedure also applies for the distance column arrangement. This distance column (D1 €“ D6) is the distance of panels P1 €“ P6 to the station. The distance between two points (with x-y coordinates) can be calculated using a simple Cartesian formula: Distance = ( (X1 €“ X2)2 + (Y1 - Y2)2 ) 0.5 . As the sample, distance between station €˜A€™ and panel €˜P19-04W€™ is = ((737606.383 - 737599.964)2 + (9548850.844 - 9548856.856)2) 0.5 = 8.79. The expected result of the work is presented in the table below:
Table 1: create table 1 ( Panels varchar(20), X_Coord float, Y_Coord float ) go set nocount on
insert into 1 values('P19-03E','737640.722','9548882.875') insert into 1 values('P19-04E','737630.166','9548868.3') insert into 1 values('P19-05E','737619.611','9548853.726') insert into 1 values('P19-06E','737609.054','9548839.15') insert into 1 values('P19-07E','737598.495','9548824.571') insert into 1 values('P19-08E','737587.941','9548809.998') insert into 1 values('P19-09E','737577.386','9548795.425') insert into 1 values('P19-10E','737563.359','9548776.163') insert into 1 values('P19-11E','737552.795','9548761.578') insert into 1 values('P19-12E','737542.256','9548746.919') insert into 1 values('P19-13E','737531.701','9548732.345') insert into 1 values('P19-14E','737521.146','9548717.772') insert into 1 values('P19-03W','737610.519','9548871.43') insert into 1 values('P19-04W','737599.964','9548856.856') insert into 1 values('P19-05W','737589.404','9548842.275') insert into 1 values('P19-06W','737578.849','9548827.702') insert into 1 values('P19-07W','737568.294','9548813.128') insert into 1 values('P19-08W','737554.274','9548793.77') insert into 1 values('P19-09W','737543.718','9548779.195') insert into 1 values('P19-10W','737533.157','9548764.614') insert into 1 values('P19-11W','737522.603','9548750.041')
set nocount off go
Table 2: create table 2 ( Station varchar(20), X_Coord float, Y_Coord float ) go set nocount on
insert into 2 values('A','737606.383','9548850.844') insert into 2 values('B','737575.41','9548806.838') insert into 2 values('C','737544.437','9548762.832')
The total quantity(sum(woitem.qtytarget) as total) result set is showing more than 6 numbers after the decimal point (example:442.2565485). How can I limit it to 2. (example:442.25)
select wo.num, sysuser.username,sum(woitem.qtytarget) as total from woitem join wo ON wo.id = woitem.woid Join moitem on moitem.id = woitem.moitemid Join mo ON mo.id = moitem.moid LEFT JOIN SYSUSER ON mo.userid = sysuser.id group by sysuser.username, num ORDER BY CAST( REPLACE( wo.num, ':', '.') as decimal(12, 3))
The parent table has the column OrderID which is the primary key. There is a unique non-clustered index in the same table with the same column and some included ones. A child table references the parent table on the OrderID column. Unfortunatelly, in the sys.foreign_keys table the index that has been used to acomplish the referential integrity is the unique non-clustered one instead of the primary key (which is the clustered index as well).
This is causing issues in some maintenance tasks where we need to disable all the indexes of the table apart from the clustered index. Disabling these indexes leeds to disabling the not properly configured foreign key as well. Maybe dropping the index create the constraint again and then recreate the index is a workarround but I wish to have something more elegant and future proof.