sql - Using a function within a Select statement for conversion -
so let's have these 2 tables 5 columns, 4 of match last of have different data types, 1 being char, other being uniqueidentifier. have function, let's call dbo.x accepts uniqueidentifier , hunts down corresponding name elsewhere in database.
so need develop script copy data table1 table2 , convert last column using function.
after doing bit of research tried (which hasn't worked):
insert table1 (col1, col2, col3, col4, col5) select col1, col2, col3, col4, col5 dbo.x(table2.col5) table2
can give me little advice on go here?
you have switched expression , alias - syntax should follows:
insert table1 (col1, col2, col3, col4, col5) select col1, col2, col3, col4, dbo.x(table2.col5) col5 table2
in general, when use expression in select statement , give resultant column name, write expression first, , alias, e.g.
select <expression> <column-name> ...
Comments
Post a Comment