Search Results

Search found 28297 results on 1132 pages for 'sql azure'.

Page 154/1132 | < Previous Page | 150 151 152 153 154 155 156 157 158 159 160 161  | Next Page >

  • T-SQL Question : Query to XML

    - by Juvil John Soriano
    anyone can show me how to generate from this data ------------------------DATA-------------------------- Key ParentKey 5 NULL 25 5 33 25 26 5 27 5 34 27 28 5 29 5 to this XML result? ---------------------RESULTS-------------------------- <record key="5" parentkey = ""> <record key="25" parentkey = "5"> <record key="33" parentkey = "25"></record> </record> </record> <record key="25" parentkey = "5"> <record key="26" parentkey = "5"> <record key="27" parentkey = "5"> <record key="34" parentkey = "27"></record> </record> </record> <record key="28" parentkey = "5"> <record key="29" parentkey = "5"> </record>

    Read the article

  • SQL ENQUIRY In how to Get defined number of records

    - by ramadan2050
    I have a select statement, retrieve about 1000 record I want to modify it to return only some records defined by @startIndex and @count e.g. : If I said @startIndex=20 and @count=20 the result will be : from the 21th record to 40th I try to make it, but it take the same time as if I retrieve the 1000 record what is the best way to do that

    Read the article

  • How to write stored procedure to do this?

    - by chobo
    I would like to create a stored procedure that takes in a string of comma separated values like this "1,2,3,4", and break it apart and use those numbers to run a query on a different table. so in the same stored procedure it would do something like select somefield from sometable where somefield = 1 select somefield from sometable where somefield = 2 select somefield from sometable where somefield = 3 select somefield from sometable where somefield = 4 Thanks!

    Read the article

  • T-SQL 2005 - Divide by zero error encountered

    - by Grant
    Hi, I am trying to get some percentage data from a stored procedure using code similar to the line below. Obviously this is going to cause a (Divide by zero error encountered) problem when base.[XXX_DataSetB] returns 0 which may happen some of the time. Does anyone know how i can deal with this in the most efficient manner? Note: There would be about 20+ lines looking like the one below... cast((base.[XXX_DataSetB] - base.[XXX_DataSetA]) as decimal) / base.[XXX_DataSetB] as [XXX_Percentage]

    Read the article

  • Permissions for Large Variables to Be Sent Via Stored Procedures (SQL Server)

    - by Joe Majewski
    I can't figure out a way to allow more than 4000 bytes to be received at once via a call to a stored procedure. I am storing images in the table that are around 15 - 20 kilobytes each, but upon getting them and displaying them to the page, they are always exactly 3.91 KB in size (or 4000 bytes). Do stored procedures have a limit on how much data can be sent at once? I double-checked my data, and I am indeed only receiving the first 4000 characters from the varbinary(MAX) field. Is there a permission setting to allow more than 4k bytes at once?

    Read the article

  • Tsql to find the start and end date(set based)

    - by priyanka.sarkar_2
    I have the below Name Date A 2011-01-01 01:00:00.000 A 2011-02-01 02:00:00.000 A 2011-03-01 03:00:00.000 B 2011-04-01 04:00:00.000 A 2011-05-01 07:00:00.000 The desired output being Name StartDate EndDate ------------------------------------------------------------------- A 2011-01-01 01:00:00.000 2011-04-01 04:00:00.000 B 2011-04-01 04:00:00.000 2011-05-01 07:00:00.000 A 2011-05-01 07:00:00.000 NULL How to achieve the same using TSQL in Set based approach DDL is as under DECLARE @t TABLE(PersonName VARCHAR(32), [Date] DATETIME) INSERT INTO @t VALUES('A', '2011-01-01 01:00:00') INSERT INTO @t VALUES('A', '2011-01-02 02:00:00') INSERT INTO @t VALUES('A', '2011-01-03 03:00:00') INSERT INTO @t VALUES('B', '2011-01-04 04:00:00') INSERT INTO @t VALUES('A', '2011-01-05 07:00:00') Select * from @t

    Read the article

  • sql server 2008

    - by tom
    Hi, I am trying to create a trigger for a cinema database. I need it to update once a rating is added for a movie showing the text "rating added". The table name is movie_ratings the primary key is = movie_rating I am not really sure how to do it, I have looked online but still are not too sure. I was wondering if anyone could help. Thanks

    Read the article

  • SQL SERVER Spatial Data

    - by Sam
    Hi All, I am struggeling finding an effectient way to find a distance between a Point that interetcts a polygon and the border of that polygon. I was able to use the STDistance comparing the point to every point that made up the polygon but that is taking a lot of time. Using SPatial indexed wasnt much helpful because the STDistance is not part of any constraint and even when I did put the constraint, the index didnt help much. I appreciate any feedback. Thanks.

    Read the article

  • An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING cla

    - by brz dot net
    I have to find the indentid from the status table based on below two conditions: 1. If there are more than one record having same indentid in status table and the same indentID has count1 in feasibilitystatus table then I don't want to display the record. 2. If there is only one record of indentid in status table and the same indentID has count0 in feasibilitystatus table then I don't want to display the record. Query: select distinct s.indentid from status s where s.status='true' and s.indentid not in(select case when count(s.indentid)>1 then (select indentid from feasibilitystatus group by indentid having count(indentid)>1) else (select indentid from feasibilitystatus group by indentid having count(indentid)>0) end as indentid from status) Error: An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference.

    Read the article

  • Next Identity Key LINQ + SQL Server

    - by user569347
    To represent our course tree structure in our Linq Dataclasses we have 2 columns that could potentially be the same as the PK. My problem is that if I want to Insert a new record and populate 2 other columns with the PK that was generated there is no way I can get the next identity and stop conflict with other administrators who might be doing the same insert at the same time. Case: A Leaf node has right_id and left_id = itself (prereq_id) **dbo.pre_req:** prereq_id left_id right_id op_id course_id is_head is_coreq is_enforced parent_course_id and I basically want to do this: pre_req rec = new pre_req { left_id = prereq_id, right_id = prereq_id, op_id = 3, course_id = query.course_id, is_head = true, is_coreq = false, parent_course_id = curCourse.course_id }; db.courses.InsertOnSubmit(rec); try { db.SubmitChanges(); } Any way to solve my dilemma? Thanks!

    Read the article

  • Comparing date range quarters sql server

    - by CR41G14
    I have a policies in a system PolRef Start End POL123 22/11/2012 23/12/2014 POL212 24/09/2012 23/10/2012 POL214 23/08/2012 29/09/2012 I am asking a user for a reporting date, the user enters 24/10/2012 this becomes @StartDate From this I derive what the quarter is by the month: set @currentMonth = Month(@StartDate) if @currentMonth = 1 or @currentMonth = 2 or @currentMonth = 3 begin set @startmonth = 1 set @endmonth = 3 end if @currentMonth = 4 or @currentMonth = 5 or @currentMonth = 6 begin set @startmonth = 4 set @endmonth = 6 end if @currentMonth = 7 or @currentMonth = 8 or @currentMonth = 9 begin set @startmonth = 7 set @endmonth = 9 end if @currentMonth = 10 or @currentMonth = 11 or @currentMonth = 12 begin set @startmonth = 10 set @endmonth = 12 end I then get a date range: @quarterStartDate = CAST(CAST(YEAR(@StartDate) AS varchar) + '-' + CAST(@startMonth AS varchar) + '-' + '01') AS Date) @quarterEndDate = CAST(CAST(YEAR(@EcdDate) AS varchar) + '-' + CAST(@endMonth AS varchar) + '-' + '31') AS Date) This will give me 01-10-2012 and 31-12-2012. Basically I need a script to only bring back the policies that are in this quarter. The policy doesn't have to span the entire quarter date range, just exist in the quarter date range. The results expected would be PolRef Start End POL123 22/11/2012 23/12/2014 POL212 24/09/2012 23/10/2012 Pol123 appears because it spans over the quarterly date range. Pol212 is there because it expires in that quarter date range. Pol214 does not appear because it neither spans, expires or starts in this quarter. Any help would be greatly appreciated

    Read the article

  • Sql server Identity issue

    - by pranay
    I have query like below declare @str_CustomerID int Insert into IMDECONP38.[Customer].dbo.CustomerMaster ( CustomerName , CustomerAddress , CustomerEmail , CustomerPhone ) values ( ‘werw12e’ , ‘jkj12kj’ , ‘3212423sdf’ , ‘1212121' ) select @str_CustomerID= scope_identity() after execution it returns null in my parameter i want to get value of identity how can i do that

    Read the article

  • SQL Full Outer Join

    - by Torment March
    I have a table named 'Logs' with the following values : CheckDate CheckType CheckTime ------------------------------------------- 2011-11-25 IN 14:40:00 2011-11-25 OUT 14:45:00 2011-11-25 IN 14:50:00 2011-11-25 OUT 14:55:00 2011-11-25 IN 15:00:00 2011-11-25 OUT 15:05:00 2011-11-25 IN 15:15:00 2011-11-25 OUT 15:20:00 2011-11-25 IN 15:25:00 2011-11-25 OUT 15:30:00 2011-11-25 OUT 15:40:00 2011-11-25 IN 15:45:00 I want to use the previous table to produce a result of: CheckDate CheckIn CheckOut ----------------------------------------- 2011-11-25 14:40:00 14:45:00 2011-11-25 14:50:00 14:55:00 2011-11-25 15:00:00 15:05:00 2011-11-25 15:15:00 15:20:00 2011-11-25 15:25:00 15:30:00 2011-11-25 NULL 15:40:00 2011-11-25 15:45:00 NULL So far I have come up with this result set : CheckDate CheckIn CheckOut ----------------------------------------- 2011-11-25 14:40:00 14:45:00 2011-11-25 14:50:00 14:55:00 2011-11-25 15:00:00 15:05:00 2011-11-25 15:15:00 15:20:00 2011-11-25 15:25:00 15:30:00 2011-11-25 15:45:00 NULL The problem is I cannot generate the log without CheckIns : CheckDate CheckIn CheckOut ----------------------------------------- 2011-11-25 NULL 15:40:00 The sequence of CheckIn - CheckOut pairing and order is in increasing time value.

    Read the article

  • SQL Server, View using multiple select statements

    - by phil
    I've banging my head for hours, it seems simple enough, but here goes: I'd like to create a view using multiple select statements that outputs a Single record-set Example: CREATE VIEW dbo.TestDB AS SELECT X AS 'First' FROM The_Table WHERE The_Value = 'y' SELECT X AS 'Second' FROM The_Table WHERE The_Value = 'z' i wanted to output the following recordset: Column_1 | Column_2 'First' 'Second' any help would be greatly appreciated! -Thanks.

    Read the article

  • Sql Server Development Server and Live

    - by Chris
    I have a database project that goes through iterations (only one so far) and I need to deploy a testing version to a live server. I'm not sure how to go about this. I can make all the changes in a copy and then remake those changes in the live version. That doesn't make sense. Is there a way to change a server name to an existing server? What's the best practice for this scenario?

    Read the article

  • Dynamically changing databases in SQL Server 2000

    - by spuppett
    At work we have a number of databases that we need to do the same operations on. I would like to write 1 SP that would loop over operations and set the database at the beginning of the loop (example to follow). I've tried sp_executesql('USE ' + @db_id) but that only sets the DB for the scope of that stored procedure. I don't really want to loop with hard coded database names because we need to do similar things in many different places and it's tough to remember where things need to change if we add another DB. Any thoughts Example: DECLARE zdb_loop CURSOR FAST_FORWARD FOR SELECT distinct db_id from DBS order by db_id OPEN zdb_loop FETCH NEXT FROM zdb_loop INTO @db_id WHILE @@FETCH_STATUS = 0 BEGIN USE @db_id --Do stuff against 3 or 4 different DBs FETCH NEXT FROM zdb_loop INTO @db_id END CLOSE zdb_loop DEALLOCATE zdb_loop

    Read the article

  • Need help in understanding a SELECT query

    - by Grant Smith
    I have a following query. It uses only one table (Customers) from Northwind database. I completely have no idea how does it work, and what its intention is. I hope there is a lot of DBAs here so I ask for explanation. particularly don't know what the OVER and PARTITION does here. WITH NumberedWomen AS ( SELECT CustomerId ,ROW_NUMBER() OVER ( PARTITION BY c.Country ORDER BY LEN(c.CompanyName) ASC ) women FROM Customers c ) SELECT * FROM NumberedWomen WHERE women > 3 If you needed the db schema, it is here

    Read the article

  • How many Stored Procedures created everyday ( problem in converting Datetime )?

    - by Space Cracker
    I make a query that return to me the count of Stored Procedure that created everyday as follow SELECT convert(varchar, crdate, 103) as Date,Count(*) as Counter FROM sysobjects WHERE (xtype = 'p') AND (name NOT LIKE 'dt%') Group by convert(varchar, crdate, 103) and its already work but dates appear in string format that i can't order it such as below 01/03/2010 3 01/04/2008 4 01/05/2010 5 01/11/2008 1 01/12/2008 4 02/03/2008 1 02/03/2010 2 02/04/2008 4 02/05/2010 2 02/11/2008 2 02/11/2009 2 02/12/2008 4 03/01/2010 1 03/02/2010 2 03/03/2010 2 03/04/2008 2 03/04/2010 2 03/05/2008 1 03/05/2010 2 I want to make that in which date is in datetime format that i can make order by successfully, i tried convert(datetime, crdate, 103) but it show Full date any idea of how to do ?

    Read the article

  • Conversion failed when converting the varchar value to data type int

    - by desi
    *I have a varchar(1000) column declared as field that contains all numbers, as shown below. And I want to execute the following script. I need this to work please Declare @PostalCode varchar(1000)=0 set @PostalCode ='7005036,7004168,7002314,7001188,6998955' Select hl.* From CountryLocation cl INNER JOIN refPostalCodes pc ON pc.PostalCode = hl.PostalCode where pc.Postalcode in (@PostalCode) and pc.notDeleted = 1

    Read the article

< Previous Page | 150 151 152 153 154 155 156 157 158 159 160 161  | Next Page >