Forum Replies Created

Viewing 15 posts - 1,411 through 1,425 (of 1,489 total)

  • RE: Two Users Pulling Same Account Problem

    On considering this again, it may be safer to use the UPDLOCK hint. eg:

    UPDATE A1

    SET

     Tagged = 1,

     WorkStart = GETDATE(),

     UserCode = @UserCode,

     @UseIt1 = A1.AcctNo

    FROM _FinalFlat (UPDLOCK) A1

    INNER JOIN

    (

     SELECT TOP 1 A.AcctNo

     FROM...

  • RE: Two Users Pulling Same Account Problem

    You are probably using the default isolation level of Read Committed. Try either setting the isolation level to Repeatable Read or using the RepeatableRead locking hint on the table to...

  • RE: Stored proc with update loop

    Still do not really have enough information, but something like this should get you started:

    UPDATE R

    -- This will set all the users RoleID to 7

    SET RoleID = 7

    -- If there...

  • RE: Stored proc with update loop

    It is not clear what you are trying to achieve.

    You will need to post:

    1. the DDL (CREATE TABLE statements) for the LOCATION, USERS a USERROLES tables.

    2. some sample data for...

  • RE: Problem with openquery and Progress odbc

    You could try returning:- SUM(CAST(dom-amount * 100 AS INT)) AS dom-amount

    from the remote query and then dividing by 100.0

  • RE: Update Query - against 2 databases

    You need to be careful with the second example as it is not portable to other db systems. (eg Oracle.)

     

  • RE: Update Query - against 2 databases

    You need to use the 3 part naming convention: - <database>.<owner>.<table>

    Something like the following should work:

    -- ANSI SQL

    UPDATE db1.dbo.People

    SET [password] =

     (SELECT P2.[password]

     FROM db2.dbo.People P2

     WHERE P2.people_id = db1.dbo.People.people_id)

    WHERE EXISTS

     (SELECT *

     FROM db2.dbo.People...

  • RE: Catching level 16 Errors in sp_ExecuteSQL

    It could be an issue with the linked server not being MS-SQL as the following fails as expected:

    DECLARE @rc INT

    EXEC @rc = sp_executesql N'select * from junk.junk.dbo.qwerty'

    PRINT @rc

    PRINT CASE @rc...

  • RE: Sript Name with Current Date

    The ISO date format is probably best for this; so something like:

    DECLARE @DiskStr NVARCHAR(255)

    SET @DiskStr = N'C:\CollSoftware2_' + CONVERT(NVARCHAR(8), GETDATE(), 112) + N'.bak'

    BACKUP DATABASE [CollSoftware2]

    TO  DISK = @DiskStr

    WITH  INIT...

  • RE: How to do a Select xx from

    You will have to use dynamic SQL.

    exec('SELECT xx FROM ' + @Variable)

     

  • RE: Why is my variable getting converted

    Declare @Memberid as varchar (50)

    Declare @ProcCode as Varchar (15)

    set @memberid = '-1'

    Set @ProcCode = 'G0202'

    Select top 100 * from [QICC-TEST].dbo.tblClaims_eligible

    where Membid = COALESCE(NULLIF( @memberid, '-1'), Membid)

    and ProcCode =...

  • RE: Count Decimal Places

    Forgot about no Decimal places:

    DECLARE @d DECIMAL(18,9)

     ,@S VARCHAR(20)

     ,@R VARCHAR(20)

     ,@Pos SMALLINT

    SET @d = 0.0

    SET @s-2 = CAST(@D AS VARCHAR(20))

    SET @r = REVERSE(SUBSTRING(@S, CHARINDEX('.', @s-2) + 1, 20))

    SET @Pos = PATINDEX('%[1-9]%' ,...

  • RE: Count Decimal Places

    DECLARE @d DECIMAL(18,9)

     ,@S VARCHAR(20)

     ,@R VARCHAR(20)

    SET @d = 0.8333

    SET @s-2 = CAST(@D AS VARCHAR(20))

    SET @r = REVERSE(SUBSTRING(@S, CHARINDEX('.', @s-2) + 1, 20))

    SELECT LEN(SUBSTRING(@R, PATINDEX('%[1-9]%', @r), 20))

  • RE: Why is my variable getting converted

    You are comparing two different datatypes with NULLIF( @memberid,-1). As INT has a higher precedence than VARCHAR, the VARCHAR will be implicitly converted to an INT before the comparison is...

  • RE: Can I use a subquery or would a function be better?

    >> Can you put SELECT statements inside that COALACSE statement???

    You can, but the outer joins should produce the NULLs for you. Try:

    SELECT E.EMPID

     ,COALESCE(L.PlantCode, H2.B_COMN_SITE_NO, 'N/A') AS HRLocation

     ,COALESCE(L.PlantCode, P2.B_COMN_SITE_NO, 'N/A') AS...

Viewing 15 posts - 1,411 through 1,425 (of 1,489 total)