Forum Replies Created

Viewing 15 posts - 331 through 345 (of 1,346 total)

  • RE: Dynamic SQL - Assign Variable Value

    You need to use sp_executesql instead of exec.

    set @sqlstring = 'select @recIDmin = min(record_id) from ' + @TblName

    --get min value of record_id in a tbl into var @recIDmin

    exec...

  • RE: What''''s the best way to generate an XML data file from a table?

    I do believe it is because you are declaring the Elements keyword in your For XML Clause.

    from BOL

    ELEMENTS

    Specifies that the columns are returned as subelements. Otherwise, they...

  • RE: Drill through/drill down in sql reports

    What do you mean Drill down?

    What are you trying to accomplish?

    you can for example call a subreport by clicking an item on your report.

    select properties on item, go to Navigation,...

  • RE: How do I calculate percentage??

    Your best bet that will give you the greatest flexibility would to do formatting on the presentation layer (whatever you use to display to the user, ie crystal, MS reporting...

  • RE: Inserting a new row into a table by copying an existing one and changing the key(s)

    you mean

    Insert...Select?

    Examples below

    --TestTable

    Create table #Mytable (pk int identity,

                           Foo varchar(25),

                           Bar varchar(25))

    --Insert TestData

    insert into #Mytable (Foo, Bar)

    Values('One', 'Mississippi')

    insert into #Mytable (Foo, Bar)

    Values('Two', 'Mississippi')

    insert into #Mytable (Foo, Bar)

    Values('Three', 'Mississippi')

    -- Can...

  • RE: Problem with OPENXML

    In the path statement you have to put the lower level to get it to look at all the rows.

    and then in the With clause indicate text() function to have...

  • RE: Procedure expects parameter Error

    Here is an article that thoroughly explains dynamic sql.

    http://www.sommarskog.se/dynamic_sql.html

    It can possibly have Performance, and Security problems, but if used wisely, and in the correct places its okay.

     

  • RE: SUM of values by Month?

    changing the date to be 8/2007 should be something easily done on the presentation layer. (What are you using BTW?)

    For sorting you absolutely have to return an actual date.

    that little...

  • RE: Report Builder/ Report Designer

    What are you dumping your output to?

    I'm guessing Tables.

    Each table is assigned to its own Dataset.

     

    Create 2 different datasets one for each output.

    then plop down 2 tables on the designer.

    Edit...

  • RE: insert one table into another

    Rough Example

    In books online it is the Insert..Select

    Insert into Mytable (col2, col3, col5)

    Select SourceCol1, SourceCol2, SourceCol4

    From StageTable

    Where Something = Something

    From BOL

    Inserting Rows Using INSERT...SELECT

    The SELECT subquery in...

  • RE: DateAdd

    declare @date1 datetime

    declare @date2  datetime

    set @Date1= '08/05/2007'

    set @Date2 = '01/01/1900 2:11:00 PM'

    select @Date1, @Date2

    --

    2007-08-05 00:00:00.000 1900-01-01 14:11:00.000

    select @Date1 + @Date2

    Result

    2007-08-05 14:11:00.000

  • RE: Pass atemp table

    No, if you do a ## it will not allow multiple users all the users will be dumping records into the same temp table.

     

    Populate your temp table inside a procedure.

    Create...

  • RE: why parameter inclusion causes less records

    Then is not needed in a IF statement Remove Text in Red

    IF @GroupLeader = '' THEN

                                                 SELECT  GRPLDR.GLPerson FROM         dbo.Main LEFT OUTER JOIN

                                                (SELECT     Person AS GLPerson, WPId   FROM   SigAuth WHERE      Title = 'GL')...

  • RE: update tables that have primary key and foreign key

    I'm not sure why you would want to do this. Designating a value as the primary key is important to maintaining data integrity, and to have a need to Update...

  • RE: Help using IN operator for passed list in parameter

    -- Don't use Dynamic sql unless you have to.

    -- Try a UDF

    Create  FUNCTION udf_list_parse_comma_string

     (@String varchar(8000))

    RETURNS @stringTable TABLE

     (string varchar(100))

    AS

    BEGIN

    -- Make sure last char is a comma

    if right(@String,1) <> ','

       ...

Viewing 15 posts - 331 through 345 (of 1,346 total)