I have been opening a file every morning for months and manually (or Find and Replace) the date. My buddy suggested a computed value to get the date for me. I am now at the point of putting the whole thing together and having problems understanding the correct number of tick (') marks and the spacing.
It compiles but never shows me anything from the linked server. How does one get the tick marks right; trial and error?
Thanks
Alan
Code:
USE Alan_Test --Contains copy of real table
DECLARE @yesterday varchar(6)
SELECT @yesterday=CONVERT(varchar(6),getdate()-1,12) --Use prev date
PRINT @yesterday
INSERT INTO Inventory_Hist
([DATE_ACCT_YR],[DATE_ACCT_MO],[PART],[LOCATION],[DATE_HISTORY]
,[COST],[JOB],[SUFFIX],[SEQ],[DEBIT_PROD_LN],[A50_CUSTOMER])
SELECT *
FROM OPENQUERY(BALCUB,'select *
FROM BALCWF.Inventory_Hist
WHERE DATE_HISTORY=''''''+@yesterday+'''''' ')
Thanks
Alan