Forum Replies Created

Viewing 15 posts - 1,846 through 1,860 (of 2,171 total)

  • RE: getting values for dynamically generated columns??

    However, this is a SP I would use. I don't like cursors that much.

     

    CREATE PROCEDURE usp_AFSearch

    AS

    DECLARE @SQL VARCHAR(8000)

    SELECT @SQL = ISNULL(@SQL + ', ', ' ')...

  • RE: getting values for dynamically generated columns??

    CREATE proc SP_AFSearch

    as

    declare @Column as varchar(300),

     @strquery as varchar(8000)

    Declare CRS_AddColumn CURSOR FOR select  syscolumns.name Name

         from  syscolumns

         inner join sysobjects on sysobjects.ID = syscolumns.ID

         where  sysobjects.xtype = 'U'

           and sysobjects.name = 'Store'

           and syscolumns.name not...

  • RE: getting values for dynamically generated columns??

    Best way to go is to prefix all "dynamically created columns" with for example "dc_"

    as "dc_ItemHeight" or "dc_ItemColor".

    This way there is no confusion of which are "fixed" columns and dynamic...

  • RE: week list

    DECLARE  @BaseDate DATETIME

    SELECT @BaseDate = '20060814'

    SELECT  DATEADD(week, b3.i + b2.i + b1.i + b0.i, @BaseDate),

            DATEADD(day, 6, DATEADD(week, b3.i + b2.i + b1.i + b0.i, @BaseDate)),

     count(*) as SomethingCounting

    FROM  (SELECT 0...

  • RE: Using COMPUTE and getting query results to Excel

    Take a look in Books Online for BCP and queryout option.

  • RE: week list

    Here is a starter

    DECLARE  @BaseDate DATETIME

    SELECT @BaseDate = '20060814'

    SELECT  DATEADD(week, b3.i + b2.i + b1.i + b0.i, @BaseDate)

    FROM  (SELECT 0 i UNION ALL SELECT 1) b0

    CROSS JOIN (SELECT 0...

  • RE: find a missing no

    What if you have some million rows? Then that will take some time to complete...

  • RE: needd help in query writing

    Please do not cross post!

    Your question has already been answered here

    http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=302310

  • RE: Is IP Address in this range?

    Or more specialized.

    CREATE FUNCTION dbo.fnIPv4_InRange

    (

        @CurrentIP VARCHAR(15),

        @FromIP VARCHAR(15),

        @ToIP VARCHAR(15)

    )

    RETURNS BIT

    AS

    BEGIN

     DECLARE @CurrentNum BIGINT,

      @FromNum BIGINT,

      @ToNum BIGINT,

      @InRange BIT

     SELECT @CurrentNum = 16777216 * CAST(PARSENAME(@CurrentIP, 4) AS BIGINT) +

           65536...

  • RE: find a missing no

    -- prepare test data

    declare @bill table (billno int)

    insert @bill

    select 1 union all

    select 2 union all

    select 3 union all

    select 4 union all

    select 6

    -- do the work

    SELECT     b.billno - 1 MissingNo

    FROM       @bill...

  • RE: Passing the cycle parameter into xp_readerrorlog

    Strange with the error you say my code produces.

    At least since I do not have either nvarchar not tinyint declarations...

  • RE: Passing the cycle parameter into xp_readerrorlog

    Change DECLARE @sql VARCHAR(100) to

    DECLARE @sql NVARCHAR(100).

     

    That is one of the drawbacks for sp_executeSQL

  • RE: union all and order by help!

    Yes there is! But I agree with you that a CASE is more readable.

    SELECT f.Country_Name

    FROM (

       SELECT Country_Name

      FROM tblCountry

      WHERE Country_ID = 26

      UNION ALL

      SELECT TOP 100...

  • RE: Is IP Address in this range?

    Easy. Write like this

    SELECT CASE

      WHEN dbo.fnIPv4('193.194.227.51') BETWEEN dbo.fnIPv4('193.194.226.19') AND dbo.fnIPv4('194.193.1.1') THEN 'Yes'

      ELSE 'No'

     END

    Where the function dbo.fnIPv4 looks like this

    CREATE FUNCTION dbo.fnIPv4

    (

        @IP VARCHAR(15)

    )

    RETURNS BIGINT

    AS

    BEGIN

        RETURN 16777216...

  • RE: ADO Incompatibility SQL 2005 vs SQL 7?

    Rule number 1

     

    ALWAYS USE

     

    SET NOCOUNT ON

     

    in stored procedures that have contact with ADO

Viewing 15 posts - 1,846 through 1,860 (of 2,171 total)