Create 2 Publications For Same Table

Mar 30, 2007

Hi



I created a DB named 'TestDB' and created a table called Users. This user table having 3 columns (Uname and pwd,version).



I need to create two publication for this user table.

1) Create a publication using all columns.

2) create a publication using Uname and pwd (not version column).



I am using Merge publication.



When I create first publication (any one - all 3 columns or any 2 coulmns) it create successfully.

When I create second publication it throws error. The details are below.





TITLE: New Publication Wizard
------------------------------

SQL Server Management Studio could not create article 'Users'.

------------------------------
ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

------------------------------

An article with a different subscriber_upload_options value already exists for object '[dbo].[Users]'.
Changed database context to 'TestDB'. (Microsoft SQL Server, Error: 20053)


How can i create the second publication? Is it possible? If yes, please give me the steps.



Thanks

View 3 Replies


ADVERTISEMENT

Replication - Publications

Dec 8, 1999

I'm trying to set up replication between two servers that both used to have SQL Server 6.5 on them. I was previously getting a 'The ID '114' was not found in the tasks collection' message and so decided to be on the safe side and remove and re-install SQL Server on both machines. Having successfully re-installed SQL Server 6.5 on both machines I then thought I'd try and set-up replication again. BUT as soon as try to install the publishing side of it the only option I have is to uninstall publishing ???? SQL Server on both machines appeared to uninstall and install nicely so how come it's still asking if I want to uninstall publishing ????

Any ideas would make my Xmas.

thanks Paul

View 1 Replies View Related

Same Article In Different Publications

Sep 23, 2005

Hi!

View 1 Replies View Related

Scripting Publications Via RMO

May 5, 2007

Hi



My first attempt at RMO is to create a job that will generate the SQL scripts necessary to recreate publications on a warm stanby server.



I thought I'd got a grip on the RMO object model, but whenever I call the script method, an empty string is generated.



Can anyone see what I'm doing wrong?



' Create connection to local server

serverConnection = New ServerConnection(".")

Try

' connect to publisher

serverConnection.Connect()

replicationServer = New ReplicationServer(serverConnection)

replicationDatabases = replicationServer.ReplicationDatabases

For Each replicationDatabase In replicationDatabases
If replicationDatabase.HasPublications Then
replicationDatabase.LoadProperties()
Console.WriteLine(replicationDatabase.Script(ScriptOptions.Creation))
End If

Next

Catch ex As Exception

Finally
serverConnection.Disconnect()

End Try

View 3 Replies View Related

Create Table From Text File, Extract Data, Create New Table From Extracted Data....

May 3, 2004

Hello all,

Please help....

