Thursday, March 8, 2012
Columns inster into problem
This is the first time I'm trying to use columns by themselves instead
of using individual values.
And I'm getting an error.
Here is my sql
INSERT INTO PS_CUST_CONTACT (SETID, CUST_ID, CNTCT_SEQ_NUM, EFF_STATUS,
ADDRESS_SEQ_NUM, LAST_MAINT_OPRID, DATE_LAST_MAINT)
SELECT (SETID, CUST_ID, CNTCT_SEQ_NUM, EFF_STATUS, ADDRESS_SEQ_NUM,
LAST_MAINT_OPRID, DATE_LAST_MAINT) FROM PS_CONTACT_CUST WHERE CUST_ID
NOT IN(SELECT CUST_ID FROM PS_CUST_CONTACT)
& the Error is
Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near ','.
I've matched all the columns. Second table have extra columns & I
didn't included them because then the columns will not match.
Also I only want to insert the values which are not currently present
in table 1.
Thanks in advance for your help.
Try...
INSERT INTO PS_CUST_CONTACT
SELECT SETID, CUST_ID, CNTCT_SEQ_NUM, EFF_STATUS, ADDRESS_SEQ_NUM,
LAST_MAINT_OPRID, DATE_LAST_MAINT FROM PS_CONTACT_CUST WHERE CUST_ID
NOT IN(SELECT CUST_ID FROM PS_CUST_CONTACT)
Almost correct but you didn't need the brackets around the select columns,
and you don't need column names in the insert.
Peter
"You can always count on Americans to do the right thing - after they've
tried everything else."
Winston Churchill
"aspnetpal" wrote:
> Hi Every1,
> This is the first time I'm trying to use columns by themselves instead
> of using individual values.
> And I'm getting an error.
> Here is my sql
> INSERT INTO PS_CUST_CONTACT (SETID, CUST_ID, CNTCT_SEQ_NUM, EFF_STATUS,
> ADDRESS_SEQ_NUM, LAST_MAINT_OPRID, DATE_LAST_MAINT)
> SELECT (SETID, CUST_ID, CNTCT_SEQ_NUM, EFF_STATUS, ADDRESS_SEQ_NUM,
> LAST_MAINT_OPRID, DATE_LAST_MAINT) FROM PS_CONTACT_CUST WHERE CUST_ID
> NOT IN(SELECT CUST_ID FROM PS_CUST_CONTACT)
> & the Error is
> Server: Msg 170, Level 15, State 1, Line 2
> Line 2: Incorrect syntax near ','.
> I've matched all the columns. Second table have extra columns & I
> didn't included them because then the columns will not match.
> Also I only want to insert the values which are not currently present
> in table 1.
> Thanks in advance for your help.
>
|||Hello Peter, thanks for your suggestion.
After removing the brackets it worked just fine.
Thanks
Columns inster into problem
This is the first time I'm trying to use columns by themselves instead
of using individual values.
And I'm getting an error.
Here is my sql
INSERT INTO PS_CUST_CONTACT (SETID, CUST_ID, CNTCT_SEQ_NUM, EFF_STATUS,
ADDRESS_SEQ_NUM, LAST_MAINT_OPRID, DATE_LAST_MAINT)
SELECT (SETID, CUST_ID, CNTCT_SEQ_NUM, EFF_STATUS, ADDRESS_SEQ_NUM,
LAST_MAINT_OPRID, DATE_LAST_MAINT) FROM PS_CONTACT_CUST WHERE CUST_ID
NOT IN(SELECT CUST_ID FROM PS_CUST_CONTACT)
& the Error is
Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near ','.
I've matched all the columns. Second table have extra columns & I
didn't included them because then the columns will not match.
Also I only want to insert the values which are not currently present
in table 1.
Thanks in advance for your help.Try...
INSERT INTO PS_CUST_CONTACT
SELECT SETID, CUST_ID, CNTCT_SEQ_NUM, EFF_STATUS, ADDRESS_SEQ_NUM,
LAST_MAINT_OPRID, DATE_LAST_MAINT FROM PS_CONTACT_CUST WHERE CUST_ID
NOT IN(SELECT CUST_ID FROM PS_CUST_CONTACT)
Almost correct but you didn't need the brackets around the select columns,
and you don't need column names in the insert.
Peter
"You can always count on Americans to do the right thing - after they've
tried everything else."
Winston Churchill
"aspnetpal" wrote:
> Hi Every1,
> This is the first time I'm trying to use columns by themselves instead
> of using individual values.
> And I'm getting an error.
> Here is my sql
> INSERT INTO PS_CUST_CONTACT (SETID, CUST_ID, CNTCT_SEQ_NUM, EFF_STATUS,
> ADDRESS_SEQ_NUM, LAST_MAINT_OPRID, DATE_LAST_MAINT)
> SELECT (SETID, CUST_ID, CNTCT_SEQ_NUM, EFF_STATUS, ADDRESS_SEQ_NUM,
> LAST_MAINT_OPRID, DATE_LAST_MAINT) FROM PS_CONTACT_CUST WHERE CUST_ID
> NOT IN(SELECT CUST_ID FROM PS_CUST_CONTACT)
> & the Error is
> Server: Msg 170, Level 15, State 1, Line 2
> Line 2: Incorrect syntax near ','.
> I've matched all the columns. Second table have extra columns & I
> didn't included them because then the columns will not match.
> Also I only want to insert the values which are not currently present
> in table 1.
> Thanks in advance for your help.
>|||Hello Peter, thanks for your suggestion.
After removing the brackets it worked just fine.
Thanks
Columns inster into problem
This is the first time I'm trying to use columns by themselves instead
of using individual values.
And I'm getting an error.
Here is my sql
INSERT INTO PS_CUST_CONTACT (SETID, CUST_ID, CNTCT_SEQ_NUM, EFF_STATUS,
ADDRESS_SEQ_NUM, LAST_MAINT_OPRID, DATE_LAST_MAINT)
SELECT (SETID, CUST_ID, CNTCT_SEQ_NUM, EFF_STATUS, ADDRESS_SEQ_NUM,
LAST_MAINT_OPRID, DATE_LAST_MAINT) FROM PS_CONTACT_CUST WHERE CUST_ID
NOT IN(SELECT CUST_ID FROM PS_CUST_CONTACT)
& the Error is
Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near ','.
I've matched all the columns. Second table have extra columns & I
didn't included them because then the columns will not match.
Also I only want to insert the values which are not currently present
in table 1.
Thanks in advance for your help.Try...
INSERT INTO PS_CUST_CONTACT
SELECT SETID, CUST_ID, CNTCT_SEQ_NUM, EFF_STATUS, ADDRESS_SEQ_NUM,
LAST_MAINT_OPRID, DATE_LAST_MAINT FROM PS_CONTACT_CUST WHERE CUST_ID
NOT IN(SELECT CUST_ID FROM PS_CUST_CONTACT)
Almost correct but you didn't need the brackets around the select columns,
and you don't need column names in the insert.
Peter
"You can always count on Americans to do the right thing - after they've
tried everything else."
Winston Churchill
"aspnetpal" wrote:
> Hi Every1,
> This is the first time I'm trying to use columns by themselves instead
> of using individual values.
> And I'm getting an error.
> Here is my sql
> INSERT INTO PS_CUST_CONTACT (SETID, CUST_ID, CNTCT_SEQ_NUM, EFF_STATUS,
> ADDRESS_SEQ_NUM, LAST_MAINT_OPRID, DATE_LAST_MAINT)
> SELECT (SETID, CUST_ID, CNTCT_SEQ_NUM, EFF_STATUS, ADDRESS_SEQ_NUM,
> LAST_MAINT_OPRID, DATE_LAST_MAINT) FROM PS_CONTACT_CUST WHERE CUST_ID
> NOT IN(SELECT CUST_ID FROM PS_CUST_CONTACT)
> & the Error is
> Server: Msg 170, Level 15, State 1, Line 2
> Line 2: Incorrect syntax near ','.
> I've matched all the columns. Second table have extra columns & I
> didn't included them because then the columns will not match.
> Also I only want to insert the values which are not currently present
> in table 1.
> Thanks in advance for your help.
>|||Hello Peter, thanks for your suggestion.
After removing the brackets it worked just fine.
Thanks
Wednesday, March 7, 2012
Column width
'Cannot specify a column width on data type smalldatetime.'
I'm using SQL Server & I've check the data type in the db & it's same as smalldatetime.
Any suggestions would be highly appreciated.
Thanks
<Error
Column or parameter #8: Cannot specify a column width on data type smalldatetime.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Column or parameter #8: Cannot specify a column width on data type smalldatetime.
Source Error:
Line 344: Try
Line 345: myConnection.Open()
Line 346: dgdSearch.DataSource = myCommand.ExecuteReader()
Line 347: dgdSearch.DataBind()
Line 348: Finally
Source File: c:\inetpub\wwwroot\Demo Equip Log\Search Equipment.aspx.vb Line: 346
Stack Trace:
[SqlException: Column or parameter #8: Cannot specify a column width on data type smalldatetime.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +742
System.Data.SqlClient.SqlCommand.ExecuteReader() +41
Demo_Equip_Log.Search_Equipment.BindGrid() in c:\inetpub\wwwroot\Demo Equip Log\Search Equipment.aspx.vb:346
Demo_Equip_Log.Search_Equipment.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\Demo Equip Log\Search Equipment.aspx.vb:195
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750Show the code you are using to set up the parameter. I presume the message means EXACTLY what it says. Are you trying to set the length of the smalldatetime parameter? You cannot.|||Hi Doug, thanks for your response & Yep!. I've released that after I posted on the forum.
This is the first time I'm using Stored Procedure.
I've removed it & now I'm not getting that error.
However, I'm getting a different error ... I highly appreciate your suggestion.
Thanks
<Error>
Cannot compute Count for a data source that does not implement ICollection.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Cannot compute Count for a data source that does not implement ICollection.
Source Error:
Line 345: myConnection.Open()
Line 346: dgdSearch.DataSource = myCommand.ExecuteReader()
Line 347: dgdSearch.DataBind()
Line 348: Finally
Line 349: myConnection.Close()
Source File: c:\inetpub\wwwroot\Demo Equip Log\Search Equipment.aspx.vb Line: 347
Stack Trace:
[HttpException (0x80004005): Cannot compute Count for a data source that does not implement ICollection.]
System.Web.UI.WebControls.PagedDataSource.get_DataSourceCount() +152
System.Web.UI.WebControls.PagedDataSource.get_Count() +187
System.Web.UI.WebControls.PagedDataSource.GetEnumerator() +268
System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean useDataSource) +712
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +49
System.Web.UI.WebControls.BaseDataList.DataBind() +23
Demo_Equip_Log.Search_Equipment.BindGrid() in c:\inetpub\wwwroot\Demo Equip Log\Search Equipment.aspx.vb:347
Demo_Equip_Log.Search_Equipment.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\Demo Equip Log\Search Equipment.aspx.vb:195
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750