Registriert seit: 12. Dez 2004
Ort: Wien, Österriech
893 Beiträge
Delphi 6 Enterprise
|
Re: ADOQuery SQL und REPLACE
27. Okt 2009, 14:56
Wenn ich folgende SQL-Statement ausführe, bekomme ich das Resultat wie im anhang.
SQL-Code:
USE [Test]
GO
/****** Object: Table [dbo].[CallDetail] Script Date: 10/27/2009 14:51:25 ******/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CallDetail]') AND type in (N'U'))
DROP TABLE [dbo].[CallDetail]
GO
/****** Object: Table [dbo].[CallDetail] Script Date: 10/27/2009 14:51:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[CallDetail](
[LocalUser] [nvarchar](50) NOT NULL,
[LocalNumber] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_CallDetail] PRIMARY KEY CLUSTERED
(
[LocalUser] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
INSERT INTO [CallDetail] ([LocalUser], [LocalNumber]) VALUES ('UserName1', '123')
INSERT INTO [CallDetail] ([LocalUser], [LocalNumber]) VALUES ('UserName2', '%0UNKNOWNNUMBER0%')
SELECT [LocalUser]
,[LocalNumber]
FROM [dbo].[CallDetail]
SELECT [LocalUser]
, Replace(LocalNumber,'0UNKNOWNNUMBER0','unbekannt') AS LocalNumber
FROM [dbo].[CallDetail]
Select
LocalUser,
case when CHARINDEX('0UNKNOWNNUMBER0', LocalNumber) > 0 then
Replace(LocalNumber,'0UNKNOWNNUMBER0','unbekannt') else LocalNumber end AS LocalNumber
from
CallDetail
Dein Problemm scheint wo anders zu sein, weil SQL-Behfele funktionieren wie gewollt.
Katura Haris Es (ein gutes Wort) ist wie ein guter Baum, dessen Wurzel fest ist und dessen Zweige in den Himmel reichen.
|
|
Zitat
|