Forum Replies Created

Viewing 15 posts - 3,316 through 3,330 (of 3,543 total)

  • RE: Use Results from a Cross Join for dynamic SQL

    Are you saying

    1 A Yes

    1 B Yes

    1 C Yes

    produces

    A 1

    AB 1

    AC 1

    BC 1

    and

    1 A Yes

    1 B Yes

    1 C No

    produces

    A 1

    AB 1

  • RE: Use Results from a Cross Join for dynamic SQL

    How about this for a wacky & crazy solution

    create table #tblResponses (Resp int, ProdName char(1), Value varchar(3))

    insert into #tblResponses values (1, 'A', 'Yes')

    insert into #tblResponses values...

  • RE: Use Results from a Cross Join for dynamic SQL

    Can I ask some qualifying q's

    How do you get 8 combinations from 3 products? If you want unique combinations then there are only 6

    select a.ProdName,b.ProdName,c.ProdName

    from prodx a

    cross join prodx b

    cross...

  • RE: Trying to add new records to a temporary table

    Since you are naming each server in turn then

    INSERT INTO ##all_logins

    SELECT name,'jupiter'

    FROM jupiter.master.dbo.sysxlogins

    WHERE name like '%Ivanov%'

    INSERT INTO ##all_logins

    SELECT name,'saturn'

    FROM saturn.master.dbo.sysxlogins

    WHERE name like '%Ivanov%'

  • RE: Trying to add new records to a temporary table

    Select into will always create a temp table.Try

    CREATE TABLE

    tempdb.##all_logins

    ([UserID] [int] IDENTITY (1, 1) NOT NULL ,

    [UserName] [varchar] (100))

    Then try to add records to it:

    INSERT INTO ##all_logins

    SELECT name

    FROM jupiter.master.dbo.sysxlogins

    WHERE...

  • RE: HELP WITH SQL PROCEDURE syntax

    Sorry, cockup on quotes (could'nt test)

    DECLARE @search VARchar(3000)

    DECLARE @scop VARchar(20)

    DECLARE @sql nvarchar(1000)

    set @scop='C:\'

    set @search='ilan '

    set @sql = 'SELECT TOP 10 *

    FROM OPENQUERY(NTindex,

    ''SELECT DocTitle,create,path,filename, rank,VPath,Contents,characterization

    FROM SCOPE ('''''+@scop+''''')

    WHERE FREETEXT(Contents, ''''"'+@search+'"'''')'')'

    exec sp_executesql...

  • RE: Text Function Help

    Nice one Jay, did not think of that one. Probably make cleaner code as well.

  • RE: Help use FREETEXT ssearch and split words

    Try this

    DECLARE

    @SearchField VARCHAR(100),

    @A varchar(5),

    @Temp VARCHAR(100),

    @Output VARCHAR(100),

    @counter INT

    SET @SearchField = 'select1 select2 select3'

    SET @Temp = @SearchField

    Print @Temp

    SET @Output = ''

    SET @A = ''

    WHILE (@Temp <> '')

    BEGIN

    SET @Counter = CHARINDEX(' ',@Temp+'...

  • RE: HELP WITH SQL PROCEDURE syntax

    The problem is you are sending the query with @scop and @search not the contents of the variables. You need to create the whole query (inc variable values) in a...

  • RE: SQL Query problem - Please Help

    Why not user a join, it is faster and you do not need an top/order by in the subquery.

    SELECT a.* FROM t_Retail a

    FROM t_Retail a

    INNER JOIN (SELECT Pcde6P

    FROM t_Retail

    WHERE LEN(RTRIM(Pcde6P))...

  • RE: Text Function Help

    Don't really know if there is a best way. It depends on volume and type of data. You only gave example of 3 rows with one character data. The only...

  • RE: Heterogeneous queries - HIGH PRIORITY HELP!

    In EM right click on the server (the one you are linking to) and select properties. Select the Connections tab, click on ANSI warnings and ANSI nulls (to put tick...

  • RE: How to retrieve a result from a dynamic sql statem

    declare @c int,@sql nvarchar(1000),@table varchar(20)

    set @table = 'tablename'

    set @sql = 'select @c=count(*) from '+@table

    exec sp_executesql @sql,N'@c int output',@c output

    select @c

  • RE: Heterogeneous queries - HIGH PRIORITY HELP!

    Have you tried setting them on the linked server for connections? (providing it does cause problems elsewhere!)

  • RE: Error handling in Stored procedures

    No but you can use goto to branch, eg

    declare @ErrorNo int

    (sql statement)

    SET @ErrorNo = @@ERROR

    IF @ErrorNo <> 0 GOTO Error_handler

    (sql statement)

    SET @ErrorNo = @@ERROR

    IF @ErrorNo <> 0 GOTO Error_handler

    RETURN

    Error_handler:

    (clean up)

    ...

Viewing 15 posts - 3,316 through 3,330 (of 3,543 total)