Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Updating the first row of a table

Author  Topic 

kgundava
Yak Posting Veteran

66 Posts

Posted - 2011-08-24 : 15:03:18
Hi All,
I have a SQl script where i have to update any random row for a particular table when i my variable = TEST .when i execute this below code it is me throwing an error saying invalid column XBLNR.Please help me.
NOTE: RDATA table get created dynamically in the script


If @TABLE_NAME = 'TEST'
BEGIN

UPDATE RDATA
SET XBLNR ='08976543210'
WHERE CLAR=
(
SELECT TOP 1 CLAR
FROM RDATA
)

gwilson67
Starting Member

42 Posts

Posted - 2011-08-25 : 00:29:59
Have you tried to use the fully qualified name in the update?

Update schema_name.RDATA...


Greg
http://www.freewebstore.org/tsqlcoderepository
Powerful tool for SQL Server development
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-25 : 01:51:28
check if has required column first

SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='RDATA' AND COLUMN_NAME='XBLNR'

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2011-08-25 : 01:53:44
"RDATA table get created dynamically in the script "

Perhaps that table exists, with different column definitions, when you are trying to create the Sproc. If you can then DROP the table before creating the Sproc.
Go to Top of Page
   

- Advertisement -