Error When Inserting To Aspnet_Roles Table

Jun 21, 2007

hi,

 I am using asp.net web admin tool to create users and the other personal details of the user are stored in a table called "Users". So in my Users table I have a field called "Id" which is of datatype UniqueIdentifier. The UserId generated in the aspnet_Membership table is also stored in my "Users" table's Id field. The problem is that an error is thrown when executing the statement

System.Web.Security.Roles.AddUserToRole(name, Role). The parameters name and role are getting values correctly. But as soon as this is executed a sql exception is thrown saying that  "The conflict of interleave for the equal operator cannot be solved to." 

 Am not able to solve this.Pls help me out.

Thanks in Advance.

 

 

View 3 Replies


ADVERTISEMENT

Error Inserting Image Into SQL Server2000 Table From Pocket PC Application Only When Using Stored Procedure In Table Adapter Wiz

Apr 24, 2008

My Pocket PC application exports signature as an image. Everything is fine when choose Use SQL statements in TableAdapter Configuration Wizard.


main.ds.MailsSignature.Clear();

main.ds.MailsSignature.AcceptChanges();


string[] signFiles = Directory.GetFiles(Settings.signDirectory);


foreach (string signFile in signFiles)

{


mailsSignatureRow = main.ds.MailsSignature.NewMailsSignatureRow();

mailsSignatureRow.Singnature = GetImageBytes(signFile); //return byte[] array of the image.

main.ds.MailsSignature.Rows.Add(mailsSignatureRow);

}


mailsSignatureTableAdapter.Update(main.ds.MailsSignature);

But now I am getting error "General Network Error. Check your network documentation" after specifying Use existing stored procedure in TableAdpater Configuration Wizard.


ALTER PROCEDURE dbo.Insert_MailSignature( @Singnature image )

AS

SET NOCOUNT OFF;

INSERT INTO MailsSignature (Singnature) VALUES (@Singnature);



SELECT Id, Singnature FROM MailsSignature WHERE (Id = SCOPE_IDENTITY())

For testing I created a desktop application and found that the same Code, same(Use existing stored procedure in TableAdpater Configuration Wizard) and same stored procedure is working fine in inserting image into the table.

Is there any limitation in CF?

Regards,
Professor Corrie.

View 3 Replies View Related

Error Inserting Into Table ""

Mar 25, 1999

We are running a application that uses SQL. No users use this database but the application. We have been getting an error stating that there was an error inserting into one of my tables. We have increased the LE Threshold to 10000 and have also increased my locks to 200000 but it still doesn't get rid of the problem. Any ideas as to why. I can't imagine that this application will hold that many locks but then again I'm not the developer. Any suggestions will help.

Ben

View 2 Replies View Related

Error While Inserting To Table

Mar 29, 2007

Hi all,
I made a C# function to insert new row to MS SQL Server 2005. However, I kept getting this error when I executed it:


Code:


Line 1: Incorrect syntax near '0'.
Unclosed quotation mark before the character string '','{ 0 }','Sun, Mar 25, 2007 04:33:00 PM')'.



here is the sql insert statement


Code:


insert into Temip_tmp_3(Managed_object, Alarm_type, Perceived_Severity, Probable_Cause, Domain, Additional_Text, Specific_Problems, Original_Event_Time ) values ('','EquipmentAlarm','Major','EquipmentMalfunction','Domain tsel_ns:.dom.radio_ericsson','"EXTERNAL ALARM RECEIVER FAULT *** ALARM 121 A2/IO_DEV BTAK1 042/0700H U 070325 1633 EXTERNAL ALARM RECEIVER FAULT AP APNAME NODE NODENAME 1 AP_BTAK1_C A AP_BTAK1_A APNODE FCODE B FAULT CODE 23 **SpecificProblem:121 , AdditionalInfo:@@"','{ 0 }','Sun, Mar 25, 2007 04:33:00 PM')



I believe there is not a single quotation mark unclosed in my query. And, what's so funny is when I tried to execute the query on SQL Server Enterprise Manager, it worked.
I don't know, maybe I missed something.
Can you guys please help me figure this out?

Thank you very much in advance.

Shinta

View 1 Replies View Related

Error Inserting Row In Table Where There Is Multiple Foreign Key.

Oct 26, 2007

