I'm trying to create sql statement in TSQL that looks like this:
INSERT INTO UsersTable (UserName) VALUES (@UserName)
This is easy until you're trying to do it dynamically in T-Sql and @UserName is a varchar
The it looks like this:
SELECT @SQLInsert = 'INSERT INTO UsersTable (UserName) ' +
'VALUES (' + @UserName + ')'
Except of course this doesn't work. How many ticks do I need to create ticks in a string???? Driving me crazy!