Wednesday, April 17, 2013
SQL'de Split Fonksiyonu
SQL'de Split Fonksiyonu
ALTER FUNCTION [dbo].[fn_Split](@text varchar(8000), @delimiter varchar(20) = ' ')
RETURNS @Strings TABLE
(
Split VarChar(1000)
)
AS
BEGIN
DECLARE @index int
SET @index = -1
WHILE (LEN(@text) > 0)
BEGIN
SET @index = CHARINDEX(@delimiter , @text)
IF (@index = 0) AND (LEN(@text) > 0)
BEGIN
INSERT INTO @Strings VALUES (@text)
BREAK
SQL'de bir tabloya index ekleme ve bu eklenen index'e göre tabloyu rebuild etme
Bir tabloya index ekleme ve bu eklenen index'e göre tabloyu rebuild etme
IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[t_Products]') AND name = N'x_Products_venderno')
DROP INDEX [x_Products_venderno] ON [dbo].[t_Products] WITH ( ONLINE = OFF )
GO
CREATE NONCLUSTERED INDEX [x_Products_venderno] ON [dbo].[t_Products]
(
[ds_id] ASC,
[vender_no] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
ALTER INDEX x_Products_venderno ON [dbo].[t_Products]
REBUILD;
Subscribe to:
Posts (Atom)