Hi guys,
I have created 3 tables namely Static, Dynamic and Demo...
Static has colums FormID(uniqueidentifier, PrimaryKey) and FormName(Nvarchar(50)).
Dynamic has colums formID(uniqueidentifier,PrimaryKey) and FormName(Nvarchar(50)).
Demo has 4 colums namely ValueID(uniqueidentifier, Primary Key), formID(uniqueidentifier, foreign key), Name(nvarchar(50)), Value(nvarchar(50).

Now the formID coloum in Demo table i have set as foreign key to both the dynamic table as well as static table on the formID colum in both table.

Now first i insert a row in the dynamic table then take the uniqueidentifier which is generated automatically and try
to insert in the Demo table in formID colum as that colum is FK to dynamic and static but when i try to insert a row it show that its violating the FOREIGN KEY CONSTRAINT

the exact error is

Msg 547, Level 16, State 0, Line 1

The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Demo_Dynamic1". The conflict occurred in database "huzefaJTest", table "dbo.Dynamic", column 'formid'.

The statement has been terminated.

please if anyone know do reply.....

View 3 Replies View Related

Error While Inserting Time Id In Fact Table

Dec 31, 2007



Hi

My time dimension has date mm/dd/yy 00:00:00
where as the source has mm/dd/yy and some time not 00:00:00
I am sure the iserts in fact table are failing.
I do not want the time part to come anywhere in data mart.
what should i do in SSIS.

View 1 Replies View Related

SQL Server 2012 :: Inserting Record In Table - Trigger Error

Aug 6, 2014

I am inserting a record in XYZ table(DB1). Through trigger it will update ABC table(DB2).

I am getting error when doing above thing. What are the roles to be set to user to avoid above problem.

View 3 Replies View Related

Trigger Error When Inserting Stored Proc Output Into Temp Table.

Feb 18, 2008





I writing a unit test which has one stored proc calling data from another stored proc. Each time I run dbo.ut_wbTestxxxxReturns_EntityTest I get a severe uncatchable error...most common cause is a trigger error. I have checked and rechecked the columns in both of the temp tables created. Any ideas as to why the error is occurring?

--Table being called.


ALTER PROCEDURE dbo.wbGetxxxxxUserReturns

@nxxxxtyId smallint,

@sxxxxxxxxUser varchar(32),

@sxxxxName varchar(32)

AS

SET NOCOUNT ON




CREATE TABLE #Scorecard_Returns

(
NAME_COL varchar(64),
ACCT_ID int,

ACCT_NUMBER varchar(10),

ENTITY_ID smallint,

NAME varchar(100),

ID int,

NUM_ACCOUNT int,

A_OFFICER varchar(30),

I_OFFICER varchar(30),

B_CODE varchar(30),

I_OBJ varchar(03),

LAST_MONTH real,

LAST_3MONTHS real,

IS int

)




ALTER PROCEDURE dbo.ut_wbTestxxxxReturns_EntityTest



AS

SET NOCOUNT ON




CREATE TABLE #Scorecard_Returns

(
NAME_COL varchar(64),
ACCT_ID int,

ACCT_NUMBER varchar(10),

ENTITY_ID smallint,

NAME varchar(100),

ID int,

NUM_ACCOUNT int,

A_OFFICER varchar(30),

I_OFFICER varchar(30),

B_CODE varchar(30),

I_OBJ varchar(03),

LAST_MONTH real,

LAST_3MONTHS real,

IS int

)

INSERT #Scorecard_Returns(

NAME_COL ,

ACCT_ID

ACCT_NUMBER ,

ENTITY_ID,

NAME,

ID,

NUM_ACCOUNT,

A_OFFICER,

I_OFFICER,

B_CODE,

I_OBJ ,

LAST_MONTH

LAST_3MONTHS,

IS

)

EXEC ISI_WEB_DATA.dbo.wbGetxxxxxcardUserReturns

@nId = 1,

@sSUser = 'SELECTED USER',

@sUName = 'VALID USER'

View 4 Replies View Related

Error (8626) While Inserting Record Into Table With Text Field And Which Is The Base For Indexed View

Mar 14, 2006

I have a problem with inserting records into table when an indexed viewis based on it.Table has text field (without it there is no problem, but I need it).Here is a sample code:USE testGOCREATE TABLE dbo.aTable ([id] INT NOT NULL, [text] TEXT NOT NULL)GOCREATE VIEW dbo.aViewWITH SCHEMABINDING ASSELECT [id], CAST([text] AS VARCHAR(8000)) [text]FROM dbo.aTableGOCREATE TRIGGER dbo.aTrigger ON dbo.aView INSTEAD OF INSERTASBEGININSERT INTO aTableSELECT [id], [text]FROM insertedENDGODo the insert into aTable (also through aView).INSERT INTO dbo.aTable VALUES (1, 'a')INSERT INTO dbo.aView VALUES (2, 'b')Still do not have any problem. But when I need index on viewCREATE UNIQUE CLUSTERED INDEX [id] ON dbo.aView ([id])GOI get following error while inserting record into aTable:-- Server: Msg 8626, Level 16, State 1, Procedure aTrigger, Line 4-- Only text pointers are allowed in work tables, never text, ntext, orimage columns. The query processor produced a query plan that requireda text, ntext, or image column in a work table.Does anyone know what causes the error?

View 1 Replies View Related

Inserting Data Into Two Tables (Getting ID From Table 1 And Inserting Into Table 2)

Oct 10, 2007

I am trying to insert data into two different tables. I will insert into Table 2 based on an id I get from the Select Statement from Table1.
 Insert Table1(Title,Description,Link,Whatever)Values(@title,@description,@link,@Whatever)Select WhateverID from Table1 Where Description = @DescriptionInsert into Table2(CategoryID,WhateverID)Values(@CategoryID,@WhateverID)
 This statement is not working. What should I do? Should I use a stored procedure?? I am writing in C#. Can someone please help!!

View 3 Replies View Related

SQL Server VARCHAR(MAX) Column Returns Error While Inserting Records Into Table(ODBC Driver: SQL Native Client)

Aug 15, 2007

I created very simple table with 3 columns and one is varchar(max) datatype

