Sand Box

OpenWiki
» Find Page » Sand Box
MENU:
Front Page
Recent Changes
Title Index
Category Index
User Preferences
Random Pages
Find Page
Help Page

Page Bookmarks:
Sand Box
Image Upload
 Je peux même mettre du texte avant.

@Echo off

::Setting Path Variables

@For /F "tokens=2 delims=/ " %%A in ('Date /t') do set DD=%%A
@For /F "tokens=3 delims=/ " %%B in ('Date /t') do set MM=%%B
@For /F "tokens=4 delims=/ " %%C in ('Date /t') do set YY=%%C

Set CUSTOMDATE=%DD%-%MM%-%YY%
echo %CUSTOMDATE%

Le seul problème est que je ne peux pas chercher dans ce code, je crois. Et c'est plate pas mal ! Je me demande si c'est une bonne idée d'essayer d'implanter de la recherche texte sur ce texte ? Dans cette page, j'ai ajouté du texte à partir de mon iPhone.
use master
go
-- Query to search a text using LIKE from all text fields from all tables
-- Pollus Brodeur (c) 2008
alter proc dbo.sp_searchtext
    @text nvarchar(1000),
    @exec bit = 0,
    @expression bit = 0
as
begin
    set nocount on
    declare @owner sysname, @table sysname, @column sysname, @lasttbl sysname
    declare @SQLtxt nvarchar(4000), @where nvarchar(4000)

    -- Transform for a LIKE query
    if @expression = 0
        begin
        select @text = replace(@text,'_','[_]')
        select @text = replace(@text,'%','[%]')
        select @text = replace(@text,'''','''''')
        select @text = '''%' + @text + '%'''
print @text
        end

    -- select all text column in a CURSOR
    declare CUR cursor read_only fast_forward for
        select u.name own, o.name tbl, c.name col
        from syscolumns c
        join sysobjects o on o.id = c.id
        join sysusers u on u.uid = o.uid
        join systypes t on t.xtype = c.xtype
        where o.type = 'U' and t.name in('varchar','nvarchar','char','nchar')
        and o.name <> 'dtproperties'
        order by 1,2,3
    open CUR

    -- for each text columns, do a search (combined by table to minimize table scan)
    fetch next from CUR into @owner, @table, @column
    select @lasttbl = quotename(@owner) + '.' + quotename(@table), @where = ''
    while (@@fetch_status = 0)
    begin
        select @table = quotename(@owner) + '.' + quotename(@table), @column = quotename(@column)
        if @table = @lasttbl -- add column to next where clause
            select @where = @where + case when len(@where)=0 then '' else ' or ' end + @column + ' like ' + @text
        else
            begin -- print/exec query
            select @SQLtxt = 'select * from ' + @lasttbl + ' where ' + @where 
            print @SQLtxt
            if @exec = 1 exec(@SQLtxt)
            select @where = @column + ' like ' + @text
            end
        select @lasttbl = @table
        fetch next from CUR into @owner, @table, @column
    end
    -- print query for last table
    select @SQLtxt = 'select * from ' + @lasttbl + ' where ' + @where 
    print @SQLtxt
    if @exec = 1 exec(@SQLtxt)

    close CUR
    deallocate CUR
end
go



Summary : Page Test ! Pour pratiquer tout simplement !

Edit this page | Rename this page | View other revisions | Attachments (0) | Print this page | View XML | Page views: 1909
Find page by browsing, searching or an index | Page Revisions: 2
Last Edited February 27, 2010 by Pollus (diff)