Hi Can anyone help me here.
I have a SQL server (BCSQL1)that is linked to a remote server (DENSQL1). I have a query that I need to run that will go from BCSQL1 to DENSQL1, pull specific information from DENSQL1 and then insert it into a table on BCSQL1.
I need all the current days data.
Database is: AVS
Tables are: Transaction_Info and Trans_Feature_Info
Transaction_Info has a date column (stored as a string).
I need collect all the data from Trans_Feature_Info table on DENSQL1 and insert it into Trans_Feature_Info table on BCSQL1 using todays date.
Here is the query.
declare @currentyear varchar(4)
declare @currentmonth varchar(2)
declare @currentday varchar(2)
select @currentyear = datepart(Year, getdate())
if len(datepart(Month, getdate())) <2
select @currentmonth = '0' + substring(str(datepart(Month, getdate()),2),2,1)
else
select @currentmonth = datepart(Month, getdate())
if len(datepart(Day, getdate())) <2
select @currentday = '0' + substring(str(datepart(Day, getdate()),2),2,1)
else
select @currentday = datepart(Day, getdate())
INSERT INTO Trans_Feature_Info
SELECT * FROM "DENSQL1".AVS.dbo.Trans_Feature_Info inner join "DENSQL1".AVS.dbo.Transaction_Info
on Trans_Feature_Info.Transaction_ID = Transaction_Info.Transaction_ID
WHERE (left(Transaction_Info.Trans_Date,8) = @currentmonth + @currentday + @currentyear)
ANy help would be greatly appreciated.
Regards
Honyo
I have a SQL server (BCSQL1)that is linked to a remote server (DENSQL1). I have a query that I need to run that will go from BCSQL1 to DENSQL1, pull specific information from DENSQL1 and then insert it into a table on BCSQL1.
I need all the current days data.
Database is: AVS
Tables are: Transaction_Info and Trans_Feature_Info
Transaction_Info has a date column (stored as a string).
I need collect all the data from Trans_Feature_Info table on DENSQL1 and insert it into Trans_Feature_Info table on BCSQL1 using todays date.
Here is the query.
declare @currentyear varchar(4)
declare @currentmonth varchar(2)
declare @currentday varchar(2)
select @currentyear = datepart(Year, getdate())
if len(datepart(Month, getdate())) <2
select @currentmonth = '0' + substring(str(datepart(Month, getdate()),2),2,1)
else
select @currentmonth = datepart(Month, getdate())
if len(datepart(Day, getdate())) <2
select @currentday = '0' + substring(str(datepart(Day, getdate()),2),2,1)
else
select @currentday = datepart(Day, getdate())
INSERT INTO Trans_Feature_Info
SELECT * FROM "DENSQL1".AVS.dbo.Trans_Feature_Info inner join "DENSQL1".AVS.dbo.Transaction_Info
on Trans_Feature_Info.Transaction_ID = Transaction_Info.Transaction_ID
WHERE (left(Transaction_Info.Trans_Date,8) = @currentmonth + @currentday + @currentyear)
ANy help would be greatly appreciated.
Regards
Honyo