Forum Replies Created

Viewing 15 posts - 49,306 through 49,320 (of 49,552 total)

  • RE: Passing two output parameters in one stored procedure

    Sure. You can have as many ouput parameters as you want.

    CREATE PROCEDURE Test

     @Out1 int OUTPUT,

     @Out2 char(1) OUTPUT

    AS

     SELECT @Out1=1, @Out2='Y'

    GO

    DECLARE @Var1 int, @Var2 char(1)

    EXEC Test @Var1 OUTPUT, @Var2 OUTPUT

    SELECT @Var1, @Var2

    --

    I...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: SQL Query Writing Help

    Does the function have to return a string. It would be easier if it was a table-returning function.

    If it has to be a string, you could always count the nuber...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: SQL Query Writing Help

    Could you please post the definition of your table, some example data and expected output please. I'm not completely sure from your description what it is you want.

    thanks

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Must Knows of SQL server

    Well this site's probably the best.

    http://www.sqlskills.com

    http://www.sql-performance.com

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: SQL server Master Database restore

    First, may I suggest you post in a more appropriate forum, like SQL Administration or SQL General. This forum is for discussion of the site's question of the Day, not general...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Select a field wich name is in a variable (impossible?)

    Pleasure, got nothing else to do right now.

    (looks cautiously around for boss)

     

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Select a field wich name is in a variable (impossible?)

    You can get variables out. I find, personally, it's the main use of it.

    DECLARE @RecordCount INT

    EXEC sp_executesql N'SELECT @RecordCountOut=COUNT(*) FROM sysobjects', N'@RecordCountOut INT OUTPUT', @RecordCountOut=@RecordCount OUTPUT

    SELECT @RecordCount

    It's like a stored procedure...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: How do I sum results columns (grand total).

    Use UNION ALL rather than UNION. There's no possibility of duplicates between the two queries.

    UNION means SQL will take the two result sets, concatinate, then sort to remove duplicates. UNION...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Select a field wich name is in a variable (impossible?)

    And if you don't know all the columns and need dynamic SQL

    B. Execute('Select @NEWVAL  =  ins.' + @FIELDNAME + ' FROM inserted ins WHERE ins.RegAudited = ' +...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: cursor Help

    Actually, come to think of it, the initial insert that you do to insert all the products is unnecessary. If there's a possibility that there will be products in Product_Forcast...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: cursor Help

    btw HTH stands for Hope that helps.

    Close, but not quite.

    Create the table sales and populate the years and products you want....

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Temp Tables and Dynamic SQL

    Why a gobal temporary table?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Temp Tables and Dynamic SQL

    Why do you not know what database the table is in?

    Could you expalin in a bit more detail the situation and what you're trying to do?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: URGENT help with statement please

    Select * from tbl

     where ID IN (SELECT ID FROM tbl WHERE transaction='1000')

     AND ID IN (SELECT ID FROM tbl WHERE transaction='2000')

    Messy, but it'll work

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Temp Tables and Dynamic SQL

    If you're using temp tables in order to get values out of dynamic sql, look at sp_executesql. It lets you pass parameters to dynamic sql, both input and output parameters.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 15 posts - 49,306 through 49,320 (of 49,552 total)