Forum Replies Created

Viewing 15 posts - 106 through 120 (of 167 total)

  • RE: Problem with XP_CMDSHELL ''''DIR .....''''

    You may have a DIRCMD environment variable set in one or both accounts using CMD.exe

    Check the account SQL Server is running under and also the account you are logged on...

  • RE: Parse data for recurring value?

    Parse the string into a temp table and do a:

    Select count(*) from dbo.#tmp group by ValueColumn having count(*)>1

  • RE: dynamic sql

    ...and if any of your variables can be populated by user data you should take steps to prevent potential career altering SQL injections...

  • RE: Unexpected Remote Query Results

    Hmmm,

    That's disconcerting... I've tryed those two queries on 5 different servers (SQL2K SP3 on W2K Pro and 2003 Server) in-house and got the same wrong results each time. The only way...

  • RE: Unexpected Remote Query Results

    Loner,

    Sorry, my bad I should have said fully-qualified remote table name instead of Linked Server table name

  • RE: Unexpected Remote Query Results

    I think you may have hit upon Microsofts buried disclaimer for this seemingly non-intuitive result...

    My solution was to use OpenQuery() as you have mentioned,...

  • RE: Sloooooow stored procedure

    All of the above are good suggestion. I would add to that:

    Check the connection default settings; compare them with the QA connection settings.

  • RE: Using a variable as a table name when opening a cursor

    Declare a cursor variable. Pass the cursor variable as OUTPUT into sp_ExecuteSQL. The dynamic SQL should assign the cursor variable via SET and OPEN it before the batch completes. 

  • RE: Drop procedure from other DB

    Or...

    Exec('Use targetdbname Drop Table tablename')

  • RE: How to increment a varchar?

    Use this function in a computed column that takes an Identity column as its input:

    Create Function dbo.WeirdIdentity

    (

     @Num BigInt

    )

    Returns VarChar(256)

    As Begin

       Declare

          @Digits Char(36),

          @Results Char(17),

          @i Int,

          @j-2 Int

       Set...

  • RE: Formatting numbers (commas and decimal)

    I use this quick and dirty function (emphasis on adjectives) for integer and decimal values. You must convert the number to a string format before calling this function (although it...

  • RE: xp_cmdshell winzip string constuction help plz

    Try this:

    In TSQL split the path from the executable; @Path & @Exe

    Create a command string and execute it:

    Set @Cmd='CD /D '+@Path+' & "'+@Exe+'" '"+@Parm1+"' '"+@Parm2+'" ...'

    (notice...

  • RE: how to ignore error message in sql

    Try:

    Exec('your sql command')

    If @@Error<>0 do something...

    Exec('your sql command')

    If @@Error<>0 do something...

    Exec('your sql command')

    If @@Error<>0 do something...

    With this method individual SQL command failures will not stop the entire batch.

  • RE: sp_executesql

    Huh? You should get an error stating that @i does not exist in the batch context...

    Try:

    Declare @sql nVarChar(4000)

    Set @sql=N'Declare @i Char(1) Set @i=''a'' Select *,@i from dbo.sysindexes'

    Exec sp_ExecuteSQL @sql

  • RE: Create Listing of Files

    Try something like this...

    Declare

       @Dir VarChar(1024),

       @Cmd VarChar(8000)

    Select

       @Dir='C:\WinNT',

       @Cmd='Dir /A-D /B "'+@Dir+'"'

    If Object_Id('tempdb.dbo.#tmp') is not Null Drop Table dbo.#Tmp

    Exec

    (

    'Create Table dbo.#Tmp(Dir VarChar(1024) default '''+@Dir+''',FN VarChar(256))

    Insert dbo.#Tmp (FN)

    Exec...

Viewing 15 posts - 106 through 120 (of 167 total)