Stangleboy
Programmer
I am sorry to post a second time but I think the code at the end is close, the error I get is it cannot find my database on my machine:
(Msg 911, Level 16, State 1, Line 1
Could not locate entry in sysdatabases for database 'DCSS'. No entry found with that name. Make sure that the name is entered correctly.
Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'INSERT'.)-->
--Original--
I am trying to copy select records from a table on another server to my local computer using MS SQL Server Management Studio for SQL Server 2008 R2. The table does not exist on my machine and I would like to create and then copy the table structure (indexes, etc.) and table data. I only have read rights to the host server and cannot make views, but I can make temporary tables if this helps. I have been searching the forum/web and found pieces here and there but I cannot seem to incorporate them together to get my end results. One issue is that there are over 11millions records and 42 fields that are in the table so when I try to use the "Export/Import" function the process dies on my computer (and I have a quad core 64-bit system). Any help will be greatly appreciated.
My goals are:
1. Have it run as one script.
2. Create the new table in the database.
3. Copy table structure and data for select records (see code below).
This host database name is "AH1PD01" and I have the server IP if needed for the code (Ithink this is my main issue is writing the code to use the full server name and database name correctly). My database name on my local machine is "DataRep". Thank you again in advance.
"USE DataRep
GO
CREATE TABLE dbo.PARTICIPANT_DEMOGRAPHIC
INSERT INTO dbo.PARTICIPANT_DEMOGRAPHIC
SELECT DISTINCT
PD.*
FROM
CASE_CAS As CC INNER JOIN
CASE_PARTICIPANT As CP ON CC.C_CASE_ID = CP.CP_CASE_ID INNER JOIN
PARTICIPANT_DEMOGRAPHIC As PD ON CP.CP_PRTCP_ID = PD.P_PRTCP_ID
WHERE
CC.C_MNG_CNTY_FIPS_CD = '071'
AND CC.C_PND_CLS_STAT_CD <> 'ACT'
AND CC.C_CRNT_STAT_CD = 'OPN'
(Msg 911, Level 16, State 1, Line 1
Could not locate entry in sysdatabases for database 'DCSS'. No entry found with that name. Make sure that the name is entered correctly.
Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'INSERT'.)-->
--Original--
I am trying to copy select records from a table on another server to my local computer using MS SQL Server Management Studio for SQL Server 2008 R2. The table does not exist on my machine and I would like to create and then copy the table structure (indexes, etc.) and table data. I only have read rights to the host server and cannot make views, but I can make temporary tables if this helps. I have been searching the forum/web and found pieces here and there but I cannot seem to incorporate them together to get my end results. One issue is that there are over 11millions records and 42 fields that are in the table so when I try to use the "Export/Import" function the process dies on my computer (and I have a quad core 64-bit system). Any help will be greatly appreciated.
My goals are:
1. Have it run as one script.
2. Create the new table in the database.
3. Copy table structure and data for select records (see code below).
This host database name is "AH1PD01" and I have the server IP if needed for the code (Ithink this is my main issue is writing the code to use the full server name and database name correctly). My database name on my local machine is "DataRep". Thank you again in advance.
"USE DataRep
GO
CREATE TABLE dbo.PARTICIPANT_DEMOGRAPHIC
INSERT INTO dbo.PARTICIPANT_DEMOGRAPHIC
SELECT DISTINCT
PD.*
FROM
CASE_CAS As CC INNER JOIN
CASE_PARTICIPANT As CP ON CC.C_CASE_ID = CP.CP_CASE_ID INNER JOIN
PARTICIPANT_DEMOGRAPHIC As PD ON CP.CP_PRTCP_ID = PD.P_PRTCP_ID
WHERE
CC.C_MNG_CNTY_FIPS_CD = '071'
AND CC.C_PND_CLS_STAT_CD <> 'ACT'
AND CC.C_CRNT_STAT_CD = 'OPN'