When i insert records thru VC++ ADO code i am getting this error



Exception Description Multiple-step OLE DB operation generated errors. Check e
ach OLE DB status value, if available. No work was done. and Error Number:: -2147217887



ODBC Driver: SQL Native Client

SQL server 2005



Table

CREATE TABLE [dbo].[RAVI_TEMP](

[ID] [int] NULL,

[Name] [varchar](max) NULL,

[CITY] [varchar](50) NULL

)



VC++ code

#include "stdafx.h"
#include <string>
#include <strstream>
#include <iomanip>


int main(int argc, char* argv[])
{
try
{
HRESULT hr = CoInitialize(NULL);
_RecordsetPtr pExtRst = NULL;
_bstr_t bstrtDSN, bstrtSQL;
bstrtDSN = L"DSN=espinfo;UID=opsuser;PWD=opsuser;";
bstrtSQL = L"SELECT * FROM RAVI_TEMP";

_variant_t vartValueID,vartValueNAME,vartValueCITY;
_bstr_t bstrtValueID,bstrtValueNAME,bstrtValueCITY;

pExtRst.CreateInstance(__uuidof(Recordset));
hr = pExtRst->Open(bstrtSQL, bstrtDSN, adOpenDynamic, adLockOptimistic, adCmdText);

hr = pExtRst->AddNew();

bstrtValueID = L"1";
vartValueID = bstrtValueID.copy();

bstrtValueNAME = L"RAVIBABUBANDARU";
vartValueNAME = bstrtValueNAME.copy();

bstrtValueCITY = L"Santa Clara";
vartValueCITY = bstrtValueCITY.copy();

pExtRst->GetFields()->GetItem(L"ID")->Value = vartValueID;
pExtRst->GetFields()->GetItem(L"NAME")->Value = vartValueNAME;
pExtRst->GetFields()->GetItem(L"CITY")->Value = vartValueCITY;
pExtRst->Update();
pExtRst->Close();

}
catch(_com_error e)
{
printf("Exception Description %s and Error Number:: %d",(LPTSTR)e.Description(),e.Error());
return e.Error();
}
return 0;
CoUninitialize();
}


if i use regular SQL ODBC driver, no error but its truncating the data



Adv Thanks for your help

View 1 Replies View Related

I Have Created A Table Table With Name As Varchar And Id As Int. Now I Have Started Inserting The Rows Like, Insert Into Table Values ('arun',20).

Jan 31, 2008

