Afternoon All,
I deperately need some help here.
I have SQL installed on 2 different servers DSQL and VSQL.
I have a database called AVS with a table called Transaction_Info (on both servers).
DSQL and VSQL are linked server via VSQL.
I need to run a query that will check a column on VSQL (local server)called Transacton_ID and pull the highest value. It will pass this value to a variable.
The next portion will then connect to the other SQL server DSQL, take the variable and compare it to that column, it there are any values higher than the variable, it will insert all the values higher than the variable into the local (VSQL) table.
I have this:
USE AVS
DECLARE @transid varchar(30)
select @transid = (select MAX(Transaction_ID) from Transaction_Info)
INSERT INTO Transaction_Info SELECT * FROM DSQL.AVS.dbo.Transaction_Info
where Transaction_ID > @transid
This works well. Now the problem (-:
All values start with 1 or 2. I need the variable to only search through the values that start with 1 and then follow the above route.
I have:
USE AVS
DECLARE @transid varchar(30)
select @transid = (select MAX(Transaction_ID) from Transaction_Info
where left(Transaction_ID,1) = 1)
INSERT INTO Transaction_Info SELECT * FROM DSQL.AVS.dbo.Transaction_Info
where Transaction_ID > @transid
This does not work )-: and I have no idea why. Any suggestions?
Regards
Honyo
I deperately need some help here.
I have SQL installed on 2 different servers DSQL and VSQL.
I have a database called AVS with a table called Transaction_Info (on both servers).
DSQL and VSQL are linked server via VSQL.
I need to run a query that will check a column on VSQL (local server)called Transacton_ID and pull the highest value. It will pass this value to a variable.
The next portion will then connect to the other SQL server DSQL, take the variable and compare it to that column, it there are any values higher than the variable, it will insert all the values higher than the variable into the local (VSQL) table.
I have this:
USE AVS
DECLARE @transid varchar(30)
select @transid = (select MAX(Transaction_ID) from Transaction_Info)
INSERT INTO Transaction_Info SELECT * FROM DSQL.AVS.dbo.Transaction_Info
where Transaction_ID > @transid
This works well. Now the problem (-:
All values start with 1 or 2. I need the variable to only search through the values that start with 1 and then follow the above route.
I have:
USE AVS
DECLARE @transid varchar(30)
select @transid = (select MAX(Transaction_ID) from Transaction_Info
where left(Transaction_ID,1) = 1)
INSERT INTO Transaction_Info SELECT * FROM DSQL.AVS.dbo.Transaction_Info
where Transaction_ID > @transid
This does not work )-: and I have no idea why. Any suggestions?
Regards
Honyo