Click here to Skip to main content
15,891,981 members
Home / Discussions / Database
   

Database

 
Questionloop problem Pin
Jassim Rahma3-Jan-10 21:02
Jassim Rahma3-Jan-10 21:02 
AnswerRe: loop problem Pin
Jassim Rahma3-Jan-10 22:30
Jassim Rahma3-Jan-10 22:30 
GeneralRe: loop problem Pin
Jassim Rahma3-Jan-10 22:39
Jassim Rahma3-Jan-10 22:39 
GeneralRe: loop problem Pin
Mycroft Holmes3-Jan-10 23:45
professionalMycroft Holmes3-Jan-10 23:45 
GeneralRe: loop problem Pin
Jassim Rahma4-Jan-10 2:01
Jassim Rahma4-Jan-10 2:01 
GeneralRe: loop problem Pin
Corporal Agarn4-Jan-10 3:56
professionalCorporal Agarn4-Jan-10 3:56 
AnswerRe: loop problem Pin
Tim Carmichael4-Jan-10 5:54
Tim Carmichael4-Jan-10 5:54 
AnswerRe: loop problem Pin
Ben Fair6-Jan-10 7:41
Ben Fair6-Jan-10 7:41 
Could it possibly have anything to do with using GETDATE() to construct 'random' portions of the string? Each pass through the loop will render the same values until the server system clock flips to the next day. It seems to me you will always get the exact same value for each pass of the loop until the next day arrives. I also don't understand your use of the RIGHT() function, perhaps it is some odd way of padding with 0's. In each case it seems you concatenate 000's + some value and then pull the 'some value' you just concatenated from the 000's; why not just use the values themselves and not clutter it up by concatenating the 000's and values together only to turn around and take the values off? If you need to pad try using the REPLICATE() function, as it will be easier to read:

DECLARE @hold varchar(50)
SET @hold = convert(varchar(7), SCOPE_IDENTITY()) -- or @recid
SET @hold = REPLICATE('0', 7 - LEN(@hold)) + @hold -- pad to desired length of 7
-- REPLICATE('0', 0) does not produce an error


Also if you truly need to get a random value try using the NEWID() function which will return a random GUID.

Hold on a second here... Don't you think you might be putting the horse ahead of the cart?

QuestionDebugging in SQL Server 2005 Pin
meeram3953-Jan-10 18:45
meeram3953-Jan-10 18:45 
AnswerRe: Debugging in SQL Server 2005 Pin
meeram3953-Jan-10 19:09
meeram3953-Jan-10 19:09 
QuestionMultiple values associated with a single value Pin
shrims4u2-Jan-10 22:19
shrims4u2-Jan-10 22:19 
AnswerRe: Multiple values associated with a single value Pin
Rob Philpott2-Jan-10 22:32
Rob Philpott2-Jan-10 22:32 
AnswerRe: Multiple values associated with a single value Pin
Corporal Agarn4-Jan-10 2:18
professionalCorporal Agarn4-Jan-10 2:18 
GeneralRe: Multiple values associated with a single value Pin
AmbiguousName4-Jan-10 7:32
AmbiguousName4-Jan-10 7:32 
QuestionBest Practices Q Pin
Member 45019402-Jan-10 8:55
Member 45019402-Jan-10 8:55 
AnswerRe: Best Practices Q Pin
DarrenShultz2-Jan-10 11:01
DarrenShultz2-Jan-10 11:01 
AnswerRe: Best Practices Q Pin
Eddy Vluggen2-Jan-10 23:43
professionalEddy Vluggen2-Jan-10 23:43 
QuestionMS SQL Server Not Updating Column Names Pin
Brendan Vogt2-Jan-10 1:51
Brendan Vogt2-Jan-10 1:51 
AnswerRe: MS SQL Server Not Updating Column Names Pin
Andy_L_J2-Jan-10 8:02
Andy_L_J2-Jan-10 8:02 
GeneralRe: MS SQL Server Not Updating Column Names Pin
Brendan Vogt3-Jan-10 1:38
Brendan Vogt3-Jan-10 1:38 
GeneralRe: MS SQL Server Not Updating Column Names Pin
Andy_L_J3-Jan-10 16:40
Andy_L_J3-Jan-10 16:40 
AnswerRe: MS SQL Server Not Updating Column Names Pin
Ashfield3-Jan-10 8:19
Ashfield3-Jan-10 8:19 
QuestionDatabase Name Pin
Brendan Vogt2-Jan-10 1:48
Brendan Vogt2-Jan-10 1:48 
AnswerRe: Database Name Pin
Eddy Vluggen2-Jan-10 4:55
professionalEddy Vluggen2-Jan-10 4:55 
AnswerRe: Database Name Pin
Mycroft Holmes2-Jan-10 17:14
professionalMycroft Holmes2-Jan-10 17:14 

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.