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

Database

 
QuestionProblem while importing the data into sql server 2005 . Pin
Pankaj Garg19-Mar-09 8:05
Pankaj Garg19-Mar-09 8:05 
AnswerRe: Problem while importing the data into sql server 2005 . Pin
knagnayak30-Mar-09 1:02
knagnayak30-Mar-09 1:02 
QuestionCounting fields Pin
stevemarsh9919-Mar-09 8:05
stevemarsh9919-Mar-09 8:05 
AnswerRe: Counting fields Pin
Blue_Boy19-Mar-09 8:35
Blue_Boy19-Mar-09 8:35 
AnswerRe: Counting fields Pin
Seren Singh20-Mar-09 1:09
Seren Singh20-Mar-09 1:09 
AnswerRe: Counting fields Pin
Seren Singh20-Mar-09 1:14
Seren Singh20-Mar-09 1:14 
GeneralRe: Counting fields Pin
Blue_Boy20-Mar-09 4:55
Blue_Boy20-Mar-09 4:55 
QuestionMaking Decisions in T-SQL??? Pin
Seren Singh19-Mar-09 5:33
Seren Singh19-Mar-09 5:33 
Hi Guys and Girls

I have been wrecking my brain all day trying to solve this problem and I hope some of you can help. I am using sql server 2005 to write a compounded stored procedure that does a series of things:

1. it reads the values from one column, removes the empty spaces around it, and stores it in another column (lets call it x) on the same table. *works*
2. it must check if the the new column (x) exists in the column of a different table *no errors*
3. if it exist, it needs to check if a value has 12 characters and begins with the character 's' *broken*
4. if it exist, it needs to check if another value has 13 characters and begins with the character 's'
5. finally, it must tag all the rows where the value exists in another table column

the code so far is:
ALTER PROCEDURE [dbo].[spValidateSerials]       
   @LineItemID int   
AS    
BEGIN
/*
Step 1: Remove leading & trailing spaces and copy into new columns
*/
UPDATE	dbo.SerialNumberStaging
	SET		dbo.SerialNumberStaging.NewSerialNumber = lTrim(rTrim(dbo.SerialNumberStaging.SerialNumber)),
			dbo.SerialNumberStaging.NewMacAddress = lTrim(rTrim(dbo.SerialNumberStaging.MacAddress))

/*
Step 2: check if vendor in 'list' (sn_vendorProduct)
*/
if @LineItemID IN (Select dbo.sn_VendorProduct.fkCompanyID from dbo.sn_VendorProduct)
	BEGIN
		-- step 3: check company & serial number
		if ((Len(dbo.SerialNumberStaging.NewSerialNumber) = 12) AND
			(SubString(dbo.SerialNumberStaging.NewSerialNumber, 1, 1) = 's'))
				UPDATE SerialNumberStaging
					SET SerialNumberStaging.NewSerialNumber = SubString(SerialNumberStaging.NewSerialNumber,2,11)
	END

/*
Step 5:	Compares SERIALNUMBERSTAGING table to LINEITEM table and 
		flags it in the SerialNumberStaging table if it	exists in
		the LintItem Table :)
*/
UPDATE	SerialNumberStaging
	SET		RowIsError = 1
		WHERE	(NewSerialNumber 
IN
	(SELECT SerialNumber FROM LineItem))      


RETURN 
END


as it stands, it is giving me the follwing error:
The multi-part identifier "dbo.SerialNumberStaging.NewSerialNumber" could not be bound. in reference to line 26 (the second IF statement)...

ANY HELP WILL BE GREATLY APPRECIATED!!!

Thanks
Answersp_help Pin
David Mujica19-Mar-09 6:22
David Mujica19-Mar-09 6:22 
GeneralRe: sp_help Pin
Seren Singh19-Mar-09 20:01
Seren Singh19-Mar-09 20:01 
AnswerRe: Making Decisions in T-SQL??? Pin
Seren Singh20-Mar-09 1:01
Seren Singh20-Mar-09 1:01 
QuestionSQL '#define' statement Pin
RChin19-Mar-09 4:21
RChin19-Mar-09 4:21 
AnswerDynamic SQL Pin
David Mujica19-Mar-09 4:40
David Mujica19-Mar-09 4:40 
AnswerRe: SQL '#define' statement Pin
Eddy Vluggen19-Mar-09 5:19
professionalEddy Vluggen19-Mar-09 5:19 
QuestionCalculating a number in a query... Pin
stevemarsh9919-Mar-09 3:35
stevemarsh9919-Mar-09 3:35 
Questionimport csv - xls Pin
AndyInUK18-Mar-09 23:53
AndyInUK18-Mar-09 23:53 
AnswerRe: import csv - xls Pin
Jason Lepack (LeppyR64)19-Mar-09 2:08
Jason Lepack (LeppyR64)19-Mar-09 2:08 
AnswerRe: import csv - xls Pin
Tim Carmichael19-Mar-09 2:10
Tim Carmichael19-Mar-09 2:10 
QuestionHowto dynamically set "Start with" value on a sequence in Oracle Pin
Jörgen Andersson18-Mar-09 22:29
professionalJörgen Andersson18-Mar-09 22:29 
AnswerRe: Howto dynamically set "Start with" value on a sequence in Oracle Pin
Garth J Lancaster19-Mar-09 0:10
professionalGarth J Lancaster19-Mar-09 0:10 
GeneralRe: Howto dynamically set "Start with" value on a sequence in Oracle Pin
Jörgen Andersson19-Mar-09 1:11
professionalJörgen Andersson19-Mar-09 1:11 
GeneralRe: Howto dynamically set "Start with" value on a sequence in Oracle Pin
Garth J Lancaster19-Mar-09 1:17
professionalGarth J Lancaster19-Mar-09 1:17 
GeneralRe: Howto dynamically set "Start with" value on a sequence in Oracle Pin
Jörgen Andersson19-Mar-09 5:31
professionalJörgen Andersson19-Mar-09 5:31 
AnswerRe: Howto dynamically set "Start with" value on a sequence in Oracle Pin
Jörgen Andersson19-Mar-09 5:30
professionalJörgen Andersson19-Mar-09 5:30 
QuestionCreate and Execute a control flow task withing the Script task in SSIS Pin
CodalcoholicNBrainy18-Mar-09 22:07
CodalcoholicNBrainy18-Mar-09 22:07 

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.