I have a text file which needs to be created into a table (let's call it DataFile table). For now I'm just doing the manual DTS to import the txt into SQL server to create the table, which works. But here's my problem....

I need to extract data from DataFile table, here's my query:

select * from dbo.DataFile
where DF_SC_Case_Nbr not like '0000%';

Then I need to create a new table for the extracted data, let's call it ExtractedDataFile. But I don't know how to create a new table and insert the data I selected above into the new one.

Also, can the extraction and the creation of new table be done in just one stored procedure? or is there any other way of doing all this (including the importation of the text file)?

Any help would be highly appreciated.

Thanks in advance.

View 3 Replies View Related

How Do I Get Frequency Of Replication Publications

Jun 26, 2006

Hi, I right click on the publications and hit 'properties' but can't find where the frequency of them is.

Thanks,

-Trevor

View 1 Replies View Related

Database Restored, Publications Gone

Apr 20, 2006

hi all,



our datbase was restore but the publications were all gone.

however replication monitor shows publication and subscription.

worst. can create the publication with the same name because

it raises an error saying that it can't drop publication becuase

there is a subscription in it.

how can i remove the publication when the are already gone in the publication

folder but exist in the replication monitor



thanks for the help

View 4 Replies View Related

Probem With A Replication With Two Publications

Jun 12, 2006

Hi.

I have a database with two publications.
One publication is used to replicate data among 4 SQL Servers, while the other is used for the replication with SQL Server CE clients.
The problem here is that the SQLCE receive a number of changes that it is not correct.
Before establishing the publication for SQL Servers the SQL CE clients were working great, but now i have this problem.

Is there any patch or fix I should install on the server?, or do you know how can I solve this?

Thank you.

Omar Rojas

View 6 Replies View Related

Regarding Publications In Transactional Replication...

Jan 31, 2007

Hi,

                    We are using transactional replication with updatable subscriptions in SQL Server 2005. In our case both the publisher and the distributor is the same server. The subscription type is the Pull Subscription. It is set to run in the continuous running mode.

                  Can we have more than one publication in the same Distributor?

Please refer the link below :

http://msdn2.microsoft.com/en-us/library/ms152471.aspx

This link has a recommendation of the following under the heading "Queued Updating Subscriptions"

"There is only one Queue Reader Agent for each Distributor. It is recommended that for each Distributor, you configure at most one publication that is enabled for queued updating subscriptions."


In our case we need to have 6 publications with 4 subscriptions each (totally 24 Subscriptions).

Pls provide a reply for this asap.

Thanks and Regards,

Swapna.B.

View 1 Replies View Related

Why Publications Does Not Show In Replications

Sep 6, 2006

Dear All,

Greetings!!


I have installed SQL server 2005 Express and SQL server Mobile, and I was reading the Books online section to find out how to maintain the two databases consistancy.

Found : replication Option.

Problem : It only shows Local Subscriptions in SQL Server and In SQL Server Mobile only Subscription. I dont get a Publication Option.

Please correct if Wrong : SQL Serv Mobile is the one should Publish and SQL Serv hould Subscribe ya?

Please help me to sort this out.

View 1 Replies View Related

How To Restore Deleted Publications?

Apr 18, 2007

The setup is 3 sql 2000 servers, one with a number of publications, and two with transactional pull subscriptions.

The publications were accidentally deleted from the primary server when replication was removed from an older server that unfortunately had been cnamed to the primary server.

The subscriber servers now error "the subscription does not exist".

I had thought restoring the master and msdb on the publisher would bring the publications back but this has not happened. There are good backups of all the system and user databases on the publisher available, but not the scripts that created the publications for replication. Can anyone suggest how or what to restore to get the publications back on the primary server so we can restart replication?

Thank You!

[edit]
It also may be worth noting that the publisher is it's own distributor in this scenario.

View 5 Replies View Related

Subscribing To Two Publications On SQLCE

Nov 27, 2006

I have two publications on a SQL Server 2000 database.
I am able to create two subscriptions from another SQL Server 2000 database
and synchronize both in succession.

However when I try to repeat this going from SQL Server 2000 to SQLCE 2.0
it fails. The first goes OK. The second fails.
I get error 80004005, 28521 (The SQL Server CE database is already enabled for publication.
Is it possible to do what I am trying to do on CE?

The reason I have 2 publications is because the first is non-filtered and goes very fast via bcp files when reinitialized.
The second is dynamically filtered and not as fast. Breaking them up makes reinits go much faster.

My code is included below.

Thanks
Ed Santosusso
esantosusso@omicron.com

--------------------------------------------------------

// Create and initialize the Replication object
hr = CoCreateInstance(CLSID_Replication, NULL, CLSCTX_INPROC_SERVER, IID_ISSCEMerge, (LPVOID *)&CEMerge);
CEMerge->put_InternetURL(L"http://myiisserver/sqlce20/sscesa20.dll");
CEMerge->put_InternetLogin(L"<userid>");
CEMerge->put_InternetPassword(L"<password>");
CEMerge->put_Publisher(L"mysqlserver");
CEMerge->put_PublisherDatabase(L"MyDataBase");

CEMerge->put_Publication(L"Publication1");
CEMerge->put_PublisherSecurityMode((REPL_SECURITY_TYPE)DB_AUTHENTICATION);
CEMerge->put_PublisherLogin(L"sa");
CEMerge->put_PublisherPassword(L"mypassword");
CEMerge->put_PublisherNetwork((REPL_NETWORK_TYPE)DEFAULT_NETWORK);
CEMerge->put_Subscriber(L"TestReplAndMerge");
CEMerge->put_SubscriberConnectionString
(L"Provider=microsoft.sqlserver.oledb.ce.2.0;Data Source=\mydatabase.sdf");
CEMerge->put_Distributor(L"mysqlserver");
CEMerge->put_DistributorNetwork((REPL_NETWORK_TYPE)DEFAULT_NETWORK);
CEMerge->put_DistributorSecurityMode((REPL_SECURITY_TYPE)DB_AUTHENTICATION);
CEMerge->put_DistributorLogin(L"sa");
CEMerge->put_DistributorPassword(L"mypassword");
CEMerge->put_HostName(L"some host name");
CEMerge->put_ExchangeType((REPL_EXCHANGE_TYPE)BIDIRECTIONAL);
CEMerge->put_Validate(NO_VALIDATION);


bool NewFile = false;

// see if we need a file


if (FileExists(L"\mydatabase.sdf") == false)
{
hr = CEMerge->AddSubscription(CREATE_DATABASE);

if (!SUCCEEDED(hr))
{
ShowMergeErrors(L"Add Subscription failed",CEMerge);
return 0;
}
NewFile = true;
}


hr = CEMerge->Initialize();

if (!SUCCEEDED(hr)) {
ShowMergeErrors(L"Static Merge Initialize failed",CEMerge);
return 0;
}

hr = CEMerge->Run();
if (!SUCCEEDED(hr)) {
ShowMergeErrors(L"Static Merge Run failed",CEMerge);
return 0;
}


// Destroy the Replication object
if (CEMerge)
CEMerge->Release();



// set up for Second Merge

// Create and initialize the Replication object
hr = CoCreateInstance(CLSID_Replication, NULL, CLSCTX_INPROC_SERVER, IID_ISSCEMerge, (LPVOID *)&CEMerge2);
CEMerge2->put_InternetURL(L"http://myiisserver/sqlce20/sscesa20.dll");
CEMerge2->put_InternetLogin(L"<userid>");
CEMerge2->put_InternetPassword(L"<password>");
CEMerge2->put_Publisher(L"mysqlserver");
CEMerge2->put_PublisherDatabase(L"MyDataBase");

CEMerge2->put_Publication(L"Publication2");
CEMerge2->put_PublisherSecurityMode((REPL_SECURITY_TYPE)DB_AUTHENTICATION);
CEMerge2->put_PublisherLogin(L"sa");
CEMerge2->put_PublisherPassword(L"mypassword");
CEMerge2->put_PublisherNetwork((REPL_NETWORK_TYPE)DEFAULT_NETWORK);
CEMerge2->put_Subscriber(L"TestReplAndMerge");
CEMerge2->put_SubscriberConnectionString
(L"Provider=microsoft.sqlserver.oledb.ce.2.0;Data Source=\mydatabase.sdf");
CEMerge2->put_Distributor(L"mysqlserver");
CEMerge2->put_DistributorNetwork((REPL_NETWORK_TYPE)DEFAULT_NETWORK);
CEMerge2->put_DistributorSecurityMode((REPL_SECURITY_TYPE)DB_AUTHENTICATION);
CEMerge2->put_DistributorLogin(L"sa");
CEMerge2->put_DistributorPassword(L"mypassword");
CEMerge2->put_HostName(L"some host name");
CEMerge2->put_ExchangeType((REPL_EXCHANGE_TYPE)BIDIRECTIONAL);
CEMerge2->put_Validate(NO_VALIDATION);


if (NewFile)
{
hr = CEMerge2->AddSubscription(EXISTING_DATABASE);

if (!SUCCEEDED(hr))
{
ShowMergeErrors(L"Add Subscription failed",CEMerge2);
return 0;
}
}


hr = CEMerge2->Initialize();

if (!SUCCEEDED(hr)) {
ShowMergeErrors(L"Tech Merge Initialize failed",CEMerge2);
return 0;
}

hr = CEMerge2->Run();
if (!SUCCEEDED(hr)) {
ShowMergeErrors(L"Tech Merge Run failed",CEMerge2);
return 0;
}


// Destroy the Replication object
if (CEMerge2)
CEMerge2->Release();


View 1 Replies View Related

Checking Publications Are Subscribed To All Subs

Mar 11, 2005

Hi All

How can I checked the publication are subscribed to all subscribers?
is there any stored procedure or method to do this?

Thanks alot

Tolga

View 3 Replies View Related

All Replication Publications Suddenly Disappear

Jan 8, 2007

Hi:

Did you have any experience that all publications and their related jobs suddenly disappear?

I had a transactional pull replication between two servers, and distributor and subscriber in the same box; publisher was an AA cluster server.
The schedule of pulling was once a week.

Last Friday morning everything was working perfectly, but I found all publications and their related jobs disappear around 5pm

I checked with the sysadmin and he said nothing was changed on that period.

Did you have any idea about it?

Did you have any idea that I can prevent this happen again or any alert I can set up to monitor who drop it, when it was dropped and so on?

It is a SQL 2000 box and system table doest not take trigger.

Thanks in advance

Theresa

View 2 Replies View Related

Dropping Article On Transaction Publications.

Dec 8, 2006

In 2005 transactional replication, The following procedure worked (without dropping the subscription) when I dropped an article from a replicated database:

Drop article: On Publication Properties, uncheck the article (table, stored procedure or function).

Create a new snapshot.

Synchronize the push subscription.

DROP the article on the Publication and Subscriber databases.

Replication still works!
However, the following article says the subscription needs to be dropped and re-created when an article is dropped from publication: http://msdn2.microsoft.com/en-us/library/ms152493.aspx (Adding Articles to and Dropping Articles from Existing Publications ). For transactional publications, articles can be dropped with no special considerations prior to subscriptions being created. If an article is dropped after one or more subscriptions is created, the subscriptions must be dropped, recreated, and synchronized.
Under what conditions is dropping the subscription and recreating it absolutely necessary? I do not want to include this extra step.
Linda

View 1 Replies View Related

Replication :: Comparing Settings For Many Publications

Nov 16, 2015

We have many transactional publications, and would like to have identical settings on each of them. Is any way to compare settings of these publications using script?

View 3 Replies View Related

Problems On Create Proc Includes Granting Create Table Or View Perissinin SP

Aug 4, 2004

Hi All,

I'm trying to create a proc for granting permission for developer, but I tried many times, still couldn't get successful, someone can help me? The original statement is:

Create PROC dbo.GrantPermission
@user1 varchar(50)

as

Grant create table to @user1
go

Grant create view to @user1
go

Grant create Procedure to @user1
Go



Thanks Guys.

View 14 Replies View Related

Boolean: {[If [table With This Name] Already Exists In [this Sql Database] Then [ Don't Create Another One] Else [create It And Populate It With These Values]}

May 20, 2008

the subject pretty much says it all, I want to be able to do the following in in VB.net code):
 
{[If [table with this name] already exists [in this sql database] then [ don't create another one] else [create it and populate it with these values]}
 
How would I do this?

View 3 Replies View Related

Dynamic Create Table, Create Index Based Upon A Given Database

Jul 20, 2005

Can I dynamically (from a stored procedure) generatea create table script of all tables in a given database (with defaults etc)a create view script of all viewsa create function script of all functionsa create index script of all indexes.(The result will be 4 scripts)Arno de Jong,The Netherlands.

View 1 Replies View Related

Replication Best Practice Question: Split Publications

Aug 31, 2006

I am working on a replication design and getting closer to implementation. One of my major concerns is maintaining and updating stored procs and/or user defined functions.

The current design is a single publication, including tables, procs and functions (no views yet). All told there are about 686 articles in the publication. The tables are horizontally partitioned using dynamic filters based on the hostname of the subscriber. There are around 50 subscribers. Most will have small databases (< 250 MB). A few (2-3) will have much larger databases. I am mostly concerned that whenever I have to update a proc or function, I have to re-initialize the subscriptions and that pushes a TON of data out over the network and may interrupt service at the subscriber locations.

I see three options for the procs and functions:
1. Include them in the publication with the data tables
2. Place them in a separate (snapshot only) publication
3. Exclude them entirely from replication and maintain them manually

I am starting to lean towards option #2; but I am a bit concerned about maintaining a duplicate set of replication agents for each subscriber.

Any thoughts and/or comments?

Regards,

hmscott

Am I overlooking something? Is there an option that I have not considered?

View 5 Replies View Related

Replication: Transactional: Multi Publications, One Subscriber.

Jul 20, 2005

Greetings All, I was hoping that a replication sage might be able toanswer a question for me.I want to have one subscriber subscribing to N publishers. Iessentially have a company that has a main headquarters and threesatellite offices. I want each of the satellite offices to push theirdata up to the master database. From what I have read it seems likethis should not be a problem. Some questions that come to mind are:1.)Does the master need to be read only or can it be configured to beupdateable as well?2.)Can the distribution agent on all the publishers be set tocontinuously distribute or should it be staggered so as not to cause aproblem when another distribution agent is running?3.)If the distribution is set to "delay distribution" will this causechanges on the subscriber to be pushed out to the publishers?In this database guid's are used as pk's so the issue of pk collisionsis not a problem.I hope that this question is not too vague. My experience thus farwith replication has been simple one way transactional and simplemerge replication.Regards, Louis Frolio

View 3 Replies View Related

Install SQL Server 2005 On Top Of Express For Publications

Nov 21, 2006

Hi,

i have the SQL Server 2005 Express installed but i want to create publications so i´m going to install the Developer Edition.

Shoud i uninstall SQL Server Express before?

IN DE installation i have the following options:
sql server database servicesanalysis servicesreporting servicesnotification servicesintegration servicesworkstations components, books online and development toolsWhat is the minimum i have to install to create publications?

Thanks
SP

View 2 Replies View Related

Replication :: Backfill Data After Failed Publications

May 10, 2015

We have setup Transactional Replication that was originally initialized from a backup. Our subscriber recently had some hardware failures causing the publications to fail. We now have the server back up however the transactions for a few days have been missed, and data is now out of sync.

How do I go about resyncing that missing data? We have too many table to manually resync the data, and I cannot restore the database directly from a backup due to some permission issues and differences from the publisher. I've attempted to generate a new snapshot

However I get a message "[0%] A snapshot was not generated because no subscriptions need initialization."  My current understanding that is that I should be able to take a snapshot from the publisher and apply it to the subscriber, thus syncing all the data.

View 8 Replies View Related

Can CREATE DATABASE Or CREATE TABLE Be Wrapped In Transactions?

Jul 20, 2005

I have some code that dynamically creates a database (name is @FullName) andthen creates a table within that database. Is it possible to wrap thesethings into a transaction such that if any one of the following fails, thedatabase "creation" is rolledback. Otherwise, I would try deleting on errordetection, but it could get messy.IF @Error = 0BEGINSET @ExecString = 'CREATE DATABASE ' + @FullNameEXEC sp_executesql @ExecStringSET @Error = @@ErrorENDIF @Error = 0BEGINSET @ExecString = 'CREATE TABLE ' + @FullName + '.[dbo].[Image] ( [ID][int] IDENTITY (1, 1) NOT NULL, [Blob] [image] NULL , [DateAdded] [datetime]NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]'EXEC sp_executesql @ExecStringSET @Error = @@ErrorENDIF @Error = 0BEGINSET @ExecString = 'ALTER TABLE ' + @FullName + '.[dbo].[Image] WITHNOCHECK ADD CONSTRAINT [PK_Image] PRIMARY KEY CLUSTERED ( [ID] ) ON[PRIMARY]'EXEC sp_executesql @ExecStringSET @Error = @@ErrorEND

View 2 Replies View Related

Replication Folder's Didn't Locate Local Publications,need Help!

Apr 20, 2007

Hi,
i'm doing POS system by using C# in visual studio 2005. Recently, i installed the microsoft sql server management studio on my pc, i plan to do merge replication through local publications between my pocket pc and my pc. So, i opened the replication file which is under Object Explorer in microsoft sql server management studio, it ONLY show me the local subscription folder under the replication file.Do i install incomplete set of microsoft sql server management studio?Local publications and local subscription, which one is more suitable for POS system?

View 11 Replies View Related

Can't Set @replicate_ddl Parameter To 1 For Publications Enabled For Non-SQL Server Subscribers

Oct 17, 2007

Hi,
I am trying to replicate some tables from an Sql Server database to an Oracle database. So the publisher is SQL Server and the Subscriber is Oracle.

Unfortunately I realised that I can't set the replicate_ddl parameter to 1 for an Oracle Subscriber. This is the error I got:
"The property "replicate_ddl" cannot be modified for publications that are enabled for non-SQL Server subscriptions."

I looked on the Internet and I found that this parameter "@replicate_ddl" (used in the add_publication stored procedure) can't be set to 1 if the @enabled_for_het_sub parameter is set to 'true'.

So I thought if I just set the replicate_ddl parameter to 1 and leave the other parameter to false and then use the sp_changepublisher stored procedure to set the enabled_for_het_sub parameter to true that will work. But it didn't. I tried this in Enterprise Manager and although I had no error I realised that the replicate_ddl parameter was reset to false.


Is there any way I can replicate the ddl statements in Oracle automatically or I should to them manually?

View 4 Replies View Related

Replication :: Replicate Multiple Databases (publications) To One Central Subscriber?

Sep 2, 2015

We need to replicate multiple databases (publications) to one central subscriber. The schema of those articles are identical in all publications and also the primary keys in publications do not have any overlap.

Is this possible?If yes is there any specific thing that I should consider for it's implementation? Should each publication has it's own dedicated distributor or all of them can share one distributor?

View 2 Replies View Related

Default Table Owner Using CREATE TABLE, INSERT, SELECT && DROP TABLE

Nov 21, 2006

For reasons that are not relevant (though I explain them below *), Iwant, for all my users whatever privelige level, an SP which createsand inserts into a temporary table and then another SP which reads anddrops the same temporary table.My users are not able to create dbo tables (eg dbo.tblTest), but arepermitted to create tables under their own user (eg MyUser.tblTest). Ihave found that I can achieve my aim by using code like this . . .SET @SQL = 'CREATE TABLE ' + @MyUserName + '.' + 'tblTest(tstIDDATETIME)'EXEC (@SQL)SET @SQL = 'INSERT INTO ' + @MyUserName + '.' + 'tblTest(tstID) VALUES(GETDATE())'EXEC (@SQL)This becomes exceptionally cumbersome for the complex INSERT & SELECTcode. I'm looking for a simpler way.Simplified down, I am looking for something like this . . .CREATE PROCEDURE dbo.TestInsert ASCREATE TABLE tblTest(tstID DATETIME)INSERT INTO tblTest(tstID) VALUES(GETDATE())GOCREATE PROCEDURE dbo.TestSelect ASSELECT * FROM tblTestDROP TABLE tblTestIn the above example, if the SPs are owned by dbo (as above), CREATETABLE & DROP TABLE use MyUser.tblTest while INSERT & SELECT usedbo.tblTest.If the SPs are owned by the user (eg MyUser.TestInsert), it workscorrectly (MyUser.tblTest is used throughout) but I would have to havea pair of SPs for each user.* I have MS Access ADP front end linked to a SQL Server database. Forreports with complex datasets, it times out. Therefore it suit mypurposes to create a temporary table first and then to open the reportbased on that temporary table.

View 6 Replies View Related

What Is The Difference Between: A Table Create Using Table Variable And Using # Temporary Table In Stored Procedure

Aug 29, 2007

which is more efficient...which takes less memory...how is the memory allocation done for both the types.

View 1 Replies View Related

Create INDEX Within CREATE TABLE DDL

Jan 27, 2006

Hi Minor and inconsequential but sometimes you just gotta know: Is it possible to define a non-primary key index within a Create Table statement? I can create a constraint and a PK. I can create the table and then add the index. I just wondered if you can do it in one statement. e.g. I have: CREATE TABLE MyT (MyT_ID INT Identity(1, 1) CONSTRAINT MyT_PK PRIMARY KEY Clustered, MyT_Desc Char(40) NOT NULL CONSTRAINT MyT_idx1 UNIQUE NONCLUSTERED ON [DEFAULT])which creates a table with a PK and unique constraint. I would like (pseudo SQL):CREATE TABLE MyT (MyT_ID INT Identity(1, 1) CONSTRAINT MyT_PK PRIMARY KEY Clustered, MyT_Desc Char(40) NOT NULL CONSTRAINT MyT_idx1 UNIQUE INDEX NONCLUSTERED ON [DEFAULT]) No big deal - just curious :D Once I know I can stop scouring BOL for clues. Tks in advance

View 2 Replies View Related

SQL Server 2012 :: Stored Procedures Compiles Even When There Is No CREATE TABLE For A Temp Table

Feb 11, 2015

i am inserting something into the temp table even without creating it before. But this does not give any compilation error. Only when I want to execute the stored procedure I get the error message that there is an invalid temp table. Should this not result in a compilation error rather during the execution time.?

--create the procedure and insert into the temp table without creating it.
--no compilation error.
CREATE PROC testTemp
AS
BEGIN
INSERT INTO #tmp(dt)
SELECT GETDATE()
END

only on calling the proc does this give an execution error

View 3 Replies View Related

SSMS Express: Create TABLE &&amp; INSERT Data Into Table - Error Msgs 102 &&amp; 156

May 18, 2006

Hi all,

I have SQL Server Management Studio Express (SSMS Express) and SQL Server 2005 Express (SS Express) installed in my Windows XP Pro PC that is on Microsoft Windows NT 4 LAN System. My Computer Administrator grants me the Administror Privilege to use my PC. I tried to use SQLQuery.sql (see the code below) to create a table "LabResults" and insert 20 data (values) into the table. I got Error Messages 102 and 156 when I did "Parse" or "Execute". This is my first time to apply the data type 'decimal' and the "VALUES" into the table. I do not know what is wrong with the 'decimal' and how to add the "VALUES": (1) Do I put the precision and scale of the decimal wrong? (2) Do I have to use "GO" after each "VALUES"? Please help and advise.

Thanks in advance,

Scott Chang

///////////--SQLQueryCroomLabData.sql--///////////////////////////
USE MyDatabase
GO
CREATE TABLE dbo.LabResults
(SampleID int PRIMARY KEY NOT NULL,
SampleName varchar(25) NOT NULL,
AnalyteName varchar(25) NOT NULL,
Concentration decimal(6.2) NULL)
GO
--Inserting data into a table
INSERT dbo.LabResults (SampleID, SampleName, AnalyteName, Concentration)
VALUES (1, 'MW2', 'Acetone', 1.00)
VALUES (2, 'MW2', 'Dichloroethene', 1.00)
VALUES (3, 'MW2', 'Trichloroethene', 20.00)
VALUES (4, 'MW2', 'Chloroform', 1.00)
VALUES (5, 'MW2', 'Methylene Chloride', 1.00)
VALUES (6, 'MW6S', 'Acetone', 1.00)
VALUES (7, 'MW6S', 'Dichloroethene', 1.00)
VALUES (8, 'MW6S', 'Trichloroethene', 1.00)
VALUES (9, 'MW6S', 'Chloroform', 1.00)
VALUES (10, 'MW6S', 'Methylene Chloride', 1.00
VALUES (11, 'MW7', 'Acetone', 1.00)
VALUES (12, 'MW7', 'Dichloroethene', 1.00)
VALUES (13, 'MW7', 'Trichloroethene', 1.00)
VALUES (14, 'MW7', 'Chloroform', 1.00)
VALUES (15, 'MW7', 'Methylene Chloride', 1.00
VALUES (16, 'TripBlank', 'Acetone', 1.00)
VALUES (17, 'TripBlank', 'Dichloroethene', 1.00)
VALUES (18, 'TripBlank', 'Trichloroethene', 1.00)
VALUES (19, 'TripBlank', 'Chloroform', 0.76)
VALUES (20, 'TripBlank', 'Methylene Chloride', 0.51)
GO
//////////Parse///////////
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near '6.2'.
Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'VALUES'.
////////////////Execute////////////////////
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near '6.2'.
Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'VALUES'.

View 7 Replies View Related

Create Target Table Dynamically Based On Source Table Schema?

Sep 13, 2005

I’ve got a situation where the columns in a table we’re grabbing from a source database keep changing as we need more information from that database. As new columns are added to the source table, I would like to dynamically look for those new columns and add them to our local database’s schema if new ones exist. We’re dropping and creating our target db table each time right now based on a pre-defined known schema, but what we really want is to drop and recreate it based on a dynamic schema, and then import all of the records from the source table to ours.It looks like a starting point might be EXEC sp_columns_rowset 'tablename' and then creating some kind of dynamic SQL statement based on that. However, I'm hoping someone might have a resource that already handles this that they might be able to steer me towards.Sincerely, 
Bryan Ax

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved