Historical Table - INSERT And SELECT With Linked Server

Aug 13, 2012

I have a historical table on a dedicated SQL Server (let's call it the reporting db) that is populated every morning with production data that does not already exist. The data in the prod table is purged after 7 days and nothing is ever deleted from the historical table. I have set up the linked server between the two 2008 SQL Servers, but when I try to run this simple query from the reporting DB, it takes more than 5 minutes and still "executing". I eventually have to cancel it:

-- INSERT INTO Temp_Import_historical
SELECT TOP 1 *
FROM [192.168.1.100].ProdDB.dbo.Temp_Import_historical a
WHERE NOT EXISTS (select [Temp_Import_ID] from Temp_Import_historical where a.[Temp_Import_ID] = Temp_Import_historical.[Temp_Import_ID])

I have omitted the INSERT statement on purpose, since I can't even get to output 1 row. Why this is such a resource intensive query?

View 9 Replies


ADVERTISEMENT

Insert Into Table On Linked Server

Oct 23, 2006

Insert statement to remote server is running very slowly. I have run Profiler and find there is a 'sp_cursor' call for each row. The source system is SQL2005 and destination is SQL2000(sp4). The linked server is using 'SQL server' type connection. Source query is against a single table with a where clause. source and destination table are identical with Primary keys. Purpose is just to move the rows. Connection is a slow network connection - should be ok. I have already overcome same problem for related update and delete queries by use of 'EXECUTE (query) AT LinkedServer' that works great - but insert can not take advantage of this...

INSERT [LinkedServSQL2000sp4].dbname.schema.tablename
({column list})
Select
 {column list}
from tablename
WHERE col1 =  '7/20/2006'
  AND col2 in (2,5,7,12,32,54,45,33)

Any thoughts?

View 1 Replies View Related

Access - SQL Server Linked Table : Insert Failed

Oct 12, 2000

Good afternoon one and all,

I have the folowing problem that I could use some help with :

I have an SQL server database acting as a back end to an access dbase. The SQL srv table contains over 32 million records and I am trying to use an append query (in access) to import a further 2 million records to the SQLSRV table. The append query fails with the message 'Insert on table bcdsales failed' followed by an ODBC timeout error message. I can append one record fine but a mass import fails.

Unfortunately i can't use SQL srv to do the import (internal policy says we must stick with access front end for now).

Any and all ideas welcomed.

TIA for your time and attention

Gurmi

View 2 Replies View Related

Linked Server Unable To Insert Result Into A Table

Jul 12, 2007

I have a 2000 machine which calls a stored procedure on another 2000 machine via a linked server. The results come back and insert into a temporary table.



When I use the same code executing the from the 2000 machine over to 2005 machine via a linked server I cannot insert into the table. But I am able to see the data if I remove the insert statement.



I have tried to place the data into a permanent table without success. I have also checked to be sure the linked server properties are the same.



Any help on this would be appreciated. Below is the code. It is very simple and returns only one value but the bigger procedure that is ran returns several records and mutliple columns. This seems to easy but doesn't work.



DECLARE @retval AS INT

DECLARE @value AS INT



SET @value = 4



CREATE TABLE #TempTable (Value DECIMAL(19, 10) NULL)



INSERT INTO #TempTable

EXEC @RetVal = Server.Database.dbo.testproc @value



SELECT * FROM #TempTable

DROP TABLE #TempTable

View 6 Replies View Related

T-SQL (SS2K8) :: OPENQUERY Syntax To Insert Into Server Table From Oracle Linked Server

Aug 28, 2014

I was trying to figure out what the OPENQUERY Syntax is to Insert into SQL Server Table from Oracle Linked Server.

View 7 Replies View Related

SQL Server 2012 :: How To Insert Data Into Table From Linked Server

Nov 19, 2013

I wonder if it possible to move data from tables on a linked server to a "normal database"?

Name linked server: Covas
Name table on linked server: tblCountries
Name field: cntCountryName

Name "normal" database: CovasCopy
Name "normal" table: Countries (or dbo.Countries)
Name "normal" field: Country

This is just a test setup. I figure that if I get this working the rest will be easier.

My current query:
select * from openquery(COVAS,'
INSERT INTO CovasCopy.dbo.Countries(Country)
SELECT cntCountryName FROM db_covas.tblCountries;')

View 8 Replies View Related

SQL Server 2014 :: Combine Data From Historical Table?

Aug 13, 2014

Recently, I partitioned one of my largest tables into multiple monthly field groups. For the current month, it is attached to my "Active' table. The older records are kept in the "historical" table. I need an efficient way to pull records when have a date range that can be spread across both tables.

View 9 Replies View Related

SQL Server 2014 :: Add Multiple Records To Table (insert / Select)?

Jul 31, 2014

I am trying to add multiple records to my table (insert/select).

INSERT INTO Users
( User_id ,
Name
)
SELECT ( SELECT MAX(User_id) + 1
FROM Users
) ,
Name

But I get the error:

Violation of PRIMARY KEY constraint 'PK_Users'. Cannot insert duplicate key in object 'dbo.Users'.

But I am using the max User_id + 1, so it can't be duplicate

This would insert about 20 records.

Why the error?

View 7 Replies View Related

Bulk Insert Into Views That Select From Table On Remote Server

Jul 20, 2005

Hi all,We have an application through which we are bulk inserting rows into aview. The definition of the view is such that it selects columns froma table on a remote server. I have added the servers usingsp_addlinkedserver on both database servers.When I call the Commit API of oledb I get the following error:Error state: 1, Severity: 19, Server: TST-PROC22, Line#: 1, msg:SqlDumpExceptionHandler: Process 66 generated fatal exception c0000005EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.I would like to know if we can bulk insert rows into a view thataccesses a table on the remote server using the "bulk insert" or bcpcommand. I tried a small test through SQL Query Analyser to use "bulkinsert" on a such a view.The test that I performed was the following:On database server 1 :create table iqbal (var1 int, var2 int)On database server 2 (remote server):create view iqbal as select var1,var2 from[DBServer1].[SomeDB].[dbo].[iqbal]set xact_abort onbulk insert iqbal from '\MachineIqbaliqbaldata.txt'The bulk insert operation failed with the following error message:[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionCheckForData(CheckforData()).Server: Msg 11, Level 16, State 1, Line 0General network error. Check your network documentation.Connection BrokenThe file iqbaldata.txt contents were :112233If the table that the view references is on the same server then weare able to bulk insert successfully.Is there a way by which I should be able to bulk insert rows into aview that selects from a table on a remote server. If not then couldanyone suggest a workaround. I would actually like to know someworkaround to get the code working using OLEDB. Due to unavoidablereasons I cannot output the records to the file and then use bcp tobulk insert the records in the remote table. I need to have some wayof doing it using OLEDB.Thanks in advanceIqbal

View 7 Replies View Related

SQL Server 2012 :: Insert Multiple Rows In A Table With A Single Select Statement?

Feb 12, 2014

I have created a trigger that is set off every time a new item has been added to TableA.The trigger then inserts 4 rows into TableB that contains two columns (item, task type).

Each row will have the same item, but with a different task type.ie.

TableA.item, 'Planning'
TableA.item, 'Design'
TableA.item, 'Program'
TableA.item, 'Production'

How can I do this with tSQL using a single select statement?

View 6 Replies View Related

BACKUP TABLE(historical)

Jul 20, 2005

How to build a TRIGGER that copies, all the time, the data from the table onwhich the transaction occurs to the historical table?thanksFernand---Outgoing mail is certified Virus Free.Checked by AVG anti-virus system (http://www.grisoft.com).Version: 6.0.659 / Virus Database: 423 - Release Date: 2004-04-15

View 1 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

Using Historical Attributes With SCD Transform On A Table With A PK

Aug 8, 2007

I must be missing something somewhere...

I have a simple table with three fields: ID, LastName, FirstName. The ID is defined as the PK. In the table is a record of "12345, Smith, John". The incoming flat file has a record of "12345, Smith, Johnny".

In the SCD transform, the ID is the business key, and Last Name and First Name are defined as historical attributes.

During the load, the SCD transform correctly sends the data down the right path, but the insert fails with a primary key violation - as I would expect since it's trying to create a new current record.

How do I get around this problem without removing the PK ???

thx

View 9 Replies View Related

HOWTO Insert Into ACCESS Linked Table Via OLE DB Destination Task

Jun 22, 2007

I have used an access linked table to import data from a sharePoint list hosted on SharePoint 2007 server.



I hope someone else has done this. (1)I Does anyone know of any other way to pull data from a SharePoint 2007 list.



(2)Has anyone pushed data to a SharePoint List from a SQL Server table?



I tried doing that via the linked table but the destination task of the data flow task does not allow me to push data into the table.



(3) Has anyone designed an SSIS package to write data to an AccESS table from a SQL Server table?



Any help would be appreciated

View 4 Replies View Related

Analysis :: Getting Historical Information From Dimension Table

Aug 17, 2015

Is it possible to design a Cube with a Dimension "DimEmployee" (SCD Type2) and Query the following: What "title" had the person "xyz" at time "2015-01-01"? - See Example data on Images.

I have also a DimTime with Day granularity. The DimEmployee is not at day granularity.

View 9 Replies View Related

T-SQL (SS2K8) :: Create Union View To Display Current Values From Table A And All Historical Values From Table B

May 6, 2014

I have 2 identical tables one contains current settings, the other contains all historical settings.I could create a union view to display the current values from table A and all historical values from table B, butthat would also require a Variable to hold the tblid for both select statements.

Q. Can this be done with one joined or conditional select statement?

DECLARE @tblid int = 501
SELECT 1,2,3,4,'CurrentSetting'
FROM TableA ta
WHERE tblid = @tblid
UNION
SELECT 1,2,3,4,'PreviosSetting'
FROM Tableb tb
WHERE tblid = @tblid

View 9 Replies View Related

Insert Into Linked Server

Mar 24, 2002

hi everybody.I have linked db2 server .Select from this server goes fine but when i do insert

case A

insert into pricing..UCIT.BOOM(A,B) VALUES(3,5)
OLE DB provider 'MSDASQL' reported an error. The provider did not give any information about the error

case B
SELECT * from
OPENQUERY(pricing, 'insert into UCIT.BOOM(A,B) VALUES(3,5)')
Server: Msg 7357, Level 16, State 2, Line 1
Could not process object 'insert into UCIT.BOOM(A,B) VALUES(3,5)'. The OLE DB provider 'MSDASQL' indicates that the object has no columns.



how to do insert into linked db2 server?
I am running SQL 2000 sp2 on WIN20000
and DB2 UDB 7.2 service pack 4

View 2 Replies View Related

Linked Server Insert

Nov 8, 2000

Hi,
I am trying to insert data from a SQL (7.0) table into an Access table but I get an error message saying the MS DTC is nor running. Apart from E.M, how can you check this. Using Query Analyzer I can select form tyhe destination table but not insert - perhaps I have missed something - acn you please help?

View 2 Replies View Related

The OLE DB Provider MSDAORA For Linked Server .... Does Not Contain The Table COUNTRY. The Table Either Does Not Exist Or The Current User Does Not Have Permissions On That Table.

Jun 13, 2006

I am using SQL Server 2005 and trying to create a linked server on Oracle 10. I used the commands below:
EXEC sp_addlinkedserver
@server = 'test1',
@srvproduct = 'Oracle',
@provider = 'MSDAORA',
@datasrc = 'testsource'
exec sp_addlinkedsrvlogin
@rmtsrvname = 'test1',
@useself = 'false',
@rmtuser='sp',
@rmtpassword='sp'
 
When I execute
select * from test1...COUNTRY
I get the error. "The OLE DB provider "MSDAORA" for linked server "...." does not contain the table "COUNTRY". The table either does not exist or the current user does not have permissions on that table."
The 'sp' user I am connecting is the owner of the table. What could be the problem ?
Thanks a lot.

View 3 Replies View Related

Insert Data To A Table Where Select Data From Another SERVER

Oct 8, 2007

I had a function like below :Public Sub Getdata2(ByVal query, ByVal db, ByVal name)
Dim selectSQL As StringDim con As SqlConnection
Dim cmd As SqlCommand
Dim reader As SqlDataReader
Trycon = New SqlConnection("User ID=xxx;password=xxx;persist security info=True;Initial Catalog=database1;Data Source=xxx.xxx.xxx.xxx.xxx,xxxxx;")
Dim username As String
username = Request.QueryString("username")
selectSQL = "SET DATEFORMAT DMY;Insert into table1(hse_num, st_name, proj_name, unit_num, postal, n_postal, flr_area, flr_sf, flr_rate, flr_ra_sf, land_area, land_sf, land_rate, lnd_ra_sf, prop_code, cont_date, title, sisv_ref, r_date, rec_num, source, username, DGP, Remarks, Sub_Code, caveat, consider, age) select hse_num, st_name, proj_name, unit_num, postal, n_postal, flr_area, flr_sf, flr_rate, flr_ra_sf, land_area, land_sf, land_rate, lnd_ra_sf, prop_code, cont_date, title, sisv_ref, r_date, rec_num, source, '" & username & "', DGP, Remarks, Sub_Code, caveat, consider, age from [yyy.yyy.yyy.yyy,yyyy].database2.dbo.table2 where " & querycmd = New SqlCommand(selectSQL, con)
con.Open()
reader = cmd.ExecuteReader()
lbl.Text = selectSQLCatch ex As Exception
lbl.Text = ex.Message
Finally
If (Not con Is Nothing) Then
con.Close()
con.Dispose()
End If
End Try
End Sub
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
May i know that how do i retrieve data from  [yyy.yyy.yyy.yyy,yyyy].database2.dbo.table2 due to diffrent server, diffrent UID and Password
 

View 1 Replies View Related

Identity Insert On A Linked Server

Feb 26, 2008

Hey there..
I need to insert some data into a linked server where I need to insert the Identity field. When I try to turn IDENTITY INSERT on, I get this error

The object name 'Server-SQL.MyDatabase.dbo.MyTable' contains more than the maximum number of prefixes. The maximum is 2.


The line I try to execute is this...
SET IDENTITY_INSERT [Server-SQL].MyDatabase.dbo.MyTable ON

From my searching around about this error, the workaround seems to be aliasing the table name, but I can't really see how to use an alias in this situation.

Thanks a bunch!
Greg

View 4 Replies View Related

Linked Server Insert Problem

Jul 23, 2005

I have two sql servers, I have defined each one as a linked server tothe other. I can mostly access the servers from one another, but I getthe following error on a sql insert.Insert statement...INSERT INTO [U1STSV02].[Custom Log Shipping].dbo.ls_secondary_files(database_name, tl_file_name, tl_applied, lsplanid, lssecid,compression_type) VALUES ('javaweb', 'c:', 'N', 1, 1, 0)i get an error messageServer: Msg 913, Level 16, State 8, Line 1Could not find database ID 10. Database may not be activated yet or maybe in transition.I can query the table with select using the followingselect * from [u1stsv02].[custom log shipping].dbo.ls_secondary_filesand I can delete rows from the table usingdelete from [u1stsv02].[custom log shipping].dbo.ls_secondary_filesI have searched Microsoft's site and googled for a while and cannot seemto find a solution.Both servers are running SQL Server 2000 with service pack 4Thanks in advance for any replies.Steve KuekesPhysicians Pharmacy Alliancejust remove the "1", "2", "3" from my email to reach me.

View 2 Replies View Related

Insert Into Linked Server Problem

Mar 6, 2007

hi,on localServer i execute this queryINSERT INTO table (A, B, C)SELECT A, B, C FROM LinkedServer.myDB.dbo.tableeverything is fine. But if i execute this oneINSERT INTO LinkedServer.myDB.dbo.table (A, B, C)SELECT A, B, C FROM tableit is very slow. Is there any solution to make it any faster?

View 2 Replies View Related

Insert Problem With Linked Server

Jul 20, 2005

Both servers running SQL 2000I have set up on our local SQL server (using Enterprise Manager) a linkedserver running on our ISP. Just did new linked server and added remotepassword and login.The following three queries work:insert into LinkedServer.dbname.dbo.Table2select *from LinkedServer.dbname.dbo.Table1select *into LocalTablefrom LinkedServer.dbname.dbo.Table1insert into LocalTableselect *from LinkedServer.dbname.dbo.Table1This query, which is what we really want to do, does not work:insert into LinkedServer.dbname.dbo.Table1select *from LocalTableand returns the error: 'The cursor does not include the table being modifiedor the table is not updatable through the cursor.'I am new to all this and would welcome some help.Adrian

View 1 Replies View Related

How To Insert Into A Table Using A Select From Xml

Dec 20, 2007

Good Day,
I am passing some XML into a stored procedure:
<answers>  <answer id="60" text="" />   <answer id="65" text="A moderate form of learning disability" />   <answer id="68" text="We will keep ASD checked" />   <answer id="70" text="" /> </answers>
Along with a memberid and questionid.
I was wondering how I can get this into a table CREATE TABLE [dbo].[Answers](
[PrimaryKeyID] [int] NOT NULL,
[MemberID] [int] NOT NULL,
[QuestionID] [int] NOT NULL,
[AnswerID] [int] NOT NULL,
[FreText] [varchar](255) COLLATE Latin1_General_CI_AS NULL
) ON [PRIMARY]What I would also like to do is if the text attribute is empty then put a NULL in the FreText field.I think I am looking for  Insert into MyTable (
Select
@MemID,
@QuesID,
'somexpathforanswer',
'somexpathfortext' -- if empty then NULL
From
@MyXML )  Any ideas - places to to look - thoughts AprreciatedKal
 

View 1 Replies View Related

INSERT INTO - SELECT With Pk In Table

Apr 11, 2008

Is it possible to use the INSERT INTO - SELECT syntax with a pk in the target table that has no auto increment?

The tables structure is:

CREATE TABLE objectlang (
objectlangID integer NOT NULL, <== PK
objectID integer NOT NULL,
langID integer NOT NULL,
somedata integer NOT NULL,
[[...more columns here...]]
)

The statement should look like:

INSERT INTO objectlang
SELECT [[??set pk here??]], o.objectID, l.langID, 1, [[...more data here...]]
FROMobject o, lang l
WHERE[[...conditions...]]

I thought of something like reading the current max value of objectlangID and adding a value,
but no idea where this value should come from.

I need this for more than one project in mssqlserver 2000/2005, postgresql and oracle.

tia

View 2 Replies View Related

Linked Server (Oracle) - No Select Possible

Mar 7, 2008

Hello,

I created a linked server to Oracle on SQL-Server 2005. I have stored the remote login username and password in the security settings (option "...Be made using this security context" in the Security tab of the Linked Server Properties.

The "Test connection" function works fine, but a select doesn't for every table the user owns. What we found out is: if the table consists only of columns defined as varchar2, the select works. As soon as the table contains only one column defined as number (without scale and precision), it doesn't work. The error displayed is:

The OLE DB provider "MSDAORA" for linked server "NEXUS_FVADM" supplied inconsistent metadata for a column. The column "WEBVORZUGSTYP" (compile-time ordinal 2) of object ""FVADM"."AKZ"" was reported to have a "DBTYPE" of 130 at compile time and 5 at run time.

The Column WEBVORZUGSTYP is defined as number.

Any ideas?

Regards,
Ralf

View 1 Replies View Related

Problem Using A Linked Server In An Insert Trigger

Aug 24, 2004

I'm writing an insert trigger in one SQL Server database that is supposed to insert another record into a linked SQL Server database. I have the linked server set up and have been using it for a few weeks in queries and stored procedure with no problem. Now that I'm trying to use it within a trigger and it just bombs.

I'm getting the following message in one of my logs and I don't know what it means... "Failed to obtain TransactionDispenserInterface: XACT_E_TMNOTAVAILABLE". I've googled around, but can't really find anything. Any help would be appreciated.

Thanks,
Bryan

View 1 Replies View Related

Linked Server Referred By Insert Trigger

Jul 23, 2005

Hei,We have 2 MS SQL SERVER 2000 installed on 2 different servers (2 separatedmachines).I am triing to connect them så that when one row is added to the table inthe database in main server - then the same row is added to the same tablein the second server database.I made the insert trigger on the table in the first server ( the secondserver is added as a linked server):-----------------------------------------------------------------------------------------create trigger ti_myTabe1 on myTable1 for insert asbegindeclare ........BEGINinsert into server2.myDatabase2.owner.myTable2(column1, column2, column3)SELECT column1, column2, column3FROM inserted insEND......end-----------------------------------------------------------------------------------------When I run the statement in "SQL Query Analyzer"on the first server:insert into Table1 values(va1,val2,val3)then error is coming:Server: Msg 7391, Level 16, State 1, Procedure ti_myTabe1 , Line 19The operation could not be performed because the OLE DB provider 'SQLOLEDB'was unable to begin a distributed transaction.[OLE/DB provider returned message: New transaction cannot enlist in thespecified transaction coordinator. ]OLE DB error trace [OLE/DB Provider 'SQLOLEDB'ITransactionJoin::JoinTransaction returned 0x8004d00a].The straing thing is: if I run the statement in "SQL Query Analyzer"on thefirst server:insert into server2.myDatabase2.owner.myTable2 values(va1,val2,val3)then it works!But not inside the trigger!!! - What I am doing wrong ?Any idea is greatly appeciated.

View 2 Replies View Related

Insert To A Linked Server Possible Via Service Broker?

Jul 14, 2006

I have configured a non-SQL linked server (via an OLE DB provider) and I wish to insert data into it via Service Broker but I am getting the following error in the SQL Server log:
The activated proc [dbo].[sp_ mytableServiceProgram] running on queue TestDB.dbo.mytableQueue output the following: 'Cannot promote the transaction to a distributed transaction because there is an active save point in this transaction.'

As you see below, my strored proc. is not issuing any 'save trans' statements, so why is it not allowing me to wrap my code in a transaction? How else can I use a transaction (in order to not lose anything from the queue) and yet still be able to insert to the linked server?


CREATE PROC sp_mytableServiceProgram
AS
SET NOCOUNT ON;

DECLARE
@XML XML,
@MessageBody VARBINARY(MAX),
@MessageTypeName nvarchar(256),
@Dialog UNIQUEIDENTIFIER;

-- This procedure continues to process messages in the queue until the
-- queue is empty.

WHILE (1 = 1)
BEGIN
BEGIN TRANSACTION;
--BEGIN DISTRIBUTED TRANSACTION; --Tried this but didn't help.

-- Receive the next available message
WAITFOR (
RECEIVE TOP(1) -- just handle one message at a time
@MessageTypeName = message_type_name,
@MessageBody = message_body,
@Dialog = conversation_handle
FROM mytableQueue
), TIMEOUT 2000 ;

-- If RECEIVE did not return a message, roll back the transaction
-- and break out of the while loop, exiting the procedure.
IF (@@ROWCOUNT = 0)
BEGIN
ROLLBACK TRANSACTION;
BREAK;
END ;

SET @XML = CAST(@MessageBody AS XML);

INSERT INTO LINKEDSERVER.dbname.user.mytable
SELECT tbl.rows.value('@doc_no', 'INT') AS doc_no,
tbl.rows.value('@queryid', 'NVARCHAR(50)') AS queryid,
tbl.rows.value('@ar_num', 'NVARCHAR(50)') AS ar_num,
tbl.rows.value('@status', 'NVARCHAR(20)') AS status,
tbl.rows.value('@creationtime', 'DATETIME') AS creationtime,
tbl.rows.value('@note', 'NVARCHAR(250)') AS note,
tbl.rows.value('@posted', 'NCHAR(1)') AS posted,
tbl.rows.value('@kms', 'INT') AS kms,
tbl.rows.value('@schresid', 'NVARCHAR(50)') AS schresid,
tbl.rows.value('@resolution_code', 'NCHAR(8)') AS resolution_code,
tbl.rows.value('@page_count', 'INT') AS page_count,
tbl.rows.value('@new_serial_number', 'NVARCHAR(20)') AS new_serial_number,
tbl.rows.value('@taskresolution', 'NVARCHAR(250)') AS taskresolution
FROM @XML.nodes('/inserted') tbl(rows);

-- If the INSERT did not insert any rows, rollback.
IF @@ROWCOUNT = 0
BEGIN
ROLLBACK TRANSACTION;
BREAK;
END
COMMIT TRANSACTION;
END
GO

View 8 Replies View Related

Unidata - SQL Linked Server Insert Statement

Dec 29, 2006

Hi -

I am using linked server to insert data to a table. When I do select, it does show me results but when I do insert, it does not work. My source/destination has exact same data types defined. Any idea?

insert into dbo.tb_PERSONNEL

select * from openquery(CADC1, 'SELECT PERSONNEL_1_NF.ID, PERSONNEL_1_NF.NAME, PERSONNEL_1_NF.PNUM, PERSONNEL_1_NF.PN

FROM PERSONNEL_1_NF')

I get:

Msg 8152, Level 16, State 14, Line 2

String or binary data would be truncated.

The statement has been terminated.

View 1 Replies View Related

SQL Server 2012 :: Select Statement That Take Upper Table And Select Lower Table

Jul 31, 2014

I need to write a select statement that take the upper table and select the lower table.

View 3 Replies View Related

How To Select && Insert Data In The Same Table

May 24, 2007

Hi
   I have a table called Version and its attributes are Version_ID, Project_ID , Hospital_ ID , Date_Created and comments. I want to select the data by Version_ID,Project_ID and  Hospital_ID and the selected data is inserted in the same table(Version) as new row .
Table: Version (Version_ID(Primary_key), Project_ID(Foreign_Key),Hospital_ID(Foreign_Key),Date_Created,Comments). 
Iam using Visual Web Developer Express and SQL Server 2005. Iam doing on asp.net 2.0.
Could anyone please send me the code asp.net 2.0 for the above problem.

View 6 Replies View Related







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