I have created a table Table with name as Varchar and id as int. Now i have started inserting the rows like, insert into Table values ('arun',20).Yes i have inserted a row in the table. Now i have got the values " arun's ", 50.                 insert into Table values('arun's',20)  My sqlserver is giving me an error instead of inserting the row. How will you solve this problem? 
 

View 3 Replies View Related

SQL Server 2008 :: Inserting Data From Staging Table To Main Table

Feb 23, 2015

I am trying to insert bulk data into main table from staging table in sql server 2012. If any error comes, this total activity is rollbacked. I don't want that to happen. I want to know the records where ever the problem persists, and the rest has to be inserted.

View 2 Replies View Related

Inserting Distinct Data From One Table In Another Table, How?!?Really Urgent And Needing Help!!!

May 24, 2007

 Hi, I have a table in which I will insert several redundant data. Don't ask why, is Integration services, it only reads data and inserts it in a SQL table. THis way, I have a SQL table with several lines repeating them selves. What I want to do is create a procedure that reads the distinct data and inserts it in another table, but my problem is that I am not able to select data line by line on the original table to save it in local variables and insert it on the another table, I just can select the last line. I've tried a while cycle but no succeed. Here is my code: create proc insertLocalizationASdeclare @idAp int, @macAp varchar(20), @floorAp varchar(2), @building varchar(30), @department varchar(30)select @idAp = idAp from OLTPLocalization where idAp not in (select idAp from dimLocalization)select @macAp=macAp,@floorAp=floorAp,@building=building,@department=department from OLTPLocalizationif (@idAp <> null)beginInsert into dimLocalization VALUES(@idAp,@macAp,@floorAp,@building,@department)endGO This only inserts the last line in the "oltpLocalization" table. O the other hand, like this:create proc aaaaasdeclare @idAp as int, @macAp as varchar(50), @floorAp as int, @building as varchar(50), @department as varchar(50)while exists (select distinct(idAp) from OLTPLocalization)begin    select @idAp =idAp from OLTPLocalization  where idAp not in (select idAp from dimLocalization)    select @macAp = macAp from OLTPLocalization where idAp = @idAp    select @building = building from OLTPLocalization where idAp = @idAp    select @department = department from OLTPLocalization where idAP = @idApif (@idAp <> null)begin    insert into dimLocalization values(@idAp,@macAp,@floorAp,@building,@department)endendgo this retrieves every distinct idAp in each increment on the while statement. The interess of the while is really selecting each different line in the OLTPLocalization table. I did not find any foreach or for each statement, is there any way to select distinct line by line in a sql table and save each column result in variables, to then insert them in another table? I've also thought about web service, that reads the distinct data from the oltpLocalization into a dataset, and then inserts this data into the dimLocalization table. Is there anything I can do?Any guess?Really needing a hand here!Thanks a lot!

View 1 Replies View Related

Trigger On Table LeaveRegister And Inserting Rows In Audit Table

Oct 22, 2012

I write a insert trigger on my table LeaveRegister(1000 rows) and inserting rows in audit table, but when i inserting a row in LeaveRegister table. In audit table 1000 + 1 rows are inserting every time.

View 6 Replies View Related

Transact SQL :: Table Structure - Inserting Data From Other Temp Table

Aug 14, 2015

Below is my table structure. And I am inserting data from other temp table.

CREATE TABLE #revf (
[Cusip] [VARCHAR](50) NULL, [sponfID] [VARCHAR](max) NULL, GroupSeries [VARCHAR](max) NULL, [tran] [VARCHAR](max) NULL, [AddDate] [VARCHAR](max) NULL, [SetDate] [VARCHAR](max) NULL, [PoolNumber] [VARCHAR](max) NULL, [Aggregate] [VARCHAR](max) NULL, [Price] [VARCHAR](max) NULL, [NetAmount] [VARCHAR](max) NULL,

[Code] ....

Now in a next step I am deleting the records from #revf table. Please see the delete code below

DELETE
FROM #revf
WHERE fi_gnmaid IN (
SELECT DISTINCT r2.fi_gnmaid
FROM #revf r1, #revf r2

[Code] ...

I don't want to create this #rev table so that i can avoid the delete statement. But data should not affect. Can i rewrite the above as below:

SELECT [Cusip], [sponfID], GroupSeries, [tran], [AddDate], [SetDate], [PoolNumber], [Aggregate], [Price], [NetAmount], [Interest],
[Coupon], [TradeDate], [ReversalDate], [Description], [ImportDate], MAX([fi_gnmaid]) AS Fi_GNMAID, accounttype, [IgnoreFlag], [IgnoreReason], IncludeReversals, DatasetID, [DeloitteTaxComments], [ReconciliationID],

[Code] ....

If my above statement is wrong . Where i can improve here? And actually i am getting 4 rows difference.

View 5 Replies View Related

Transact SQL :: Inserting Records Into Table 2 From Table 1 To Avoid Duplicates

Nov 2, 2015

INSERT
INTO [Table2Distinct]        
([CLAIM_NUMBER]        
,[ACCIDENT_DATE]

[code]....

I used the above query and it still inserts all the duplicate records. What is wrong with my statement?

View 5 Replies View Related

SQL Server 2012 :: Inserting Row From A Table Into Another Table From SSIS

Sep 18, 2014

I have a 2010 SSIS package where I am reading csv files with different fields and formatted data, I have created separate packages for each file and I am formatting the data to fit the final destination tables data elements, I've been instructed to create 7 separate packages to read each file and the format the data from the 7 csv files, and insert into their table tbl1, tbl2, tbl3...etc then, I'm taking a execute sql task and wanting to insert the tbl1, tbl2, tbl3...etc into destination table that will be the final table for all reports and other uses.

1- should I create a ID?
2- these files will be read once a month
3- I want to append the data, not drop and recreate each run,
4- It's 2012 SQL and 2010 SSIS

Each csv file is in a different format, some have 15 columns, other have 8 I have to parse the data, in SP to align with the fields in the destination table.

5- Can I force RowID to be the next auto gen number from tbl1,for the start of insert for tbl2, then last row of tbl2 for insert of tbl3???

View 0 Replies View Related

Calculating Value From Two Separate Rows In The Same Table And Inserting As New Row In The Same Table

Jan 19, 2008

Code Block


Hi,

I'm working on a database for a financial client and part of what i need to do is calculate a value from two separate rows in the same table and insert the result in the same table as a new row. I have a way of doing so but i consider it to be extremely inelegant and i'm hoping there's a better way of doing it. A description of the existing database schema (which i have control over) will help in explaining the problem:

Table Name: metrics_ladder

id security_id metric_id value
1 3 80 125.45
2 3 81 548.45
3 3 82 145.14
4 3 83 123.32
6 4 80 453.75
7 4 81 234.23
8 4 82 675.42
.
.
.

Table Name: metric_details

id metric_id metric_type_id metric_name
1 80 2 Fiscal Enterprise Value Historic Year 1
2 81 2 Fiscal Enterprise Value Current Fiscal Year
3 82 2 Fiscal Enterprise value Forward Fiscal year 1
4 83 2 Fiscal Enterprise Value Forward Fiscal Year 2
5 101 3 Calendar Enterprise value Historic Year 1
6 102 3 Calendar Enterprise Value Current Fiscal Year
5 103 3 Calendar Enterprise value Forward Year 1
6 104 3 Calendar Enterprise Value Forward Year 2

Table Name: metric_type_details

id metric_type_id metric_type_name
1 1 Raw
2 2 Fiscal
3 3 Calendar
4 4 Calculated

The problem scenario is the following: Because a certain number of the securities have a fiscal year end that is different to the calendar end in addition to having fiscal data (such as fiscal enterprise value and fiscal earnings etc...) for each security i also need to store calendarised data. What this means is that if security with security_id = 3 has a fiscal year end of October then using rows with ids = 1, 2, 3 and 4 from the metrics_ladder table i need to calculate metrics with metric_id = 83, 84, 85 and 86 (as described in the metric_details table) and insert the following 4 new records into metrics_ladder:

id security_id metric_id value
1 3 101 <calculated value>
2 3 102 <calculated value>
3 3 103 <calculated value>
4 3 104 <calculated value>

Metric with metric_id = 101 (Calendar Enterprise value Historic Year 1) will be calculated by taking 10/12 of the value for metric_id 80 plus 2/12 of the value for metric_id 81.

Similarly, metric_id 102 will be equal to 10/12 of the value for metric_id 81 plus 2/12 of the value for metric_id 82,

metric_id 103 will be equal to 10/12 of the value for metric_id 82 plus 2/12 of the value for metric_id 83 and finally

metric_id 104 will be NULL (determined by business requirements as there is no data for forward year 3 to use).

As i could think of no better way of doing this (and hence the reason for this thread) I am currently achieving this by pivoting the relevant data from the metrics_ladder so that the required data for each security is in one row, storing the result in a new column then unpivoting again to store the result in the metrics_ladder table. So the above data in nmetrics_ladder becomes:

security_id 80 81 82 83 101 102
----------- -- -- -- -- -- --
3 125.45 548.45 145.14 123.32 <calculated value> <calculated value>
4 ...
.
.
.

which is then unpivoted.

The SQL that achieves this is more or less as follows:

*********
START SQL
*********

declare @calendar_averages table (security_id int, [101] decimal(38,19), [102] decimal(38,19), [103] decimal(38,19), [104] decimal(38,19),etc...)


-- Dummy year variable to make it easier to use MONTH() function
-- to convert 3 letter month to number. i.e. JAN -> 1, DEC -> 12 etc...
DECLARE @DUMMY_YEAR VARCHAR(4)
SET @DUMMY_YEAR = 1900;

with temp(security_id, metric_id, value)
as
(
select ml.security_id, ml.metric_id, ml.value
from metrics_ladder ml
where ml.metric_id in (80,81,82,83,84,85,86,87,88,etc...)
-- only consider securities with fiscal year end not equal to december
and ml.security_id in (select security_id from company_details where fiscal_year_end <> 'dec')
)
insert into @calendar_averages
select temppivot.security_id
-- Net Income
,(CONVERT(DECIMAL, MONTH(cd.fiscal_year_end + @DUMMY_YEAR))/12*[80])
+((12 - CONVERT(DECIMAL, MONTH(cd.fiscal_year_end + @DUMMY_YEAR)))/12*[81]) as [101]
,(CONVERT(DECIMAL, MONTH(cd.fiscal_year_end + @DUMMY_YEAR))/12*[81])
+((12 - CONVERT(DECIMAL, MONTH(cd.fiscal_year_end + @DUMMY_YEAR)))/12*[82]) as [102]
,(CONVERT(DECIMAL, MONTH(cd.fiscal_year_end + @DUMMY_YEAR))/12*[82])
+((12 - CONVERT(DECIMAL, MONTH(cd.fiscal_year_end + @DUMMY_YEAR)))/12*[83]) as [103]
,NULL as [104]
-- Share Holders Equity
,(CONVERT(DECIMAL, MONTH(cd.fiscal_year_end + @DUMMY_YEAR))/12*[84])
+((12 - CONVERT(DECIMAL, MONTH(cd.fiscal_year_end + @DUMMY_YEAR)))/12*[85]) as [105]
,(CONVERT(DECIMAL, MONTH(cd.fiscal_year_end + @DUMMY_YEAR))/12*[85])
+((12 - CONVERT(DECIMAL, MONTH(cd.fiscal_year_end + @DUMMY_YEAR)))/12*[86]) as [106]
,(CONVERT(DECIMAL, MONTH(cd.fiscal_year_end + @DUMMY_YEAR))/12*[86])
+((12 - CONVERT(DECIMAL, MONTH(cd.fiscal_year_end + @DUMMY_YEAR)))/12*[87]) as [107]
,NULL as [108]
-- Capex
-- Sales
-- Accounts payable
etc...
..
..
from temp
pivot
(
sum(value)
for metric_id in ([80],[81],[82],[83],[84],[85],[86],[87],[88],etc...)
) as temppivot
inner join company_details cd on temppivot.security_id = cd.security_id

*********
END SQL
*********

The result then needs to be unpivoted and stored in metrics_ladder.

And FINALLY, the question! Is there a more elegant way of achieving this??? I have complete control over the database schema so if creating mapping tables or anything along those lines would help it is possible. Also, is SQL not really suited for such operations and would it therefore be better done in C#/VB.NET.

Many thanks (if you've read this far!)

M.

View 6 Replies View Related

How To Create Table A By Inserting All Data From Table B?

Jan 16, 2005

Hi,

Anyone can help me?

How to create Table A by inserting all the data from Table B?

Cheers,
Daniel.

View 1 Replies View Related

Inserting Data Into A Table Referencing PK From Another Table

May 12, 2008

How do i insert data into multiple tables. Lets say i have 2 tables: Schedules and Event

Schedules data is entered into the Schedules Table first

then now i need to insert Event table's data by refrencing the (PK ID) from the schedules table.

How do i insert data into Event table referencing the (PK ID) from Schedules Table ?


Fields inside each of the tables can be found below:




Event Table
(PK,FK) ScheduleID
EventTitle
AccountManager
Presenter
EventStatus
Comment

Schedule Table
(PK) ID


AletrnateID
name
UserID
UserName
StartTime
EndTime
ReserveSource
Status
StatusRetry
NextStatusDateTime
StatusRemarks

View 2 Replies View Related

Transact SQL :: Inserting Into Table And Joining With Same Table

Jun 4, 2015

I am looking for an alternate logic for below-mentioned code where I am inserting into a table and having left join with the same table

insert TABLE1([ID],[Key],[Return])
select distinct a.[ID],cat1,cat2 from
(select ID,[Key] Cat1 ,[Return] cat2 from @temp as temp) a left join TABLE1 oon a.ID= o.ID
and a.Cat1 = o.[Key]
and a.cat2 = o.[return]
where [key] is null order by ID

View 2 Replies View Related

Inserting Into A SQL Error

Feb 25, 2006

hey guys I got an error when trying to insert an SQL statement.
basically it when I try to insert into a unique ID column I think
error is:
Compiler Error Message: BC30516: Overload resolution failed because no accessible 'New' accepts this number of arguments.Source Error:





Line 51: objCmd = New SQLCommand(strSQL1, SqlConn)
Line 52:
Line 53: objCmd.Parameters.Add(New SqlParameter("@CustomerID"))
Line 54: objCmd.Parameters("@CustomerID").Value = UserID
Line 55: objCmd.Parameters.Add(New SqlParameter("@CompanyID", _Source File: C:Prototypeofficial1html icketsystem.aspx    Line: 53
 

Dim strConnection as string = ConfigurationManager.ConnectionStrings("GeolinkSupportdb").connectionstring
Dim sqlConn = New SqlConnection(strConnection)
dim mu = Membership.GetUser()
dim UserID = mu.ProviderUserKey.ToString()

Sub Page_Load(sender as Object, e as EventArgs)

If Not IsPostBack() then
'1. Create a connection
Dim sqlConn = New SqlConnection(strConnection)
'2. Create the command object, passing in the SQL string
Const strSQL as String = "SELECT IssueID, IssueName FROM Support_Issue;"
sqlConn.Open()
Dim myCommand as New SqlCommand(strSQL, sqlConn)
'3. Create the DataReader

Dim objDR as SqlDataReader
objDR = myCommand.ExecuteReader(CommandBehavior.CloseConnection)

'Databind the DataReader to the listbox Web control
TicketIssue.DataSource = objDR
TicketIssue.DataTextField = "IssueName"
TicketIssue.DataValueField = "IssueID"
TicketIssue.DataBind()

'Add a new listitem to the beginning of the listitemcollection
TicketIssue.Items.Insert(0, new ListItem("-- Choose an Issue --"))
objDR.close()
sqlConn.Close()

'assign fullname from profile and company ID to the text fields.
FullName.Text = profile.firstName & " " & profile.lastName
Company.Text = profile.CompanyID
end if
End Sub
Sub Submit(sender as Object, e as EventArgs)
Dim rightNow as DateTime = DateTime.Now
Dim strSQL1 = "insert into Support_Ticket (CustomerID, CompanyID, Subject, Problem, Open_Date, IsClosed) Values (@CustomerID, @CompanyID, @Subject, @Problem, @OpenDate, @IsClosed);"
Dim objCmd As SqlCommand
objCmd = New SQLCommand(strSQL1, SqlConn)

objCmd.Parameters.Add(New SqlParameter("@CustomerID", _
SqlDbType.uniqueidentifier))
objCmd.Parameters("@CustomerID").Value = UserID
objCmd.Parameters.Add(New SqlParameter("@CompanyID", _
SqlDbType.uniqueidentifier))
objCmd.Parameters("@CompanyID").Value = profile.CompanyID
objCmd.Parameters.Add(New SqlParameter("@Subject", _
SqlDbType.varchar, 50))
objCmd.Parameters("@Subject").Value = Subject.Text
objCmd.Parameters.Add(New SqlParameter("@Problem", _
SqlDbType.ntext))
objCmd.Parameters("@Problem").Value = TicketInfo.Value
objCmd.Parameters.Add(New SqlParameter("@Open_Date", _
SqlDbType.DateTime))
objCmd.Parameters("@Open_Date").Value = rightNow.ToString("dd/MM/yyyy , HH:mm:ss")
objCmd.Connection.Open()
objCmd.Parameters.Add(New SqlParameter("@IsClosed", _
SqlDbType.bit))
objCmd.Parameters("@IsClosed").Value = 0
' Test whether the new row can be added and display the
' appropriate message box to the user.
Try
Catch ex As SqlException
objCmd.ExecuteNonQuery()
Message.InnerHtml = "<b>Record Added</b> to Database<br>"

If ex.Number = 2627 Then
Message.InnerHtml = "ERROR: A record already exists with " _
& "the same primary key"
Else

Message.InnerHtml = "ERROR: Could not add record, please " _
& "ensure the fields are correctly filled out"
Message.Style("color") = "red"

End If
End Try
objCmd.Connection.Close()
end sub
 
the database looks like this
TicketID             uniqueidentifier      CustomerID        uniqueidentifier       Subject               varchar(50)               Problem              ntext                          Open_Date        datetime                    IsClosed             bit                              Closed_Date      datetime                   DeptID               uniqueidentifier     CompanyID       varchar(50)            

View 2 Replies View Related

Error While Inserting!!!!

Apr 20, 2004

Hey folks,
I am trying to updat a table by inserting values from another table into the parent table. The SQL being used is:
"insert into "LogSchema"."_rt1182" select * from "LogSchema"."_rt557" where recordID not in (select * from "LogSchema"."_rt1182") ORDER BY TIMESTAMP"
I have used the above statement and was successful, but with these two particluar tables I am getting an error message" Wrong number of values to INSERT"
Please lemme know, what this means and how to correct this problem!
TIA

View 3 Replies View Related

Inserting Into More Than 1 Table

Jan 9, 2008

Hey all,
Quick question for ya.  If I wanted to insert 1 value into 1 table and another value into another table, how would I do that with closing connections and reopening and whatnot?  I am using Visual Web Dev and SQL server 2005 express.  I have been trying to mess around with it but I can't figure it out.  Here is the situation.
I want to insert a GroupName and GroupDescription that a user fills in in 2 text boxes named GroupNametxt and GroupDescriptiontxt.  This data will go into the "Group" table.
I then also want to Insert the data UserID (taken from the aspnet ID table), and GroupName from the Grouptxt.text into a GroupMembership table.
How would I do all this in 1 button click?  I know some basic TSQL but I don't know how to handle the opening and closing of connections and whatnot. 
Thanks,
Chris

View 2 Replies View Related

Inserting Into A Sql Table

Feb 15, 2008

VWD 2005 Express.  Visual Basic.  Sql Server 2005.
How may I insert a record into a table from code behind (I am doing this without any entries to a form).  The connection name is GoodNews_Extranet.  The table is Login.  The fields I want to write are UserId and dtTime.  Thanks for any help.  The insert command is:
INSERT INTO [Login] ([SystemUserId], [dtTime]) VALUES (@SystemUserId, @dtTime)
I will provide the @ parameters programmatically.  I just need to know the commands I should use in Visual Basic to actually execute the INSERT command.  Thanks for the help.

View 2 Replies View Related

Help Inserting XML Into MS SQL Table.

Jan 18, 2004

I've got a string value in C# that contains:

"<?xml version="1.0"?><?qbxml version="2.0"?><QBXML><QBXMLMsgsRq onError="stopOnError"><JournalEntryAddRq requestID="1"><JournalEntryAdd><TxnDate>2003-11-18</TxnDate><JournalDebitLine><AccountRef>
<FullName>1200</FullName>
</AccountRef>
<Amount>160.06</Amount>
<Memo>613663</Memo>
<ClassRef>
<FullName>Buffalo</FullName>
</ClassRef></JournalDebitLine><JournalCreditLine><AccountRef>
<FullName>5687</FullName>
</AccountRef>
<Amount>160.06</Amount>
<Memo>613663</Memo>
<ClassRef>
<FullName>Buffalo</FullName>
</ClassRef></JournalCreditLine><JournalDebitLine><AccountRef>
<FullName>1200</FullName>
</AccountRef>
<Amount>133.85</Amount>
<Memo>300931</Memo>
<ClassRef>
<FullName>Buffalo</FullName>
</ClassRef></JournalDebitLine><JournalCreditLine><AccountRef>
<FullName>5687</FullName>
</AccountRef>
<Amount>133.85</Amount>
<Memo>300931</Memo>
<ClassRef>
<FullName>Buffalo</FullName>
</ClassRef></JournalCreditLine></Journ
alEntryAdd></JournalEntryAddRq></QBXMLMsgsRq></QBXML>"


I'm passing that string to an insert stored procedure that hits a varchar field (varchar 5000).

problem is, nothing is showing up in the database.
there are no errors, but the field I have shows nothign in it after the insert.

if i run a test and set my string to "this is a test" it goes into the table from the SP_insert no problem.

So i'm figuring, somehow the formatting of the XML string in C# isn't kosher with MS SQL.

the above text is the exact string value from VS.NET command output (? mystring).

I'm really in need of help here guys. I'm trying to log this XML result into a log table for reference if there are ever any problems I can look in the log table @ the xml.

but i can't get it to insert.

Help!

View 3 Replies View Related

Inserting Into Table

Aug 24, 2004

I have the 3 tables below. I want to be able to add more than one item to a quote. I thought I had designed the tables so that I could have more than one item in a quote....? I've tried to do this:

insert into has_quote(date_of_quote,service_desk_contact,category,cat_ref)
values('09/12/2002', 'me',2,'C92') where quote_id = '1'

but it doesn't work. Am I totally missing something here?



Code:

CREATE TABLE Item (
cat_ref VARCHAR(5)PRIMARY KEY,
descrip VARCHAR(50),
date_added SMALLDATETIME,
date_last_pricecheck SMALLDATETIME,
cat_type VARCHAR(20),
contract VARCHAR(10),
cost_price SMALLMONEY,
installation_charge SMALLMONEY,
commercial_markup SMALLMONEY,
supplier_name VARCHAR(20),
supplier_phone VARCHAR(20),
notes VARCHAR(500))


CREATE TABLE has_quote (
quote_id INT IDENTITY (1,1) PRIMARY KEY,
date_of_quote SMALLDATETIME,
service_desk_contact VARCHAR(20),
category INTEGER,
cat_ref VARCHAR(5)FOREIGN KEY
REFERENCES Item(cat_ref),
first_name VARCHAR(10),
surname VARCHAR(10),
customer_phone VARCHAR(20),
FOREIGN KEY (first_name, surname, customer_phone)
REFERENCES Customer(first_name, surname, customer_phone)
ON DELETE CASCADE
ON UPDATE CASCADE)

CREATE TABLE Customer (
first_name VARCHAR(10),
surname VARCHAR(10),
customer_phone VARCHAR(20),
contract VARCHAR(10),
location VARCHAR(20),
email VARCHAR(50),
cust_id INT IDENTITY (1,1),
PRIMARY KEY (first_name, surname, customer_phone))

View 14 Replies View Related

Inserting To A Table From A CTE?

May 23, 2008

Hello,

I have created a CTE to combine some data. I have also created a temporary table that I need this data that the CTE returns to be inserted to and then everything that is in this temp table needs to be inserted to an existing table in my database. I don't know how to select the values from the CTE into the temp table?

Create Table #TempLabTestConfigImport
(labtestkey varchar(10) null,valuecode varchar(32)null,
value_description varchar(255) null,value_type varchar(32) null,
units varchar(32) null, table_name varchar(30) null,
field_name varchar(30) null)

Insert Into #TempLabTestConfigImport
(labtestkey,valuecode,value_description,value_type,units,table_name,field_name)


Does my select go here??? I tried select * and it doesn't like that syntax...

With labtestcheck (labtestcode)
as
(
select a.labtestcode
from EMR_temp_labtest_configupdate a
Where Not Exists (Select * From lab_test_add_conf b where b.labtest_key = a.labtestcode)
)

select row_number() over (partition by t.labtestcode order by b.valuecode) as count,
t.labtestcode,b.zsegcode,b.valuecode,b.valuedesc,b.valuetype,b.units,b.tablename,b.fieldname
from EMR_temp_labtest_configupdate a
inner join emr_zseg_code_descriptions b on a.zsegcode = b.zsegcode
inner join labtestcheck t on t.labtestcode = a.labtestcode

View 8 Replies View Related

Inserting Into A Table

Nov 30, 2005

Hi, i am new to SQL. I have this problem here, i need a little help.

How do i insert data into a table only when there is no such record in the existing table? I have this:

INSERT INTO ptable ( symptoms, weight, solutions ) VALUES ( '"+str+"', "+percent+", '"+str3+"' );

View 6 Replies View Related

Inserting A Value From Another Table

Nov 17, 2006

Hi,

I am using MSSQL and I want to do something like this:

insert into
people
values
(newid(), *value from names table* )


but I can't work out how to select the value from one table and insert it into another table in a single query. Using a subquery or combining with a select has not worked.

Is this a job for a datacursor or is there a simpler way?

Thanks.

View 6 Replies View Related

Inserting From One Table To Another

Nov 9, 2007

I am trying to insert data into a table from another where not exists. This will be a table that writes from one table to another if there has been an update from the original table. Both tables have the same field and table names. This is what I have so far:

USE cana_01imis

DECLARE @Gen_Tables.Code AS VARCHAR(60)
DECLARE @Gen_Tables.DESCRIPTION AS VARCHAR(255)

DECLARE cur CURSOR FAST_FORWARD FOR
SELECT Gen_Tables.Code, Gen_Tables.DESCRIPTION
FROM dbo.cana_01imis.gen_tables
WHERE NOT IN (SELECT Gen_Tables.Code FROM Gen_Tables)

FETCH NEXT FROM cur INTO @Gen_Tables.Code, @Gen_Tables.DESCRIPTION
WHILE @@FETCH_STATUS = 0
BEGIN
--SELECT Gen_Tables.Code, Gen_Tables.DESCRIPTION from gen_tables

DECLARE @DNNGen_Tables AS VARCHAR(60)
SET @DNNGen_Tables.code = @Gen_Tables.Code

DECLARE @DNNGen_Tables.Code DESCRIPTION AS VARCHAR(255)
SET @DNNGen_Tables.Code DESCRIPTION = @Gen_Tables.description

-- then your insert statement goes here
INSERT INTO cana_01dnn.gen_tables
VALUES (Gen_Tables.Code,Gen_Tables.DESCRIPTION)

FETCH NEXT FROM cur INTO @Gen_Tables.Code,@Gen_Tables.Code
END

CLOSE cur
DEALLOCATE cur

View 20 Replies View Related

Inserting Roles Error

Apr 25, 2006

Msg 515, Level 16, State 2, Procedure aspnet_Roles_CreateRole, Line 37
Cannot insert the value NULL into column 'RoleId', table 'PORTAL.MDF.dbo.aspnet_Roles'; column does not allow nulls. INSERT fails.
The statement has been terminated.
this MS sql server 2005 using the aspnetdb.mdf.
The RoleID is an primary key and supposed to be autopopulating itself everytime there is an new insertion correct? so what is the problem?

View 3 Replies View Related







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