Forum Replies Created

Viewing 15 posts - 91 through 105 (of 110 total)

  • RE: Assigning value to variable for selection.

    The code that doesn't work does not work because @TimeSheet_PK_ID has no value at the time you ask to select...WHERE @TimeSheet_PK_ID = tbl_TimeSheetEntry.TimeSheet_PK_ID.

    The part that you say seems redundant only...

  • RE: Assigning value to variable for selection.

    Your first Exists should start

    IF EXISTS(SELECT * from ...

    You cannot assign a variable within an EXISTS.

    Since you are not setting @TimeSheet_PK_ID, your WHERE clause for the UPDATE should start WHERE...

  • RE: Calling UDFs on linked servers

    execute ('select DB1.dbo.getSomething(3)')

    as login = 'MyLoginName'

    at LinkedServerName

    You can use login or user names. See BOL under EXECUTE (Transact-SQL).

  • RE: small issue

    Look up INSERT and UPDATE in BOL. There are many ways to code this. The one you want may depend on requirements you did not mention.

    Simplest thing would be insert...

  • RE: Import XML in SQL 2000

    the table specs did not come through. please post them again.

  • RE: setiing variables in a temp table

    create table #test (aaa int, bbb int)

    insert into #test select 1, 2

    declare

    @aaa int,

    @bbb int

    select @aaa = aaa + 2, @bbb = bbb + 3 from #test

    select @aaa...

  • RE: Pull User / Server Data Info..

    Look under Security Catalog Views in BOL for your second question. sys.database_role_members is one such view.

  • RE: SELECT with IF EXISTS not working

    It seems like you need parentheses around the units part too. That's why your else statement ran even when @PayFormulaCode was not TS in one of the early versions.

    declare @PayFormulaCode...

  • RE: Parse a name field

    Where does the 26 come from?

    If all of your names to parse look like 'Brown JohnF' this will work

    create table #tblImportAppliedBankDaily (Details varchar(40))

    insert into #tblImportAppliedBankDaily (Details) select 'Brown JohnF'

    insert into...

  • RE: Dynamic SQL in a IF exists statement

    I'm partial to stating conditions positively so instead of not exists this uses exists and may finish a little quicker.

    create proc CheckExists

    @TableName varchar(100),

    @ColumnName varchar(20),

    @HolderNum int,

    @DoesExist...

  • RE: Dynamic SQL in a IF exists statement

    Echoing the previous response but avoiding the local temp table and having to convert all of your stuff to do into dynamic sql as well as the test.

    For exists() you...

  • RE: Bulk insert question

    A table variable created outside of the dynamic sql is not visible within the dynamic sql. You can make and use the table variable within the dynamic sql.

    declare @fname as...

  • RE: Decision in a query

    create table #test

    (

    FullName varchar(5), AddressHome varchar(10), AddressPO varchar(10), CustPhone char(10)

    )

    insert into #test

    select 'allen', '1', null, 'any'

    union

    select 'betty', null, '22', 'any'

    union

    select 'chuck', '333', '4444', 'any'

    union

    select 'david', null, null, 'any'

    select FullName,...

  • RE: How can I execute an external .sql file from a stored procedure?

    bulk insert and bcp will work too. Both have a lot of options. This is about as simple as they get:

    CREATE TABLE #MyFile (MyText VARCHAR(500))

    BULK INSERT #MyFile

    FROM...

  • RE: SQL statement

    Some fixes based on guesses about what may not be working as you expect.

    -- No results at all or syntax error because of the double quotes around 16285. Change to...

Viewing 15 posts - 91 through 105 (of 110 total)