Geeks With Blogs
Bunch's Blog One day I'll have a catchy subtitle, one day

To print multiple int variables on one line you need to CAST them first. Otherwise the PRINT command will add them up (at least it does for me anyways using SQL 2008). In the example I needed to have two ID variables print out while I was working on a sproc so I could see if I was getting the correct IDs before adding in my update code.

This did not work, it adds the two variables together:

PRINT @FirstID + ‘ – ‘ + @NextID

This does work, it prints each variable with the dash in-between:

PRINT CAST(@FirstID AS Varchar(20)) + ‘ – ‘ + CAST(@NextID AS Varchar(20))

Technorati Tags:
Posted on Thursday, October 20, 2011 10:48 AM | Back to top


Comments on this post: PRINT Ints in TSQL

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Bunch | Powered by: GeeksWithBlogs.net | Join free