Forum Replies Created

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

  • RE: Count record from different table

    -- Test Data

    DECLARE @t TABLE

    (

     TID CHAR(5) COLLATE DATABASE_DEFAULT NOT NULL

     ,TYPE CHAR(3) COLLATE DATABASE_DEFAULT NOT NULL

    )

    INSERT @t

    SELECT 'KL202', 'JPJ' UNION ALL

    SELECT 'KL202', 'JPJ' UNION ALL

    SELECT 'KL202', 'JPN' UNION ALL

    SELECT 'KL202', 'JIM'...

  • RE: Two Users Pulling Same Account Problem

    I read up on this last night and think that UPDLOCK should work no matter how much contention there is. The UPDLOCK should ensure that no other...

  • 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))

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