Avatar of deer777
deer777
Flag for United States of America asked on

MS Access SQL Server Table Connection

I need to connect to a SQL Server table from MS Access.  The table name in Access is 123 but the SQL Server table name is 123_v_username.  I need the table name (123) to stay the same in Access but only change the connection string from SQL Server to change to 123_v_username.  How would I write the code to do this.
Microsoft AccessMicrosoft SQL ServerSQL

Avatar of undefined
Last Comment
Jim Dettman (EE MVE)

8/22/2022 - Mon
Pawan Kumar

You can do like below

Pass the name of the table at runtime

Exec('' select columnname from ' + variabletablename + '')
ASKER CERTIFIED SOLUTION
Jim Dettman (EE MVE)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy