IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MS SQL Server Discussion :

[SQL 2005] Requette LIKE assez spéciale


Sujet :

MS SQL Server

  1. #1
    Membre confirmé
    Avatar de frechy
    Inscrit en
    Novembre 2004
    Messages
    343
    Détails du profil
    Informations personnelles :
    Âge : 40

    Informations forums :
    Inscription : Novembre 2004
    Messages : 343
    Points : 511
    Points
    511
    Par défaut [SQL 2005] Requette LIKE assez spéciale
    Bonjour à tous,


    Je vous explique rapidement l'état.

    Dans une entreprise, certains services ont accès à certaines portes (accès badge).

    Dans ma DB j'ai une table Services et une autre Portes. Entre ces 2 tables je n'ai pas une liaison N-N, mais uniquement une liaison avec Porte.

    Imaginons que j'ai ceci comme services;

    CA
    CA1
    CA2
    CA3
    CA31
    CA32
    CA4

    Ma table intermédaire (ServicePorte) qui "lie" services à portes pourait avoir ces enregistrements;

    CA3% porte1
    CA4 porte2

    Betement, je pensais pouvoir executer cette requette;

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    SELECT * FROM ServicePorte WHERE @Service LIKE ServiceCode
    ou
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    SELECT * FROM ServicePorte WHERE ServiceCode LIKE @Service

    @Service = 'CA31' par exemple


    Le but étant d'utiliser les caractères '%' et '?' présents dans la DB pour éffectuer le LIKE. Mais sql n'en tient pas compte.
    Avez-vous une idée car je suis obligé de suivre ce raisonement, la table est déjà remplie et il y a 4500 records.

    Merci d'avance

  2. #2
    Rédacteur

    Avatar de SQLpro
    Homme Profil pro
    Expert bases de données / SQL / MS SQL Server / Postgresql
    Inscrit en
    Mai 2002
    Messages
    21 837
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Expert bases de données / SQL / MS SQL Server / Postgresql
    Secteur : Conseil

    Informations forums :
    Inscription : Mai 2002
    Messages : 21 837
    Points : 52 922
    Points
    52 922
    Billets dans le blog
    5
    Par défaut
    Poste le DDL et les INSERT de tes tables STP.

    En cela tu respectera la charte de postage :
    http://www.developpez.net/forums/showthread.php?t=96701

    A +
    Frédéric Brouard - SQLpro - ARCHITECTE DE DONNÉES - expert SGBDR et langage SQL
    Le site sur les SGBD relationnels et le langage SQL: http://sqlpro.developpez.com/
    Blog SQL, SQL Server, SGBDR : http://blog.developpez.com/sqlpro
    Expert Microsoft SQL Server - M.V.P. (Most valuable Professional) MS Corp.
    Entreprise SQL SPOT : modélisation, conseils, audit, optimisation, formation...
    * * * * * Expertise SQL Server : http://mssqlserver.fr/ * * * * *

  3. #3
    Membre confirmé
    Avatar de frechy
    Inscrit en
    Novembre 2004
    Messages
    343
    Détails du profil
    Informations personnelles :
    Âge : 40

    Informations forums :
    Inscription : Novembre 2004
    Messages : 343
    Points : 511
    Points
    511
    Par défaut
    Bon j'avais pris des noms de tables pour que ca soit plus compréhensibles...


    Voici mes tables

    La table "Services" s'appelle en fait HierarchicalUnits:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    USE [PamDev]
    GO
    /****** Object:  Table [dbo].[HierarchicalUnits]    Script Date: 02/28/2008 10:58:08 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[HierarchicalUnits](
    	[HierarchicalUnitsCd] [nvarchar](20) NOT NULL,
    	[DepartmentsCd] [nchar](10) NULL,
    	[ActivatedFlg] [bit] NULL,
    	[DescriptionNL] [nvarchar](max) NULL,
    	[DescriptionFR] [nvarchar](max) NULL,
    	[DescriptionEN] [nvarchar](max) NULL,
     CONSTRAINT [PK_HierachicalUnits] PRIMARY KEY CLUSTERED 
    (
    	[HierarchicalUnitsCd] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
     
    GO
    ALTER TABLE [dbo].[HierarchicalUnits]  WITH CHECK ADD  CONSTRAINT [FK_HierachicalUnits_HierachicalUnits] FOREIGN KEY([DepartmentsCd])
    REFERENCES [dbo].[Departments] ([DepartmentsCd])
    GO
    ALTER TABLE [dbo].[HierarchicalUnits] CHECK CONSTRAINT [FK_HierachicalUnits_HierachicalUnits]

    La table "Portes" s'appelle ServiceCatalogSubCategories

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    USE [PamDev]
    GO
    /****** Object:  Table [dbo].[ServiceCatalogSubCategories]    Script Date: 02/28/2008 11:02:13 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[ServiceCatalogSubCategories](
    	[ServiceCatalogSubCategoriesCd] [nchar](10) NOT NULL,
    	[ServiceCatalogCategoriesCd] [nchar](15) NULL,
    	[ActivatedFlg] [bit] NOT NULL,
    	[RestrictedFlg] [bit] NULL,
    	[Description] [nvarchar](max) NULL,
    	[ValidFromDt] [datetime] NULL,
    	[ValidToDt] [datetime] NULL,
    	[ServiceCategoriesCd] [nchar](10) NULL,
    	[AgreementTypesCd] [nchar](10) NULL,
     CONSTRAINT [PK_ServiceCatalogSubCategories] PRIMARY KEY CLUSTERED 
    (
    	[ServiceCatalogSubCategoriesCd] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
     
    GO
    ALTER TABLE [dbo].[ServiceCatalogSubCategories]  WITH CHECK ADD  CONSTRAINT [FK_ServiceCatalogSubCategories_AgreementTypes] FOREIGN KEY([AgreementTypesCd])
    REFERENCES [dbo].[AgreementTypes] ([AgreementTypesCd])
    GO
    ALTER TABLE [dbo].[ServiceCatalogSubCategories] CHECK CONSTRAINT [FK_ServiceCatalogSubCategories_AgreementTypes]
    GO
    ALTER TABLE [dbo].[ServiceCatalogSubCategories]  WITH CHECK ADD  CONSTRAINT [FK_ServiceCatalogSubCategories_ServiceCatalogCategories] FOREIGN KEY([ServiceCatalogCategoriesCd])
    REFERENCES [dbo].[ServiceCatalogCategories] ([ServiceCatalogCategoriesCd])
    GO
    ALTER TABLE [dbo].[ServiceCatalogSubCategories] CHECK CONSTRAINT [FK_ServiceCatalogSubCategories_ServiceCatalogCategories]
    GO
    ALTER TABLE [dbo].[ServiceCatalogSubCategories]  WITH CHECK ADD  CONSTRAINT [FK_ServiceCatalogSubCategories_ServicesCategories] FOREIGN KEY([ServiceCategoriesCd])
    REFERENCES [dbo].[ServicesCategories] ([ServicesCategoriesCd])
    GO
    ALTER TABLE [dbo].[ServiceCatalogSubCategories] CHECK CONSTRAINT [FK_ServiceCatalogSubCategories_ServicesCategories]

    Et la table qui lie ces 2 tables (sans vraiment les lier);

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    USE [PamDev]
    GO
    /****** Object:  Table [dbo].[ServiceCatalogSubCategoryRequestors]    Script Date: 02/28/2008 11:02:48 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[ServiceCatalogSubCategoryRequestors](
    	[ServiceCatalogSubCategoriesCd] [nchar](10) NOT NULL,
    	[HUWildCard] [nchar](10) NOT NULL,
    	[ActivatedFlg] [bit] NULL,
     CONSTRAINT [PK_ServiceCatalogSubCategoryRequestors] PRIMARY KEY CLUSTERED 
    (
    	[ServiceCatalogSubCategoriesCd] ASC,
    	[HUWildCard] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
     
    GO
    ALTER TABLE [dbo].[ServiceCatalogSubCategoryRequestors]  WITH CHECK ADD  CONSTRAINT [FK_ServiceCatalogSubCategoryRequestors_ServiceCatalogSubCategories] FOREIGN KEY([ServiceCatalogSubCategoriesCd])
    REFERENCES [dbo].[ServiceCatalogSubCategories] ([ServiceCatalogSubCategoriesCd])
    GO
    ALTER TABLE [dbo].[ServiceCatalogSubCategoryRequestors] CHECK CONSTRAINT [FK_ServiceCatalogSubCategoryRequestors_ServiceCatalogSubCategories]

    Et voici quelques enregistrements dans ces tables;

    HierarchicalUnits
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNO', N'0         ', 0, N'Brussels Network Operations', N'Brussels Network Operations', N' ')
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNO0', N'0         ', 0, N'Assistentie directie', N'Assistance direction', N'')
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA', N'1         ', 1, N'Asset Management', N'Asset Management', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA1', N'1         ', 1, N'Beheer Investeringen & Onderhoud', N'Gestion Investissements & Maintenance', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA2', N'1         ', 1, N'TMFO', N'TMFO', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA21', N'1         ', 1, N'Methodes Elektriciteit & Techn.Opleid.', N'Méthodes Electr. & Formations Techniques', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA211', N'1         ', 1, N'Technische Opleidingen', N'Formations Techniques', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA212', N'1         ', 1, N'Methodes Elektriciteit', N'Méthodes Electricité', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA22', N'1         ', 1, N'Methodes Gas & Kwaliteitscontrole', N'Méthodes Gaz & Contrôle Qualité', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA221', N'1         ', 1, N'Methodes Gas', N'Méthodes Gaz', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA222', N'1         ', 1, N'Kwaliteitscontrole', N'Contrôle Qualité', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA3', N'1         ', 1, N'Aankopen & Opdrachten', N'Achats & Marchés', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA31', N'1         ', 1, N'Beheer van de Opdrachten', N'Gestion des Marchés', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA32', N'1         ', 1, N'Aankopen', N'Achats', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA33', N'1         ', 1, N'Aankopen & Opdrachten', N'Achats & Marchés', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA4', N'1         ', 1, N'Bevoorrading & Alg. Tech. Diensten', N'Approv. locaux et STG', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA41', N'1         ', 1, N'Plan.aank.& Bevoorradingsbeh.& Admin ATD', N'Planif.Achats & Gestion appros & Adm STG', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA42', N'1         ', 1, N'Technische Diensten Logistiek', N'Service Techniques Logistiques', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA421', N'1         ', 1, N'Studies & Projecten', N'Etudes & Projets', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA422', N'1         ', 1, N'Leiding & Toezicht', N'Conduite & Surveillance', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA423', N'1         ', 1, N'Transport/Kitting/Express Delivery', N'Transport/Kitting/Express Delivery', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA424', N'1         ', 1, N'VGV - Vervoer - Gereedschap', N'NGV - Charroi - Outillage', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA43', N'1         ', 1, N'Binnenmagazijn', N'Approvisionnements', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA44', N'1         ', 1, N'Buitenmag./Uitrusting/Werkkledij', N'Mag. Ext./Dot./Vêtements de travail', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA45', N'1         ', 1, N'Documentaire Logistieke Diensten', N'Service logistiques documentaires', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA451', N'1         ', 1, N'Secretariaat', N'Secrétariat', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA452', N'1         ', 1, N'Reprografie', N'Reprographie', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOA46', N'1         ', 1, N'Mobiliteitsbeheer', N'Gestion Mobilité', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOB', N'2         ', 1, N'Netbeheer', N'Gestion des Réseaux', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOB1', N'2         ', 1, N'Studies', N'Etudes', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOB11', N'2         ', 1, N'Tekenbureel', N'Bureau de dessin', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOB111', N'2         ', 1, N'Detailplan G/E, aftak. & Urbis kaart', N'Plan détail G/E, branch. & carte Urbis', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOB1111', N'2         ', 1, N'Beheer Grafische Gegevens', N'Gestion des Données Graphiques', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOB1112', N'2         ', 1, N'Bijwerken Urbis', N'Mise à jour Urbis', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOB11121', N'2         ', 1, N'Bijwerken Detailplannen Sector Oost', N'Mise à jour plans de détails Sect. Est', NULL)
     
    INSERT INTO [dbo].[HierarchicalUnits] ([HierarchicalUnitsCd], [DepartmentsCd], [ActivatedFlg], [DescriptionNL], [DescriptionFR], [DescriptionEN])
    VALUES (N'BNOB11122', N'2         ', 1, N'Bijwerken Detailplannen Sector West', N'Mise à jour plans de détails Sect. Ouest', NULL)
    ServiceCatalogSubCategories
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    INSERT INTO [dbo].[ServiceCatalogSubCategories] ([ServiceCatalogSubCategoriesCd], [ServiceCatalogCategoriesCd], [ActivatedFlg], [RestrictedFlg], [Description], [ValidFromDt], [ValidToDt], [ServiceCategoriesCd], [AgreementTypesCd])
    VALUES (N'0         ', N'0              ', 1, 0, N'Création/suppression', '20070807', '20991231', NULL, N'1         ')
     
    INSERT INTO [dbo].[ServiceCatalogSubCategories] ([ServiceCatalogSubCategoriesCd], [ServiceCatalogCategoriesCd], [ActivatedFlg], [RestrictedFlg], [Description], [ValidFromDt], [ValidToDt], [ServiceCategoriesCd], [AgreementTypesCd])
    VALUES (N'1         ', N'0              ', 1, NULL, N'Desktop (bundle)', '20000101', '29000101', NULL, NULL)
     
     
    INSERT INTO [dbo].[ServiceCatalogSubCategories] ([ServiceCatalogSubCategoriesCd], [ServiceCatalogCategoriesCd], [ActivatedFlg], [RestrictedFlg], [Description], [ValidFromDt], [ValidToDt], [ServiceCategoriesCd], [AgreementTypesCd])
    VALUES (N'2         ', N'0              ', 1, NULL, N'Email adress', '20000101', '29000101', NULL, NULL)
     
    INSERT INTO [dbo].[ServiceCatalogSubCategories] ([ServiceCatalogSubCategoriesCd], [ServiceCatalogCategoriesCd], [ActivatedFlg], [RestrictedFlg], [Description], [ValidFromDt], [ValidToDt], [ServiceCategoriesCd], [AgreementTypesCd])
    VALUES (N'3         ', N'1              ', 1, NULL, N'Thin Client', '20000101', '29000101', NULL, NULL)
     
    INSERT INTO [dbo].[ServiceCatalogSubCategories] ([ServiceCatalogSubCategoriesCd], [ServiceCatalogCategoriesCd], [ActivatedFlg], [RestrictedFlg], [Description], [ValidFromDt], [ValidToDt], [ServiceCategoriesCd], [AgreementTypesCd])
    VALUES (N'4         ', N'1              ', 1, NULL, N'Laptop', '20000101', '29000101', NULL, NULL)
     
    INSERT INTO [dbo].[ServiceCatalogSubCategories] ([ServiceCatalogSubCategoriesCd], [ServiceCatalogCategoriesCd], [ActivatedFlg], [RestrictedFlg], [Description], [ValidFromDt], [ValidToDt], [ServiceCategoriesCd], [AgreementTypesCd])
    VALUES (N'5         ', N'1              ', 1, NULL, N'Display 17''''', '20000101', '29000101', NULL, NULL)
     
    INSERT INTO [dbo].[ServiceCatalogSubCategories] ([ServiceCatalogSubCategoriesCd], [ServiceCatalogCategoriesCd], [ActivatedFlg], [RestrictedFlg], [Description], [ValidFromDt], [ValidToDt], [ServiceCategoriesCd], [AgreementTypesCd])
    VALUES (N'6         ', N'1              ', 1, NULL, N'Display 19"', '20000101', '29000101', NULL, NULL)
     
    INSERT INTO [dbo].[ServiceCatalogSubCategories] ([ServiceCatalogSubCategoriesCd], [ServiceCatalogCategoriesCd], [ActivatedFlg], [RestrictedFlg], [Description], [ValidFromDt], [ValidToDt], [ServiceCategoriesCd], [AgreementTypesCd])
    VALUES (N'7         ', N'1              ', 1, NULL, N'Mouse', '20000101', '29000101', NULL, NULL)
    ServiceCatalogSubCategoryRequestors
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    INSERT INTO [dbo].[ServiceCatalogSubCategoryRequestors] ([ServiceCatalogSubCategoriesCd], [HUWildCard], [ActivatedFlg])
    VALUES (N'1         ', N'BNOA1%    ', 1)
     
    INSERT INTO [dbo].[ServiceCatalogSubCategoryRequestors] ([ServiceCatalogSubCategoriesCd], [HUWildCard], [ActivatedFlg])
    VALUES (N'1         ', N'BNOB      ', 1)
     
    INSERT INTO [dbo].[ServiceCatalogSubCategoryRequestors] ([ServiceCatalogSubCategoriesCd], [HUWildCard], [ActivatedFlg])
    VALUES (N'2         ', N'BNO%      ', 1)
     
    INSERT INTO [dbo].[ServiceCatalogSubCategoryRequestors] ([ServiceCatalogSubCategoriesCd], [HUWildCard], [ActivatedFlg])
    VALUES (N'2         ', N'BNOA%     ', 1)
     
    INSERT INTO [dbo].[ServiceCatalogSubCategoryRequestors] ([ServiceCatalogSubCategoriesCd], [HUWildCard], [ActivatedFlg])
    VALUES (N'3         ', N'BNOA3?    ', 1)
     
    INSERT INTO [dbo].[ServiceCatalogSubCategoryRequestors] ([ServiceCatalogSubCategoriesCd], [HUWildCard], [ActivatedFlg])
    VALUES (N'4         ', N'BNOA      ', 1)
     
    INSERT INTO [dbo].[ServiceCatalogSubCategoryRequestors] ([ServiceCatalogSubCategoriesCd], [HUWildCard], [ActivatedFlg])
    VALUES (N'5         ', N'BNOA1     ', 1)
     
    INSERT INTO [dbo].[ServiceCatalogSubCategoryRequestors] ([ServiceCatalogSubCategoriesCd], [HUWildCard], [ActivatedFlg])
    VALUES (N'6         ', N'BNOA2     ', 1)

    Le but est de faire un LIKE en utilisant les valeurs de la colonne HUWildCard...une sorte de LIKE inversé...

    Si vous ne comprenez-pas ce que je veux, n'hésitez pas à me demander.

    Merci

  4. #4
    Membre confirmé
    Avatar de frechy
    Inscrit en
    Novembre 2004
    Messages
    343
    Détails du profil
    Informations personnelles :
    Âge : 40

    Informations forums :
    Inscription : Novembre 2004
    Messages : 343
    Points : 511
    Points
    511
    Par défaut
    Un ami a trouvé la solution.

    Du moins celà semble fonctionner...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    declare @test nvarchar(10)
    set @test = 'CA31'
     
    select *
    from ServiceCatalogSubCategoryRequestors
    WHERE (charindex('%',HUWildCard) > 0 and @test like substring(HUWildCard,0,charindex('%',HUWildCard)) + '%')
    or (charindex('?',HUWildCard) > 0 and @test like substring(HUWildCard,0,charindex('?',HUWildCard)) + '_')

    Je n'ai pas encore testé en profondeur, mais celà semble tenir la route.
    Si vous avez d'autres idées, ca m'intersse toujours.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [SQL Server 2005] équivalent like '%' pour int
    Par Zobbiwan dans le forum Langage SQL
    Réponses: 4
    Dernier message: 01/10/2008, 15h27
  2. [SQL 2005] Stocker des fichiers
    Par NicoNGRI dans le forum MS SQL Server
    Réponses: 4
    Dernier message: 06/02/2006, 10h05
  3. SQL Access: clause like?
    Par rapace dans le forum Requêtes et SQL.
    Réponses: 3
    Dernier message: 03/02/2006, 14h39
  4. [ADO.Net][C#/SQL 2005] Comment faire INSERT avec variable ?
    Par hduchemin dans le forum Accès aux données
    Réponses: 1
    Dernier message: 25/01/2006, 17h34
  5. Aide pour requête de Tri assez spécial (Oracle)
    Par Chips dans le forum Langage SQL
    Réponses: 2
    Dernier message: 29/04/2005, 10h56

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo