I am working on a query that copies the table structure from a linked server to a local database for a common list of tables.
However, for some reason, decimal data types are changing to numeric. It seems like this happens when you select on more connected servers. However, when I try to do the same on my local system, I could not replicate the problem.
In the environment where this error occurred, the SQL version of the local and linked server was different (10, 12, respectively). Not sure if this is related.
If anyone could shed light on this, that would be very grateful. Thanks.
The request is as follows:
WHILE (select count(*) from @tbls) > 0 BEGIN SELECT @id = 0, @tblname = '', @cols = '', @colSets = '' select top 1 @id = ID, @tblname = TableName, @PKField = PKField, @DataType = DataType from @tbls if exists (select 1 from sys.tables where name = @tblname) begin delete from @tbls where ID = @id Continue; end exec('select * into '+ @tblname +' from [linkedserver].MyDatabase.dbo.' +@tblname + ' where 1 = 0') delete from @tbls where ID = @id END
stubs source share