Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Newbie to SQL. Variables don't appear to work.

$
0
0

I'm fairly inexperienced with SQL as a language. I can get buy with simple stuff, but I'm far from a DBA. Right now I've been asked to help a client clean up some pretty major data validity issues in a particular database. Here's the code I'm trying to use:

SQL
Useengage;DECLARE@oldvalvarchar;DECLARE@newvalvarchar;SET@oldval=' ENGINEERING'SET@newval='ENGINEERING'updategagemastsetstorage_loc=@newvalWherestorage_loc=@oldvalupdategagemastsetCURRENT_loc=@newvalWhereCURRENT_loc=@oldval
There are two fields in the table "gagemast" that need to be updated. The values I'm trying to set for variables @oldval and @newval are representative of the issues we're having.

Unfortunately, I'm doing something wrong here with the variable syntax. If I replace the variables in the UPDATE statements, the query works. As written,...

Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>