Forum Replies Created

Viewing 12 posts - 2,026 through 2,037 (of 2,037 total)

  • RE: XML String Process

    Hello James

    Why the detour over the line by line cursor?

    DECLARE @xml xml

    SELECT @xml = BulkColumn FROM OPENROWSET(

    BULK 'D:\Temp\Test\test.xml',

    SINGLE_BLOB) AS x

    SELECT @xml.query('/root/test')

    Greets

    Flo

  • RE: How to get sum of date difference from multiple records

    Just write what you said...

    DECLARE @datesum TABLE (id tinyint, name VARCHAR(25),sdate DATETIME, edate DATETIME )

    INSERT INTO @datesum

    SELECT 1,'TestName1','2004-01-25','2005-02-06'

    UNION ALL

    SELECT 2,'TestName1','2003-07-20','2005-03-18'

    UNION ALL

    SELECT 3,'TestName1','2002-12-24','2004-03-21'

    UNION ALL

    SELECT 4,'TestName1','2001-10-27','2003-03-03'

    SELECT SUM(DATEDIFF(DAY, sdate, edate)) FROM...

  • RE: Loop back to the root record

    Hi

    So just put the results into a table and return it:

    SET NOCOUNT ON

    DECLARE @tree TABLE (id INT, parent INT, desp VARCHAR(100))

    INSERT INTO @tree VALUES (1, NULL, 'a')

    INSERT INTO @tree VALUES...

  • RE: Order number grouping and count

    Okay, next try.

    If you want the count of visits of your customers within the special_orders use a aggregated sub-query. (In your sample data every customer/location has exactly two entries within...

  • RE: how to get user's identity in sql

    Hi

    Since you use your ErrorLog user account for the ConnectionString you have to specify any other user information by your self. If any other user account is connected you can...

  • RE: Query out attributes in XML

    This example from BOL may solve your problem:

    DECLARE @myDoc xml

    DECLARE @ProdID int

    SET @myDoc = '<Root>

    <ProductDescription ProductID="1" ProductName="Road Bike">

    <Features>

    <Warranty>1 year parts and labor</Warranty>

    <Maintenance>3 year parts and labor...

  • RE: Loop back to the root record

    Sample:

    SET NOCOUNT ON

    DECLARE @tree TABLE (id INT, parent INT, desp VARCHAR(100))

    INSERT INTO @tree VALUES (1, NULL, 'a')

    INSERT INTO @tree VALUES (2, 1, 'b')

    INSERT INTO @tree VALUES (3, 2, 'c')

    INSERT INTO...

  • RE: Updating varchar(max) column

    As first I would suggest to change the type of your VARCHAR(MAX) column to XML.

    Here a little example:

    DECLARE @v-2 VARCHAR(MAX)

    SET @v-2 = '<Root><Age>45</Age></Root>'

    DECLARE @xml XML

    SET @xml...

  • RE: String comparisons Am I going Mad?

    You can handle the problem by a little trick. Check the value AND the DATALENGTH (not then LEN). The DATALENGTH of the search criterion still contains the full size.

    DECLARE

  • RE: Order number grouping and count

    Hello g8r

    I'm not sure if I understood, but for the example result of your first post it might be just:

    SELECT Visit_Date, COUNT(*)

    FROM #Special_Orders

    GROUP BY...

  • RE: Is there a way to select all columns except one or two columns?

    Oups... did not yet get my breakfast...

    Thanks and sorry

    Flo

  • RE: Is there a way to select all columns except one or two columns?

    Yet another way:

    DECLARE @excluded_columns TABLE (name SYSNAME)

    DECLARE @table_name SYSNAME

    DECLARE @columns NVARCHAR(MAX)

    SET @table_name = 'Person.Contact'

    -- Excluded columns

    INSERT INTO @excluded_columns VALUES ('Suffix')

    INSERT INTO @excluded_columns VALUES ('rowguid')

    SET @columns = ''

    SELECT @columns = @columns...

Viewing 12 posts - 2,026 through 2,037 (of 2,037 total)