I'd like to simultaneously do two things in an MSSQL query:
- select a field's value into a variable
select @myvar = colName from tableName - alias my column
select colName as [myCol] from tableName
I've tried these things:
- Attempted Syntax
select @myvar = colName as [myCol] from tableName - Attempted Syntax
select @myvar = (colName as [myCol]) from tableName - Attempted Syntax
select (@myvar = colName) as [myCol] from tableName - checked select statement syntax: https://msdn.microsoft.com/en-us/library/ms176104.aspx
If this is possible, how can it be accomplished?
select @myvar as [myCol]select @myvar = (select (select colName as [myCol] from tableName))is probably the closes you will get if you want to do come kinf of textual analysis on the source