Click here to Skip to main content
15,892,005 members
Home / Discussions / Database
   

Database

 
AnswerRe: Updating Data on Other Server?? Pin
Mycroft Holmes4-Jan-10 13:17
professionalMycroft Holmes4-Jan-10 13:17 
GeneralRe: Updating Data on Other Server?? Pin
AmbiguousName5-Jan-10 3:54
AmbiguousName5-Jan-10 3:54 
GeneralRe: Updating Data on Other Server?? Pin
Mycroft Holmes5-Jan-10 11:05
professionalMycroft Holmes5-Jan-10 11:05 
GeneralRe: Updating Data on Other Server?? Pin
AmbiguousName5-Jan-10 13:47
AmbiguousName5-Jan-10 13:47 
Questionexported the first column of an excel file to a table Pin
deva23-Jan-10 23:05
deva23-Jan-10 23:05 
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 
this is the modeified code ro make the SCOPE_IDENTITY clear but of course still the same problem

DECLARE @rec_id int, @client_id int, @client_cpr varchar(50), @client_name varchar(255), @account_number_string VARCHAR(50), @account_number numeric(38,0)

DECLARE		account_numbers CURSOR FOR
SELECT		clients.client_id, clients.client_cpr, clients.client_name
FROM		clients
ORDER BY	clients.client_name

OPEN account_numbers

FETCH NEXT FROM account_numbers INTO @client_id, @client_cpr, @client_name

WHILE @@FETCH_STATUS = 0
BEGIN
	INSERT INTO accounts_summary (client_category, client_id, cr_cpr_number, account_number, account_name) VALUES ('I', @client_id, @client_cpr, 0, @client_name)
	SET @rec_id = SCOPE_IDENTITY()
	-- get random from 1 to 7
	SET @account_number_string = RIGHT('0' + convert(varchar(1), DATEPART(WEEKDAY, GETDATE())), 1)
	-- get random from 1 to 365
	SET @account_number_string = @account_number_string + RIGHT('000' + convert(varchar(3), DATEPART(DAYOFYEAR, GETDATE())), 3)
	SET @account_number_string = @account_number_string + RIGHT('0000000' + convert(varchar(7), @rec_id), 7)
	SET @account_number = convert(bigint, @account_number_string)
	UPDATE accounts_summary SET account_number = @account_number WHERE account_id = @rec_id
	UPDATE clients SET account_number = @account_number WHERE client_id = @client_id
	
	FETCH NEXT FROM account_numbers INTO @client_id, @client_cpr, @client_name
END

CLOSE account_numbers
DEALLOCATE account_numbers

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 
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 

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.