Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2003
    Posts
    2

    Unanswered: SQL Stored Procedure Problems

    I'm trying to pull data from a SQL table and populate a pre-existing Access97 table (template) with the same fields as the SQL table using a stored procedure.

    Unfortunately, it's not working.... Here's the statement in the procedure:

    INSERT INTO " + @DbName + "...tbl_Master (n_number, serial_number, mfr_mdl_code) SELECT n_number, serial_number, mfr_mdl_code FROM tbl_AC_Master WHERE state = '" + @State + "'

    Where @DbName is the database name and @State is the variable state (which are both being passed to the procedure)....

    Any ideas why the procedure won't populate the Access97 db? If nothing seems obvious with this SQL statement (I can't see anything), anything that can be suggested to look for would be greatly appreciated!

    Thanks!

  2. #2
    Join Date
    Aug 2002
    Location
    Scotland
    Posts
    1,578
    Refer to sp_executesql topic under BOL for more information on using dynamic sql and batch statements.

    HTH
    --Satya SKJ
    Microsoft SQL Server MVP
    [IMG]http://sqlserver-qa.net/google_bart.gif[/IMG]

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Don't you have too many dots in your code?

    INSERT INTO " + @DbName + "...tbl_Master

    should be

    INSERT INTO " + @DbName + "..tbl_Master

    since the syntax for full declaration is Server.Database.Owner.Table?
    Maybe your code is looking for a server named @DbName?

    blindman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •