Click here to Skip to main content
15,849,032 members
Home / Discussions / Database
   

Database

 
AnswerRe: Sql server 2008 R2 Express Edition working very slow why? Pin
Mycroft Holmes25-Mar-15 16:35
professionalMycroft Holmes25-Mar-15 16:35 
Questionhow to create a chart from a database in android eclipse .. please help me :D Pin
Pungkas Soebarkah25-Mar-15 0:24
Pungkas Soebarkah25-Mar-15 0:24 
AnswerRe: how to create a chart from a database in android eclipse .. please help me :D Pin
Mycroft Holmes25-Mar-15 16:16
professionalMycroft Holmes25-Mar-15 16:16 
QuestionNDF File Pin
Member 1133602724-Mar-15 9:45
Member 1133602724-Mar-15 9:45 
QuestionRe: NDF File Pin
ZurdoDev24-Mar-15 9:51
professionalZurdoDev24-Mar-15 9:51 
AnswerRe: NDF File Pin
Richard Deeming24-Mar-15 10:15
mveRichard Deeming24-Mar-15 10:15 
AnswerRe: NDF File Pin
Richard Deeming24-Mar-15 10:18
mveRichard Deeming24-Mar-15 10:18 
QuestionHelp needed on string function Pin
Ambertje24-Mar-15 7:01
Ambertje24-Mar-15 7:01 
Hi everyone,

I'm strugling with a string function.
I have a PRODUCT field and it contains 4 kind of values:
a) 000000000000001234
b) 000000000000123456
c) 000000000001234567
d) 000000000123456789



I want the values to look like this:
[1] if the length of PRODUCT without zeros is smaller then
7 the output is:
a) 0001234
b) 0123456
[2] if the length of PRODUCT without zeros is equal to 7 then output is:
c) 1234567
[3] If the lengt of PRODUCT without zeros is equal to 9 then output is:
d) 123456789


The If statements [1] and [2] are taken care of with af function that I call in my statement:
ALTER FUNCTION [dbo].[LPAD]
(
	-- Add the parameters for the function here
	-- Test with data as nvarchar like in Staging 
	@SourceString nvarchar(MAX), --Varchar(MAX),
	@FinalLength int,
	@PadChar Char(1)
)
RETURNS nvarchar(MAX) --Varchar(MAX) --<Function_Data_Type, ,Int>

WITH SCHEMABINDING

AS
BEGIN
	RETURN --<@ResultVar, sysname, @Result>
	(Select REPLICATE(@PadChar,@FinalLength - Len(@SourceString)) + @SourceString)
END


SQL statement:
SQL
, CAST(RTRIM(dbo.LPAD(SUBSTRING(dbo.SD.PRODUCT, PATINDEX('%[^0]%',dbo.SD.PRODUCT+ ''), LEN(dbo.SD.PRODUCT)), 7, 0))
    AS nvarchar(255))                                                                                       AS PRODUCT


So if PRODUCT is smaller then 7 chars I need a zero to make a maximum length of 7 chars. The first 11 zero's need to dissapear and thats taken care of with the above function and statement.

It's the third statement that gives me a headache, I also want the PRODUCT with 9 chars without any leading zero.
Does anyone know how I can integrate the 3rd if please ???

Kind regards,
Ambertje
AnswerRe: Help needed on string function Pin
Kornfeld Eliyahu Peter24-Mar-15 8:42
professionalKornfeld Eliyahu Peter24-Mar-15 8:42 
GeneralRe: Help needed on string function Pin
Ambertje25-Mar-15 0:43
Ambertje25-Mar-15 0:43 
GeneralRe: Help needed on string function Pin
Johan Hakkesteegt8-Apr-15 3:36
Johan Hakkesteegt8-Apr-15 3:36 
QuestionVB.NET MYSQL DATATABLE Pin
Pauls Pauls21-Mar-15 5:33
Pauls Pauls21-Mar-15 5:33 
AnswerRe: VB.NET MYSQL DATATABLE Pin
Peter Leow21-Mar-15 5:56
professionalPeter Leow21-Mar-15 5:56 
AnswerRe: VB.NET MYSQL DATATABLE Pin
manchanx21-Mar-15 6:14
professionalmanchanx21-Mar-15 6:14 
GeneralRe: VB.NET MYSQL DATATABLE Pin
Pauls Pauls21-Mar-15 7:16
Pauls Pauls21-Mar-15 7:16 
QuestionOracle, inner join and substr function Pin
Ludwing RS20-Mar-15 10:29
Ludwing RS20-Mar-15 10:29 
AnswerRe: Oracle, inner join and substr function Pin
Eddy Vluggen20-Mar-15 11:21
professionalEddy Vluggen20-Mar-15 11:21 
AnswerRe: Oracle, inner join and substr function Pin
Jörgen Andersson20-Mar-15 14:20
professionalJörgen Andersson20-Mar-15 14:20 
GeneralRe: Oracle, inner join and substr function Pin
Ludwing RS23-Mar-15 9:02
Ludwing RS23-Mar-15 9:02 
QuestionSSRS merging main header of two columns into one and then splitting subheadings Pin
indian14316-Mar-15 13:39
indian14316-Mar-15 13:39 
QuestionSSRS Report not allowing to edit name of the field Pin
indian14316-Mar-15 12:44
indian14316-Mar-15 12:44 
AnswerRe: SSRS Report not allowing to edit name of the field Pin
Richard Deeming17-Mar-15 4:42
mveRichard Deeming17-Mar-15 4:42 
GeneralRe: SSRS Report not allowing to edit name of the field Pin
indian14318-Mar-15 13:46
indian14318-Mar-15 13:46 
QuestionHelp with SSAS project Pin
rafael.avaria16-Mar-15 8:10
rafael.avaria16-Mar-15 8:10 
QuestionProblem executing backup script in Sql Server 2012 Pin
delgaillo12-Mar-15 7:38
delgaillo12-Mar-15 7:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.