Forum Replies Created

Viewing 15 posts - 1 through 15 (of 89 total)

  • RE: Dynamic SQL Not working

    IF only determines if the statement is going to execute. Or the next batch of statements in a BEGIN END section. So in your code,

    IF (@Status =...

  • RE: Importing multiple .dbf files with TSQL

    SELECT INTO expects to create the destination table. If you are trying to load them into an existing table, you need to do INSERT INTO Table (list of destination...

  • RE: Dynamic SQL Not working

    IF (@Status = 'All Active')

    SET @SQLStr = 'SELECT * FROM #DLFiltered WHERE Active = 1 '

    SET @SQLStr = @SQLStr + ' AND CurrentLevelXID BETWEEN ' + CONVERT(Varchar(2),@AchieveLevelStart ) + '...

  • RE: How to add leading zeros?

    Or, you can highlight the cells you want to change, right click and choose format. Select the Custom Category. Then in the Type: field, type in a zero...

  • RE: Truncation of Output Variable

    I didn't see this in any of the posts, but will throw it out there anyway. If you do a convert to varchar, without specifying a length, it defaults...

  • RE: QUERY TO ADD RECORDS TO A TABLE

    Start by looking up "INSERT" in BOL.

  • RE: email users depending on result of query

    You should be able to add an Execute SQL Statement step into your DTS.  Then use XP_SendMail in the SQL statement.

    Brian

  • RE: Ambiguous column name error

    And why does this work?

    select id, name

    from sysobjects so

    order by abcd.id

    It appears to ignore the alias if it doesn't exist.

    Brian

  • RE: Complicated Query

    Assuming the concatenated string of attributes will be less than 8000 characters, you don't need to do the cursor.  Your function could look something like the following.

    CREATE FUNCTION dbo.AllAttributes

    (@Order INT)

    RETURNS...

  • RE: CHAR vs VARCHAR

    I thought I read somewhere once that if you alter the datatype of a column, SQL basically abandons the location of the old column and moves the data to the...

  • RE: Eliminating Leading Char Zeros

    Because sometimes the simple answers are the hardest to see. 

    Brian

  • RE: ISNULL performance question

    On my system, both of your options cause a clustered index scan.  Ideally you want an index seek.  This is accomplished by my first suggestion.  Based on your table definition...

  • RE: ISNULL performance question

    Then how about

    SELECT ....

    WHERE CASE WHEN @RecordId IS NULL THEN RecordGuid ELSE RecordId END=CASE WHEN @RecordId IS NULL THEN @RecordGuid ELSE @RecordId END

    AND CASE WHEN @RecordGuid IS NULL THEN RecordId ELSE...

  • RE: ISNULL performance question

    I would have two queries.

    If @RecordId IS NULL

    ... WHERE RecordGuid=@RecordGuid

    ELSE

    ... WHERE RecordId=@RecordId

    Of course, this assume that exactly one will always be provided.

    Brian

  • RE: Eliminating Leading Char Zeros

    --Create a tally table of sequential numbers

    SELECT TOP 1000000

    N=IDENTITY(INT,1,1)

    INTO Tally

    FROM Master.dbo.SysObjects sc1,       

    Master.dbo.SysObjects sc2

    --Make sure it is indexed

    ALTER TABLE Tally ADD PRIMARY KEY CLUSTERED (N)

    --Create my test data

    CREATE TABLE #test...

Viewing 15 posts - 1 through 15 (of 89 total)