Search Results

Search found 28900 results on 1156 pages for 'sql 2005'.

Page 119/1156 | < Previous Page | 115 116 117 118 119 120 121 122 123 124 125 126  | Next Page >

  • Assign the results of a stored procedure into a variable in another stored procedure

    - by RHPT
    The title of this question is a bit misleading, but I couldn't summarize this very well. I have two stored procedures. The first stored procedure (s_proc1) calls a second stored procedure (s_proc2). I want to assign the value returned from s_proc2 to a variable in s_proc1. Currently, I'm calling s_proc2 (inside s_proc1) in this manner: EXEC s_proc2 @SiteID, @count = @PagingCount OUTPUT s_proc2 contains a dynamic query statement (for reasons I will not outline here). CREATE dbo.s_proc2 ( @siteID int, @count int OUTPUT ) AS DECLARE @sSQL nvarchar(100) DECLARE @xCount int SELECT @sSQL = 'SELECT COUNT(ID) FROM Authors' EXEC sp_ExecuteSQL @sSQL, N'@xCount int output', @xCount output SET @count = @xCount RETURN @count Will this result in @PagingCount having the value of @count? I ask because the result I am getting from s_proc1 is wonky. In fact, what I do get is two results. The first being @count, then the result of s_proc1 (which is incorrect). So, it makes me wonder if @PagingCount isn't being set properly. Thank you.

    Read the article

  • SQL Design Question regarding schema and if Name value pair is the best solution

    - by Aur
    I am having a small problem trying to decide on database schema for a current project. I am by no means a DBA. The application parses through a file based on user input and enters that data in the database. The number of fields that can be parsed is between 1 and 42 at the current moment. The current design of the database is entirely flat with there being 42 columns; some have repeated columns such as address1, address2, address3, etc... This says that I should normalize the data. However, data integrity is not needed at this moment and the way the data is shaped I'm looking at several joins. Not a bad thing but the data is still in a 1 to 1 relationship and I still see a lot of empty fields per row. So my concerns are that this does not allow the database or the application to be very extendable. If they want to add more fields to be parsed (which they do) than I'd need to create another table and add another foreign key to the linking table. The third option is I have a table where the fields are defined and a table for each record. So what I was thinking is to make a table that stores the value and then links to those two tables. The problem is I can picture the size of that table growing large depending on the input size. If someone gives me a file with 300,000 records than 300,000 x 40 = 12 million so I have some reservations. However I think if I get to that point than I should be happy it is being used. This option also allows for more custom displaying of information albeit a bit more work but little rework even if you add more fields. So the problem boils down to: 1. Current design is a flat file which makes extending it hard and it is not normalized. 2. Normalize the tables although no real benefits for the moment but requirements change. 3. Normalize it down into the name value pair and hope size doesn't hurt. There are a large number of inserts, updates, and selects against that table. So performance is a worry but I believe the saying is design now, performance testing later? I'm probably just missing something practical so any comments would be appreciated even if it’s a quick sanity check. Thank you for your time.

    Read the article

  • execute stored procedure as another user premission

    - by StuffHappens
    Hello. I faced the following problem: there's a user who has to execute a stored porcedure (spTest). In spTest's body sp_trace_generateevent is called. sp_trace_generateevent requires alter trace permissions and I don't want user to have it. So I would like user to be able to execute spTest. How can I do that? Thank you for your help.

    Read the article

  • Select records by comparing subsets

    - by devnull
    Given two tables (the rows in each table are distinct): 1) x | y z 2) x | y z ------- --- ------- --- 1 | a a 1 | a a 1 | b b 1 | b b 2 | a 1 | c 2 | b 2 | a 2 | c 2 | b 2 | c Is there a way to select the values in the x column of the first table for which all the values in the y column (for that x) are found in the z column of the second table? In case 1), expected result is 1. If c is added to the second table then the expected result is 2. In case 2), expected result is no record since neither of the subsets in the first table matches the subset in the second table. If c is added to the second table then the expected result is 1, 2. I've tried using except and intersect to compare subsets of first table with the second table, which works fine, but it takes too long on the intersect part and I can't figure out why (the first table has about 10.000 records and the second has around 10). EDIT: I've updated the question to provide an extra scenario.

    Read the article

  • Trigger on database using a web application and a winform application

    - by Michael
    Hello all, Situation: I have a web application which shows errors and where you can accept those error messages. I also have a service, which checks errors from a system and sets the error messages in the database. When I accept an error in the web application, i would like the service to know which error message has been accepted, so that it can do some other actions. My guess is that this could be done through some sort of trigger, but i can't figure out how. Can anyone help me with this?

    Read the article

  • XML Import how would you do it?

    - by Rico
    XML is used as one of our main integration points. it comes over by many clients at a time but too many clients importing at the same time can slow down our database to a crawl. Someone has to have solved a problem like this. I am basically using VB to parse through the data and import what i want and don't want. Is there a better way?

    Read the article

  • SQL Analysis Services - Dimension attributes with a "many" cardinality

    - by MonkeyBrother
    I am creating a cube with the following tables: Customer CustomerID, Name Customer Rep CustomerID, RepID Rep RepID, Name The important thing here is that there is a many to many relationship between Reps and Customers. I want to be able to ask the question "How much sales for customers working with rep 'A'?" In the data source view i set up the relationships between both customerid columns and both repid columns. I set up the rep attribute in the dimension builder and when I try to build the cube I get this error: Errors in the high-level relationship engine. the 'Rep' table that is required for a join cannot be reached based on the relationships in the data source view.

    Read the article

  • Is there a set based solution for this problem?

    - by NYSystemsAnalyst
    We have a table set up as follows: |ID|EmployeeID|Date |Category |Hours| |1 |1 |1/1/2010 |Vacation Earned|2.0 | |2 |2 |2/12/2010|Vacation Earned|3.0 | |3 |1 |2/4/2010 |Vacation Used |1.0 | |4 |2 |5/18/2010|Vacation Earned|2.0 | |5 |2 |7/23/2010|Vacation Used |4.0 | The business rules are: Vacation balance is calculated by vacation earned minus vacation used. Vacation used is always applied against the oldest vacation earned amount first. We need to return the rows for Vacation Earned that have not been offset by vacation used. If vacation used has only offset part of a vacation earned record, we need to return that record showing the difference. For example, using the above table, the result set would look like: |ID|EmployeeID|Date |Category |Hours| |1 |1 |1/1/2010 |Vacation Earned|1.0 | |4 |2 |5/18/2010|Vacation Earned|1.0 | Note that record 2 was eliminated because it was completely offset by used time, but records 1 and 4 were only partially used, so they were calculated and returned as such. The only way we have thought of to do this is to get all of the vacation earned records in a temporary table. Then, get the total vacation used and loop through the temporary table, deleting the oldest record and subtracting that value from the total vacation used until the total vacation used is zero. We could clean it up for when the remaining vacation used is only part of the oldest vacation earned record. This would leave us with just the outstanding vacation earned records. This works, but it is very inefficient and performs poorly. Also, the performance will just degrade over time as more and more records are added. Are there any suggestions for a better solution, preferable set based? If not, we'll just have to go with this.

    Read the article

  • Multipart Identifier And Functions

    - by The King
    Here is my Query... Here I'm using a function Fn_getStagesForProject()... For which I need to pass the SWProjectID from Projects Table... The function takes the ID as parameter and return all stages that corressponds to the project, on which I need to filer only the row that contains StageLevel as 0. Select A.SWProjectID, A.ShortTitle, C.StageName as StageName, B.ExpectedCompletionDate as BudgetedReleaseDate From Projects as A left outer join ProjectBudgets as B on A.SWProjectID = B.SWProjectID Left outer join Fn_getStagesForProject(Projects.SWProjectID) as C on B.StageID = C.StageID Where C.StageLevel = 0 The error is The multi-part identifier "Projects.SWProjectID" could not be bound. I tried changing it to A.SWProjectID, but I still get the error... Thanks in advance for your help. Let me know, incase you need the Table Structure Raja

    Read the article

  • Modifying SQL XML ?olumn

    - by Chinjoo
    I have an XML column in one of my table. For example I have an Employee table with following fields: Name (varhcar) | Address (XML) The Address field is having values like <Address> <Street></Street> <City></City> </Address> I have some n number of rows already in the table. Now I want to insert a new node - Country to all the rows in tha table. With default: <Country>IND</Country>. How can I write the query for this. I want all the existing data to be as it is with adding the country node to all the Address column XML.

    Read the article

  • Need a set based solution to group rows

    - by KM
    I need to group a set of rows based on the Category column, and also limit the combined rows based on the SUM(Number) column to be less than or equal to the @Limit value. For each distinct Category column I need to identify "buckets" that are <=@limit. If the SUM(Number) of all the rows for a Category column are <=@Limit then there will be only 1 bucket for that Category value (like 'CCCC' in the sample data). However if the SUM(Number)@limit, then there will be multiple bucket rows for that Category value (like 'AAAA' in the sample data), and each bucket must be <=@Limit. There can be as many buckets as necessary. Also, look at Category value 'DDDD', its one row is greater than @Limit all by itself, and gets split into two rows in the result set. Given this simplified data: DECLARE @Detail table (DetailID int primary key, Category char(4), Number int) SET NOCOUNT ON INSERT @Detail VALUES ( 1, 'AAAA',100) INSERT @Detail VALUES ( 2, 'AAAA', 50) INSERT @Detail VALUES ( 3, 'AAAA',300) INSERT @Detail VALUES ( 4, 'AAAA',200) INSERT @Detail VALUES ( 5, 'BBBB',500) INSERT @Detail VALUES ( 6, 'CCCC',200) INSERT @Detail VALUES ( 7, 'CCCC',100) INSERT @Detail VALUES ( 8, 'CCCC', 50) INSERT @Detail VALUES ( 9, 'DDDD',800) INSERT @Detail VALUES (10, 'EEEE',100) SET NOCOUNT OFF DECLARE @Limit int SET @Limit=500 I need one of these result set: DetailID Bucket | DetailID Category Bucket -------- ------ | -------- -------- ------ 1 1 | 1 'AAAA' 1 2 1 | 2 'AAAA' 1 3 1 | 3 'AAAA' 1 4 2 | 4 'AAAA' 2 5 3 OR 5 'BBBB' 1 6 4 | 6 'CCCC' 1 7 4 | 7 'CCCC' 1 8 4 | 8 'CCCC' 1 9 5 | 9 'DDDD' 1 9 6 | 9 'DDDD' 2 10 7 | 10 'EEEE' 1

    Read the article

  • linq2sql left join with "multiselect"

    - by just_azho
    Hi, folks I'm trying to achieve following by linq2sql, but not successful. I've Member and Reference tables. DB is design in such a manner that Member can have multiple (=0) References. What I want as a result of query is, list (rows) of members, where all references of the member are "collected" in one column. What I had achieved is following query, but for this one there exist a row for each Reference. var refs = (from m in db.Members join r in db.References on m.PID equals r.PID into g from o in g.DefaultIfEmpty() select new { member = m, name = (o == null ? "" : o.NameSurname) }); I feel I need to insert SelectMany somewher :) Could you please give hints on achieving the goal?

    Read the article

  • check for null date in CASE statement, where have I gone wrong?

    - by James.Elsey
    Hello, My source table looks like this Id StartDate 1 (null) 2 12/12/2009 3 10/10/2009 I want to create a select statement, that selects the above, but also has an additional column to display a varchar if the date is not null such as : Id StartDate StartDateStatus 1 (null) Awaiting 2 12/12/2009 Approved 3 10/10/2009 Approved I have the following in my select, but it doesn't seem to be working. All of the statuses are set to Approved even though the dates have some nulls select id, StartDate, CASE StartDate WHEN null THEN 'Awaiting' ELSE 'Approved' END AS StartDateStatus FROM myTable The results of my query look like : Id StartDate StartDateStatus 1 (null) Approved 2 12/12/2009 Approved 3 10/10/2009 Approved 4 (null) Approved 5 (null) Approved StartDate is a smalldatetime, is there some exception to how this should be treated? Thanks

    Read the article

< Previous Page | 115 116 117 118 119 120 121 122 123 124 125 126  | Next Page >