Search Results

Search found 37012 results on 1481 pages for 'sql query'.

Page 63/1481 | < Previous Page | 59 60 61 62 63 64 65 66 67 68 69 70  | Next Page >

  • Convert XML to table in SQL Server 2005.

    - by Tamim Sadikali
    If I pass in an xml parameter to a stored proc which looks like this: <ClientKeys> <ck>3052</ck> <ck>3051</ck> <ck>3050</ck> <ck>3049</ck> ... </ClientKeys> ...and then convert the XML to a temp table like this: CREATE TABLE #ClientKeys ( ClientKey varchar(36) ) INSERT INTO #ClientKeys (ClientKey) SELECT ParamValues.ck.value('.','VARCHAR(36)') FROM @ClientKeys.nodes('/ClientKeys/ck') as ParamValues(ck) ...the temp tbl is populated and everything is good. However the time taken to populate said table is strictly proportionate to the number of 'ck' elements in the xml - which I wasn't expecting as there is no iterative step. And thus the time taken to populate the tbl soon becomes 'too long'. Is there a quicker way to achieve the above?

    Read the article

  • Moving a Point along a Path in SQL Server 2008

    - by David Pfeffer
    I have a geography field stored in my database, holding a linestring path. I want to move a point n meters along this linestring, and return the destination. For example, I want the destination point 500 meters along the linestring starting from its beginning. Here's an example -- what is the YourFunctionHere? Or, is there another way? DECLARE @g geography; SET @g = geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656, -122.310 47.690)', 4326); SELECT @g.YourFunctionHere(100).ToString();

    Read the article

  • Dynamically determining table name given field name in SQL server

    - by Salman A
    Strange situation: I am trying to remove some hard coding from my code. There is a situation where I have a field, lets say "CityID", and using this information, I want to find out which table contains a primary key called CityID. Logically, you'd say that it's probably a table called "City" but it's not... that table is called "Cities". There are some other inconsistencies in database naming hence I can never be sure if removing the string "ID" and finding out the plural will be sufficient. Note: Once I figure out that CityID refers to a table called Cities, I will perform a join to replace CityID with city name on the fly. I will appreciate if someonw can also tell me how to find out the first varchar field in a table given its name.

    Read the article

  • SQL Server: "Mostly-unique" index

    - by Ian Boyd
    In a table i want to ensure that only unique vales exist over the five-column key: Timestamp Account RatingDate TripHistoryKey EventAction ========= ======= ========== ============== =========== 2010511 1234 2010511 1 INSERT 2010511 1234 2010511 4 INSERT 2010511 1234 2010511 7 INSERT 2010511 1234 2010511 1 INSERT <---duplicate But i only want the unique constraint to apply between rows when EventAction is INSERT: Timestamp Account RatingDate TripHistoryKey EventAction ========= ======= ========== ============== =========== 2010511 1234 2010511 1 INSERT 2010511 1234 2010511 1 UPDATE 2010511 1234 2010511 1 UPDATE <---not duplicate 2010511 1234 2010511 1 UPDATE <---not duplicate 2010511 1234 2010511 1 DELETE <---not duplicate 2010511 1234 2010511 1 DELETE <---not duplicate 2010511 1234 2010511 1 INSERT <---DUPLICATE Possible?

    Read the article

  • Contains performs MUCH slower with variable vs constant string MS SQL Server

    - by Greg R
    For some unknown reason I'm running into a problem when passing a variable to a full text search stored procedure performs many times slower than executing the same statement with a constant value. Any idea why and how can that be avoided? This executes very fast: SELECT * FROM table WHERE CONTAINS (comments, '123') This executes very slowly and times out: DECLARE @SearchTerm nvarchar(30) SET @SearchTerm = '123' SET @SearchTerm = '"' + @SearchTerm + '"' SELECT * FROM table WHERE CONTAINS (comments, @SearchTerm) Does this make any sense???

    Read the article

  • t-sql pivot filter based on input column name

    - by stackoverflowuser
    Based on following AreaState table Area State ------------------- A1 Active A1 Active A1 Active A1 Proposed A1 Proposed A2 Active A2 Proposed I want to write a stored proc that returns count of state for each of the areas. Input to the stored proc is any valid State (in this case @state is the input parameter). I was hoping that below would work but it does not. declare @state varchar(10) set @state = 'Active' select Area, QUOTENAME(@state) from ( select Area, State from AreaState ) as src pivot ( count(State) for State in (QUOTENAME(@state)) ) as pvt Pls. suggest.

    Read the article

  • SQL Duplicates Issue SQL SERVER 2000

    - by jeff
    I have two tables : Product and ProductRateDetail. The parent table is Product. I have duplicate records in the product table which need to be unique. There are entries in the ProductRateDetail table which correspond to duplicate records in the product table. Somehow I need to update the ProductRateDetail table to match the original (older) ID from the Product table and then remove the duplicates from the product table. I would do this manually but there are 100's of records. i.e. something like UPDATE tbl_productRateDetail SET productID = (originalID from tbl_product) then something like DELETE from tbl_product WHERE duplicate ID and only delete the recently added ID data example: (sorry can't work out this formatting thing) tbl_Product select * from dbo.Product where ProductCode = '10003' ProductID ProductTypeID ProductDescription ProductCode ProductSize 365 1 BEND DOUBLE FLANGED 10003 80mmX90deg 1354 1 BEND DOUBLE FLANGED 10003 80mmX90deg tbl_ProductRateDetail SELECT * FROM [MSTS2].[dbo].[ProductRateDetail] WHERE ProductID in (365,1354) ProductRateDetailID ProductRateID ProductID UnitRate 365 1 365 16.87 1032 5 365 16.87 2187 10 365 16.87 2689 11 365 16.87 3191 12 365 16.87 7354 21 1354 21.30 7917 22 1354 21.30 8480 23 1354 21.30 9328 25 1354 21.30 9890 26 1354 21.30 10452 27 1354 21.30 Please help!

    Read the article

  • SQL SERVER Project

    - by Saif Omari
    My Application Database Without Project and without Source safe, i planned to make my DB to be as project and add it to TFS, but I have no idea how to script the stored procedures, Triggers, Views, Functions, and what is the best practice to Make Update Script for All My stored procedures, Triggers, Views, and Functions to My customers DB.

    Read the article

  • mod_rewrite to redirect URL with query string

    - by meeble
    I've searched all over stackoverflow, but none of the answers seem to be working for this situation. I have a lot of working mod_rewrite rules already in my httpd.conf file. I just recently found that Google had indexed one of my non-rewritten URLs with a query string in it: http://domain.com/?state=arizona I would like to use mod_rewrite to do a 301 redirect to this URL: http://domain.com/arizona The issue is that later on in my rewrite rules, that 2nd URL is being rewritten to pass query variables on to WordPress. It ends up getting rewritten to: http://domain.com/index.php?state=arizona Which is the proper functionality. Everything I have tried so far has either not worked at all or put me in an endless rewrite loop. This is what I have right now, which is getting stuck in a loop: RewriteCond %{QUERY_STRING} state=arizona [NC] RewriteRule .* http://domain.com/arizona [R=301,L] #older rewrite rule that passes query string based on URL: RewriteRule ^([A-Za-z-]+)$ index.php?state=$1 [L] which gives me an endless rewrite loop and takes me to this URL: http://domain.com/arizona?state=arizona I then tried this: RewriteRule .* http://domain.com/arizona? [R=301,L] which got rid of the query string in the URL, but still creates a loop.

    Read the article

  • Licensing SQL Server 2012 Reporting Services w/ SharePoint 2010

    - by Evan M.
    Here's my situation: I have 1 VM that is running SharePoint 2010 SP1. I have a different physical server that is running SQL Server 2008 R2 that hosts all the configuration and content database for SharePoint. Now, we want to start providing BI capabilities to our users with SharePoint and SQL Server. With it's new features, 2012 is the obvious way to go. To support this, I'm looking to build a new VM that will have SQL Server 2012 installed w/ Analysis services and SSIS, which will be the platform that gets our data from our Oracle databases, puts it in a warehouse hosted by the SQL 2012 instance, and is put into cubes. What's getting me about the platform is licensing for Reporting Services and PowerPivot. My plan was to install SSRS and PowerPivot on the current SharePoint server. But my understanding of the licensing means that instead of the new SQL server being licensed, I'd have to license both new server, and the SharePoint server. Conversely, I could install SharePoint onto the SQL server, and only have to get a second SP license, but then I'd have the added complexity of deploying a separated application server, and combines my data and application servers. Is my licensing understanding correct, or can I have SSRS and PowerPivot installed separately without incurring additional licensing costs?

    Read the article

  • Passing delimited string to stored procedure to search database

    - by rs
    How can i pass a string delimited by space or comma to stored procedure and filter result? I'm trying to do something like - Parameter Value -------------------------- @keywords key1 key2 key3 Then is stored procedure i want to first find all records with first or last name like key1 filter step 1 with first or last name like key2 filter step 2 with first or last name like key 3

    Read the article

  • SQL server 2008 trigger not working correct with multiple inserts

    - by Rob
    I've got the following trigger; CREATE TRIGGER trFLightAndDestination ON checkin_flight AFTER INSERT,UPDATE AS BEGIN IF NOT EXISTS ( SELECT 1 FROM Flight v INNER JOIN Inserted AS i ON i.flightnumber = v.flightnumber INNER JOIN checkin_destination AS ib ON ib.airport = v.airport INNER JOIN checkin_company AS im ON im.company = v.company WHERE i.desk = ib.desk AND i.desk = im.desk ) BEGIN RAISERROR('This combination of of flight and check-in desk is not possible',16,1) ROLLBACK TRAN END END What i want the trigger to do is to check the tables Flight, checkin_destination and checkin_company when a new record for checkin_flight is added. Every record of checkin_flight contains a flightnumber and desknumber where passengers need to check in for this destination. The tables checkin_destination and checkin_company contain information about companies and destinations restricted to certain checkin desks. When adding a record to checkin_flight i need information from the flight table to get the destination and flightcompany with the inserted flightnumber. This information needs to be checked against the available checkin combinations for flights, destinations and companies. I'm using the trigger as stated above, but when i try to insert a wrong combination the trigger allows it. What am i missing here?

    Read the article

  • SQL Temp Tables & Replication

    - by Refracted Paladin
    I have had an issue with our replication process and would like to salvage some data. I have a process in place where I will connect to each subscriber before flagging them for reinitialization and I will run the below to pull any data they may have entered in during the "dark time". I am pretty sure this will work in a vanilla palace. What I am unsure of is whether the Global Temporary Table will persist through DB Replication. To be clear, I am not trying to Replicate the TempTable, I just want to make sure it will still exist at the local DB after the Replication so I may run the INSERT from it. Thoughts? USE MemberCenteredPlan -- Select Data from tblPLan SELECT * INTO ##MyPlan FROM tblPlan WHERE PlanID = 407869 --------------------------- -- Run Replication Process --------------------------- -- Insert Plan back into DB INSERT INTO tblPlan SELECT * FROM ##MyPlan WHERE PlanID = 407869 -- Drop Global Temp Table DROP TABLE ##MyPlan --------------------------- -- Run Replication Process ---------------------------

    Read the article

  • SQL Server / T-SQL : How to update equal percentages of a resultset?

    - by Kent Comeaux
    I need a way to take a resultset of KeyIDs and divide it up as equally as possible and update records differently for each division based on the KeyIDs. In other words, there is SELECT KeyID FROM TableA WHERE (some criteria exists) I want to update TableA 3 different ways by 3 equal portions of KeyIDs. UPDATE TableA SET FieldA = Value1 WHERE KeyID IN (the first 1/3 of the SELECT resultset above) UPDATE TableA SET FieldA = Value2 WHERE KeyID IN (the second 1/3 of the SELECT resultset above) UPDATE TableA SET FieldA = Value3 WHERE KeyID IN (the third 1/3 of the SELECT resultset above) or something to that effect. Thanks for any and all of your responses.

    Read the article

  • How to update a single table using trigger in MS SQL 2008

    - by Yakob-Jack
    I have a table PeroidicDeduction and the fields are ID(auto-increment),TotalDeduction(e.g.it can be loan),Paid(on which the deduction for each month),RemainingAmount, What I want is when every time I insert or update the table---RemainingAmount will get the value of TotalDeduction-SUM(Paid)....and writ the following trigger...but dosen't work for me CREATE TRIGGER dbo.UpdatePD ON PeroidicDedcution AFTER INSERT,UPDATE AS BEGIN UPDATE PeroidicDedcution SET REmaininAmoubnt=(SELECT TotalDeduction-(SELECT SUM(Paid) FROM PeroidicDeduction) FROM PeroidicDeduction) END NOTE: it is on a Single table

    Read the article

  • Update Multiple Tables at a Time - SQL Server/T-SQL

    - by peace
    I have two tables, Customer and CustomerPhone. Single record in Customer can have multiple CustomerPhone records. As you see in the image below, Phone and Fax resides in CustomerPhone table whereas the rest of the fields resides in Customer table. If user want to edits a customer record, obviously i will have to update the record in Customer table and at least two records from CustomerPhone (Phone and Fax). I could write two update statements, one Update customerPhone and the second update Customer table. Is there a better solution?

    Read the article

  • Passing dynamic parameters to a stored procedure in SQL Server 2008

    - by themhz
    I have this procedure that executes another procedure passed by a parameter and its parameters datefrom and dateto. CREATE procedure [dbo].[execute_proc] @procs varchar(200), @pdatefrom date, @pdateto date as exec @procs @datefrom=@pdatefrom,@dateto=@pdateto But I need to also pass the parameters dynamically without the need to edit them in the procedure. For example, what I am imagining is something like this CREATE procedure [dbo].[execute_proc] @procs varchar(200), @params varchar(max) as exec @procs @params where @params is a string like @param1=1,@param2='somethingelse' Is there a way to do this?

    Read the article

  • SQL Server 2008 : Standard or SQL Express

    - by dr
    Which is a better choice on a development box if you primarily develop Asp.Net applications and SSRS reports. I have never had to use the Express editions, so I don't really know the pros or cons. The cons I have listed for Standard+ editions are: toll it takes on system resources pain to attach database for projects pain to detach unused databases $$$ Pros: You have everything you need Management Studio features Easy move to production

    Read the article

  • Is there a way to prevent Triggers from being disabled?

    - by HAdes
    I have a trigger on a table that should never be disabled. It performs certain checks and there have been occasions when other developers have disabled it to get around it. This is not good so I want to be able to turn off trigger disablement on this table alone. Is this possible? If not, any suggestions please. thanks.

    Read the article

  • How to switch sql-2005 Select Case When T-sql Naming?

    - by soe
    select (Case Remark01 When 'l1' then type1 when 'l2' then type2 end) AS [?] --Remark .....want to switch name in here from mytable Example .... select (Case level When 'l1' then type1 ('l1' mean check constant string) when 'l2' then type2(('l2' mean check constant string)) end) AS (Case when 'l1' then [type01] Else [type02]) from mytable select level,type1,type2 from mytable I using two program this mytable one program is want to show menu only type1 only one program is want to show menu only type2 only I using one view using two program..

    Read the article

< Previous Page | 59 60 61 62 63 64 65 66 67 68 69 70  | Next Page >