Best Way To Handle Populating Column?
Jul 2, 2014
Have two tables: table1 and table2
Working with two main columns in both tables: D_ID and C_ID.
Table1 has D_ID populated and C_ID is not.
Table2 is a cross reference table with both D_ID and C_ID values within.
Looking for best way to populate C_ID in table1 from C_ID values in table2 where table1.D_ID = table2.D_ID.
There are too many values to do a case in stored procedure which has been my best practice. Trying to up my game with using SSIS 2012 as well.
View 1 Replies
ADVERTISEMENT
Aug 23, 2006
I have a table with two columns:
OwnerName Owner
John;Smith
Mary;Smith
OwnerName is populated. Owner is not.
I want to populate the Owner column with the OwnerName in alphabetical order. I have already created a function to do this.
Select fnGetOwner(OwnerName) from OwnerTable. This returns:
Smith, John
Smith, Mary
How do I populate the blank Owner field beside the OwnerName in the OwnerTable?
View 3 Replies
View Related
Apr 25, 2008
Hello, all.
I am new to SQL querying and I came across an issue while experimenting.
Say, I have two tables like the following, a Users table at the top, and a Roles table at the bottom (drawing the issue as I'm not fluent in English to explain):
(Users table)
UserId | RoleId | RoleOldId
-------+--------+----------
1......|x.......|11........
2......|y.......|22........
3......|z.......|22........
(Roles table)
RoleId | RoleOldId | RoleName
-------+-----------+-------------
10.....|11.........|Anonymous....
20.....|22.........|Superuser....
30.....|33.........|Administrator
The Roles table was changed to include a new column Roles.RoleId and the old column is named Roles.RoleOldId. Same is done for Users table.
Assume these are not foreign and/or primary keys. How can I fill Users.RoleId with new Roles.RoleIds, matching RoleOldIds at each tables? The resulting (x, y, z) set of Users table will be (10, 20, 20).
Thank you for your time.
View 3 Replies
View Related
Apr 29, 2015
I want to populate a datetime column on the fly within a stored procedure. Below is the query that I currently have that does same but slows down query performance.
CREATE TABLE #TaxVal
(
ID INT
, PaidDate DATETIME
, CustID INT
, CompID INT
[code]...
Which is the best way to write this query for better performance?
View 2 Replies
View Related
Dec 5, 2005
Sorry I'm pretty new to SQL so I don't know if this is a simple question. I have a table, and I am trying to add a column to the table and populate this column using what would be called an 'IF' function in Excel.
Basically 'column A' has numbers in it. I want SQL to look at 'column A' and if the first 5 digits of the number in 'column A' are 00001, then put 'description A' into new column 'column B'. If the first 5 digits of the number in 'column A' are 00002, then put 'description B' into 'column A' etc.
Any ideas?
View 2 Replies
View Related
Aug 29, 2013
I have a table of id numbers that I wish to mask. My thought was to create a new column for this new id number and populate it with a unique sequential value - start at 1 and go as high as needed. My problem is that I cannot recall how to populate that column with a number...
View 4 Replies
View Related
Mar 28, 2006
I'm having some issues getting OLE DB Data Sources to work w stored procs in SSIS. Here's the situation.
I have an OLE DB Data Source set up to call a stored proc w no parameters. The stored procedure loops through a set of databases and inserts data from each database into a results table. I'm attempting to return the results table to SSIS, but the Available External Columns are not populating. However, previewing the query in SSIS does show results. The insert in to the results table is done by a call to sp_executesql.
I've tried setting the results table up as a temp table, table variable, and static table. I have NOCOUNT set ON and am only returning one recordset. I've seen the other threads in here about similar problems, but none of their solutions seem to work for me.
Any help would be much appreciated....
View 2 Replies
View Related
Nov 19, 2007
Hi,
I have a table Called Actcodes and has 2 columns Name and Description...
And i want to insert the data from this table called PlanDBF to ActCode..
and this my insert statement...
INSERT INTO Statements..AscActCodes
(
Name,
Description
)
SELECT
ACT_CODE1,
ACT_DESC1
ACT_CODE2,
ACT_DESC2,
ACT_CODE3,
ACT_DESC3,
ACT_CODE4,
ACT_DESC4,
ACT_CODE5,
ACT_DESC5,
ACT_CODE6,
ACT_DESC6,
ACT_CODE7,
ACT_DESC7,
ACT_CODE8,
ACT_DESC8,
ACT_CODE9,
ACT_DESC9,
ACT_CODE10,
ACT_DESC10,
ACT_CODE11,
ACT_DESC11,
ACT_CODE12,
ACT_DESC12,
ACT_CODE13,
ACT_DESC13,
ACT_CODE14,
ACT_DESC14,
ACT_CODE15,
ACT_DESC15,
ACT_CODE16,
ACT_DESC16,
ACT_CODE17,
ACT_DESC17,
ACT_CODE18,
ACT_DESC18,
ACT_CODE19,
ACT_DESC19,
ACT_CODE20,
ACT_DESC20
FROM
PlanDBF
each actcode and its description is gonna be different and so i am not sure how to do this 1 - many column insert.
Any help will be appreciated.
Regards
Karen
View 7 Replies
View Related
Jan 26, 2006
I have multiple columns in a table that I only want to convert if they are not null or of the proper type. I don't really want to redirect the whole row if one of the conversions fails, rather I would just not want to do the cast or set it to another value. In this scenario is it better to use a custom script or multiple tasks? The multiple tasks seems like a lot of overhead for processing the same data. Just curious how others handle this scenario as it seems as though it has come up quite often on our current project? Thanks for the assistance.
-Krusty
PS: Is it possible to embed evaluation statements along with conversion statements in a task expression? e.g. (len(trim([Column1])) > 0) substring([Column1], 1, 4)
View 1 Replies
View Related
Sep 18, 2015
We have a table to 100M rows and up until now we were fine with an non clustered index a varchar(4000) because we never went above 900 bytes (yes it is a bad design).We have the need to support international character sets now so the column was updated to nvarchar(4000) and now we have data past the 900 byte limit.
The data is long, seems useless but is needed by the business and they need to be able to search "where bigcolumn like 'test%'". With an index, even with a huge amount of data, it was 'fast'. Now of course without an index it is unusable. The wildcard is always at the end of the search. I made a full text index on the column and basic queries such as: select * from ourtable where contains(bigcolumn, 'AReallyLongStringofTextHere') works fine unless there is a space in the data. We loose thousands of returned rows because of spaces in the data.
I have tried select * from ourtable where contains(bigcolumn, '"AReallyLongStringofTextHere that includes spaces"') but not all of the data is returned. I get 112 rows with the contains statement. The table scanning statement of "select * from ourtable where bigcolumn like 'AReallyLongStringofTextHere that includes spaces%' returns 1939 rows.I understand that a full text index is breaking the long string up since it contains spaces. Is there a way to retain the entire string as 1 index entry or is there a way to fix my query to return all of the rows?
View 9 Replies
View Related
Mar 27, 2008
Hi!
I recently was confronted with a problem where a piece of text that was included in many NTEXT column values in a table needed to be replaced with another piece of text. You can't issue normal REPLACE statements against NTEXT columns, so this seemed to be a bit of a challenge €” issuing a REPLACE() against a TEXT or NTEXT column in SQL Server yields error
I tried following
UPDATE CaseTypeDefs SET definition = replace(LTRIM(RTRIM(definition)), '<![CDATA[sp_YOTAssetAdditionalOffences 0, ArgParamHearingsId, ArgParamLanguage, ArgParamReferralId]]>', '<![CDATA[sp_YOTAssetAdditionalOffences 0, ArgParamHearingsId, ArgParamLanguage]]>')
But this is producing following error
Server: Msg 8116, Level 16, State 1, Line 1Argument data type ntext is invalid for argument 1 of replace function.
For Example: I want to replace string <![CDATA[sp_YOTAssetAdditionalOffences 0, ArgParamHearingsId, ArgParamLanguage]]> with <![CDATA[sp_YOTAssetAdditionalOffences 0, ArgParamHearingsId, ArgParamLanguage, ArgParamReferralId]]> in NTEXT column values in a table.
Need help, how to do it?.
Thanks In Advance
Devloper
Anil Kumar Dwivedi
View 4 Replies
View Related
Dec 3, 2007
Hi
I'm using service broker and keep getting errors in the log even though everythig is working as expected
SQL Server 2005
Two databases
Two end points - 1 in each database
Two stored procedures:
SP1 is activated when a message enters the sending queue. it insert a new row in a table
SP2 is activated when a response is sent from the receiving queue. it cleans up the sending queue.
I have a table with an update trigger
In that trigger, if the updted row meets a certain condition a dialogue is created and a message is sent to the sending queue.
I know that SP1 and SP2 are behaving properly because i get the expected result.
Sp1 is inserteding the expected data in the table
SP2 is cleaning up the sending queue.
In the Sql Server log however i'm getting errors on both of the stored procs.
error #1
The activated proc <SP 1 Name> running on queue Applications.dbo.ffreceiverQueue output the following: 'The conversation handle is missing. Specify a conversation handle.'
error #2
The activated proc <SP 2 Name> running on queue ADAPT_APP.dbo.ffsenderQueue output the following: 'The conversation handle is missing. Specify a conversation handle.'
I would appreceiate anybody's help into why i'm getting this. have i set up the stored procs in correctly?
i can provide code of the stored procs if that helps.
thanks.
View 10 Replies
View Related
Jan 18, 2008
We have implemented our service broker architecture using conversation handle reuse per MS/Remus's recommendations. We have all of the sudden started receiving the conversation handle not found errors in the sql log every hour or so (which makes perfect sense considering the dialog timer is set for 1 hour). My question is...is this expected behavior when you have employed conversation recycling? Should you expect to see these messages pop up every hour, but the logic in the queuing proc says to retry after deleting from your conversation handle table so the messages is enqueued as expected?
Second question...i think i know why we were not receiving these errors before and wanted to confirm this theory as well. In the queuing proc I was not initializing the variable @Counter to 0 so when it came down to the retry logic it could not add 1 to null so was never entering that part of the code...I am guessing with this set up it would actually output the error to the application calling the queueing proc and NOT into the SQL error logs...is this a correct assumption?
I have attached an example of one of the queuing procs below:
Code Block
DECLARE @conversationHandle UNIQUEIDENTIFIER,
@err int,
@counter int,
@DialogTimeOut int,
@Message nvarchar(max),
@SendType int,
@ConversationID uniqueidentifier
select @Counter = 0 -- THIS PART VERY IMPORTANT LOL :)
select @DialogTimeOut = Value
from dbo.tConfiguration with (nolock)
where keyvalue = 'ConversationEndpoints' and subvalue = 'DeleteAfterSec'
WHILE (1=1)
BEGIN
-- Lookup the current SPIDs handle
SELECT @conversationHandle = [handle] FROM tConversationSPID with (nolock)
WHERE spid = @@SPID and messagetype = 'TestQueueMsg';
IF @conversationHandle IS NULL
BEGIN
BEGIN DIALOG CONVERSATION @conversationHandle
FROM SERVICE [InitiatorQueue_SER]
TO SERVICE 'ReceiveTestQueue_SER'
ON CONTRACT [TestQueueMsg_CON]
WITH ENCRYPTION = OFF;
BEGIN CONVERSATION TIMER ( @conversationHandle )
TIMEOUT = @DialogTimeOut
-- insert the conversation in the association table
INSERT INTO tConversationSPID
([spid], MessageType,[handle])
VALUES
(@@SPID, 'TestQueueMsg', @conversationHandle);
SEND ON CONVERSATION @conversationHandle
MESSAGE TYPE [TestQueueMsg] (@Message)
END
ELSE IF @conversationHandle IS NOT NULL
BEGIN
SEND ON CONVERSATION @conversationHandle
MESSAGE TYPE [TestQueueMsg] (@Message)
END
SELECT @err = @@ERROR;
-- if succeeded, exit the loop now
IF (@err = 0)
BREAK;
SELECT @counter = @counter + 1;
IF @counter > 10
BEGIN
-- Refer to http://msdn2.microsoft.com/en-us/library/ms164086.aspx for severity levels
EXEC spLogMessageQueue 20002, 8, 'Failed to SEND on a conversation for more than 10 times. Error %i.'
BREAK;
END
-- We tried on the said conversation, but failed
-- remove the record from the association table, then
-- let the loop try again
DELETE FROM tConversationSPID
WHERE [spid] = @@SPID;
SELECT @conversationHandle = NULL;
END;
View 2 Replies
View Related
Mar 28, 2008
I'm trying to populate the variable "STATUS" with the BEFORE value from TABLE1 to insert into TABLE2, but not sure how to do that. Attached is a stripped down code I'm working on. Sorry, I'm new at this...// some variable stuff protected ErrorText ErrorText1;protected System.Web.UI.WebControls.DropDownList DISP_CD;public System.Web.UI.HtmlControls.HtmlInputText DISP_DOC;protected System.Web.UI.HtmlControls.HtmlInputText DISP_DATE;protected System.Web.UI.WebControls.DataList DataTagList;protected System.Web.UI.WebControls.Button BtnUpd;public string STATUS = string.Empty; <---- Help me.// some update stuffprivate void UpdateTable(){ using(DatabaseConnection conn = new DatabaseConnection()) { try { conn.OpenConnection(devSettings.junk); for (int i = 0; i < DataTagList.Items.Count; i++) { HtmlInputText textTag = (HtmlInputText)DataTagList.Items[i].FindControl("TagList"); if (textTag.Value.Trim() != string.Empty) { GetOldStatus(conn, textTag.Value.Trim()); <---- Help me. UpdateTable1(conn, textTag.Value.Trim()); UpdateTable2(conn, textTag.Value.Trim()); } } } catch ( Exception ex ) { conn.Rollback(); throw ex; } }}// some sql table stuffprivate string GetOldStatus(DatabaseConnection conn, string tag){ StringBuilder sqlStr = new StringBuilder(); sqlStr.Append(" SELECT "); sqlStr.Append(" STATUS AS STATUS"); <---- Help me. sqlStr.Append(" FROM "); sqlStr.Append(" TABLE1 "); sqlStr.AppendFormat(" WHERE TAG in '{0}'", Functions.DBFormatUpper(tag)); conn.Update(sqlStr.ToString()); return sqlStr.ToString();}private string UpdateTable1(DatabaseConnection conn, string tag){ StringBuilder sqlStr = new StringBuilder(); sqlStr.Append(" UPDATE TABLE1 "); sqlStr.AppendFormat(" SET DISP_DOC = '{0}',",Functions.DBFormatUpper(this.DISP_DOC.Value)); sqlStr.AppendFormat(" DISP_DATE = to_date('{0}', 'mm/dd/yyyy'),", DISP_DATE.Value); sqlStr.AppendFormat(" STATUS = '{0}',", Functions.DBFormatUpper(DISP_CD.SelectedValue)); sqlStr.Append(" UPDT_DATE = sysdate "); sqlStr.AppendFormat(" WHERE TAG in '{0}'", Functions.DBFormatUpper(tag)); sqlStr.Append(" AND STATUS in ('1','2','3')"); conn.Update(sqlStr.ToString()); return sqlStr.ToString();}private string UpdateTable2(DatabaseConnection conn, string tag){ StringBuilder sqlStr = new StringBuilder(); sqlStr.Append(" INSERT INTO TABLE2 ("); sqlStr.Append(" TAG"); sqlStr.Append(" ,DATE"); sqlStr.Append(" ,FIELD1"); sqlStr.Append(" ,FIELD2"); sqlStr.Append(" ,BEFORE"); <---- Help me. sqlStr.Append(" ,AFTER"); sqlStr.Append(" ,USER"); sqlStr.Append(" )"); sqlStr.Append(" VALUES ("); sqlStr.AppendFormat(" '{0}'", Functions.DBFormatUpper(tag)); sqlStr.Append(" ,sysdate "); sqlStr.Append(" ,'JUNK1'"); sqlStr.Append(" ,'JUNK2' "); sqlStr.AppendFormat(" ,'{0}'", Functions.DBFormatUpper(this.STATUS)); <---- Help me. sqlStr.AppendFormat(" ,'{0}'", Functions.DBFormatUpper(DISP_CD.SelectedValue)); sqlStr.AppendFormat(" ,'{0}'", Functions.DBFormatUpper(devState.UserId)); sqlStr.Append(" )"); conn.Update(sqlStr.ToString()); return sqlStr.ToString();}
View 1 Replies
View Related
Mar 23, 2006
I've got the following code and it's not really what I want. With the below code I can select in a dropdownlist a value and in the other dropdownlist the correspondending value will be selected. But when I select a value the second dropdownlist won't be filled with all the data in the database. It is filled only with the correspondending value and not with the rest of the value. When someone changes his mind and want to select a value in the dropdownlist it can't be done. Any ideas??Default.aspx:<body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="Botanische Naam: "> </asp:Label> <asp:DropDownList ID="DDL1" AutoPostBack="True" runat="server" OnSelectedIndexChanged="ChangeBotanicName" DataSourceID="SqlDataSource1" DataTextField="Botanische_Naam" DataValueField="Botanische_Naam"> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:BonsaiDataBaseConnectionString %>" SelectCommand="SELECT [Botanische Naam] AS Botanische_Naam FROM [BonsaiSoorten]"> </asp:SqlDataSource> <asp:sqldatasource id="SqlDataSource2" runat="server" connectionstring="<%$ ConnectionStrings:BonsaiDataBaseConnectionString%>" selectcommand="SELECT [Nederlandse Naam] AS Nederlandse_Naam FROM [BonsaiSoorten]WHERE [Botanische Naam] = @Title1"> <selectparameters> <asp:controlparameter name="Title1" controlid="DDL1" propertyname="SelectedValue" /> </selectparameters> </asp:sqldatasource> <asp:Label ID="Label2" runat="server">Nederlandse Naam:</asp:Label> <asp:DropDownList ID="DDL2" AutoPostBack="True" runat="server" OnSelectedIndexChanged="ChangeDutchName" DataSourceID="SqlDataSource3" DataTextField="Nederlandse_Naam" DataValueField="Nederlandse_Naam"> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:BonsaiDataBaseConnectionString %>" SelectCommand="SELECT [Nederlandse Naam] AS Nederlandse_Naam FROM [BonsaiSoorten]"> </asp:SqlDataSource> <asp:sqldatasource id="SqlDataSource4" runat="server" connectionstring="<%$ ConnectionStrings:BonsaiDataBaseConnectionString%>" selectcommand="SELECT [Botanische Naam] AS Botanische_Naam FROM [BonsaiSoorten]WHERE [Nederlandse Naam] = @Title2"> <selectparameters> <asp:controlparameter name="Title2" controlid="DDL2" propertyname="SelectedValue" /> </selectparameters> </asp:sqldatasource> </div> </form></body>Default.aspx.vb:Partial Class _Default Inherits System.Web.UI.Page Sub ChangeBotanicName(ByVal Sender As Object, ByVal e As System.EventArgs) DDL2.DataSourceID = "SqlDataSource2" End Sub Sub ChangeDutchName(ByVal Sender As Object, ByVal e As System.EventArgs) DDL1.DataSourceID = "SqlDataSource4" End SubEnd Class
P.S. I posted this before but can't find it anymore so here it is again
View 3 Replies
View Related
May 19, 2004
I have a table with a list of products,once I enter the data into the table and start using it on my web site as a drop down list,the list is sorted as an alphabetical list,is there are way to have a single drop down list but still be able to group the those products,in order words force them not to get sorted aphabetically.
Thanks
View 11 Replies
View Related
May 11, 2007
Hi, I have two tables:
1. RubricReportDetail with columns LocalPerf, Age
2. SppIndicator with columns Pct, Age
How can I populate the values of LocalPerf with Pct by matching
RubricReportDetail.Age = SppIndicator.Age ??
Please help me. Thanks in advance.
View 15 Replies
View Related
Aug 16, 2007
Hi Guys!!
I have a DataSet (which requires 2 parameters), and for some reason even though it works in Query Analyzer and on the Data Tab of VS2003 it will not work when I choose to Preview it. Can anybody shed some light on this behaviour?
If you need to see the dataSet I can post it up!
Thanks!
View 2 Replies
View Related
Apr 17, 2007
I am running a program that populates tables on my local database by querying another database.
View 2 Replies
View Related
Oct 3, 2007
Hi All,
I have a startdate (01/11/2007) and a enddate (01/11/2008). I need to add dates into a table for everyday between these dates. Can anyone help?
View 1 Replies
View Related
Apr 22, 2008
I have a page that is part of a 5 page wizard. The wizard gathers data for a claim filter. The second page is laid out with four labels at the top
Filter Name: <filterName> -- filterName_LFilter Description: <filterDescription> -- filterDescription_LFilter Data Source: <filterDataSource> -- filterDataSource_LFilter Purpose: <filterPurpose> -- filterPurpose_L
--I have written an sp to populate these four label.Text values. I want to populate them on page load.
Two questions. How do I get four output values out of the sp? Is there a better way to do this than an sp?
SET QUOTED_IDENTIFIER ON GOSET ANSI_NULLS ON GO
-- =============================================-- Author: <Author,,Name>-- ALTER date: <ALTER Date,,>-- Description: <Description,,>-- =============================================ALTER PROCEDURE [dbo].[a_spNewFilter_Step1_Summary] -- Add the parameters for the stored procedure here @filterID int ,
@filtername varchar(100) OUTPUT, @filterdescription varchar(250) OUTPUT, @filterOwnerID int OUTPUT, @filterDataSourceID INT OUTPUT, @filterPurposeID int OUTPUT
ASBEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements.SET NOCOUNT ON;
--DECLARE @FilterID int
--SET @filterID = 14
SELECT filterIsComplete, filterCreateDate, filterStep1Complete, filterName, filterDescription, das.AuditorFirstName + ' ' + das.AuditorLastName as FilterOwner, dfds.filterDataSource, dfp.filterPurposeFROM a_factSamplingFilter_2 fsfINNER JOIN dbo.a_dimFilterDataSource dfdsON dfds.filterDataSourceID = fsf.filterDataSourceIDINNER JOIN dbo.a_dimAuditStaff dasON das.AuditorID = fsf.filterOwnerIDINNER JOIN dbo.a_dimfilterPurpose dfpON dfp.filterPurposeID = fsf.filterPurposeIDWHERE filterID = @filterIDGROUP BY filterIsComplete, filterCreateDate, filterStep1Complete, filterName, filterDescription, das.AuditorFirstName, das.AuditorLastName, dfds.filterDataSource, dfp.filterPurpose
END
GOSET QUOTED_IDENTIFIER OFF GOSET ANSI_NULLS ON GO
----
protected void Page_Load(object sender, EventArgs e) {
int filterID = int.Parse(Request.QueryString["filterID"]); /// grab the filterID from the URL query string
string connectionString = WebConfigurationManager.ConnectionStrings["DDT"].ConnectionString; SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand("a_spNewFilter_Step1_Summary", con); // get the values from filter setup step1 cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@FilterID", SqlDbType.Int)); // using the filterID created in step1 cmd.Parameters["@FilterID"].Value = filterID;
cmd.Parameters.Add(new SqlParameter("@FilterName", SqlDbType.VarChar, 100)); cmd.Parameters["@FilterName"].Direction = FilterName_TB.Text;
cmd.Parameters.Add(new SqlParameter("@FilterDescription", SqlDbType.VarChar, 255)); cmd.Parameters["@FilterDescription"].Direction = ParameterDirection.Output;
cmd.Parameters.Add(new SqlParameter("@FilterOwner", SqlDbType.VarChar,50)); cmd.Parameters["@FilterOwner"].Direction = ParameterDirection.Output;
cmd.Parameters.Add(new SqlParameter("@FilterDataSource", SqlDbType.VarChar,50)); cmd.Parameters["@FilterDataSource"].Direction = ParameterDirection.Output;
cmd.Parameters.Add(new SqlParameter("@FilterPurpose", SqlDbType.VarChar,100)); cmd.Parameters["@FilterPurpose"].Direction = ParameterDirection.Output;
con.Open();
try { cmd.ExecuteNonQuery(); } finally { con.Close(); }
///get name, description, owner, datasource, purpose
}
View 1 Replies
View Related
Jun 8, 2006
I am trying to populate an array from a sqlreader. I am getting the error "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index". Can anyone help? I have my code below.
Try sql = "...." cmd = New SqlCommand(sql, conn) SqlReader = cmd.ExecuteReader 'Get the data from SQL Server Dim Counter As Integer = 0 Do While SqlReader.Read() Counter += 1 PageArray(Counter) = SqlReader("WebPageID") Loop Catch ex As Exception lblMessage.Text = ex.Message End Try
View 5 Replies
View Related
Dec 3, 2001
Following is an example of a query which I use in a SP.
<BR><BR>
What I would really like to do is set both variables with one query. Can I get both data elements with one query, or do I have to run 2 queries to set 2 variables? This query is going to run over 2 servers and would like to save the extra trip.
<BR><BR>
set @int_MCID = (select top 1 iPID from customers inner join tblPersonnel on MtgConsultant = iPid where phone1 = @str_Phone and Position = 'Consultant')
<BR><BR>
set @int_LocID = (select top 1 iLocID from customers inner join tblPersonnel on MtgConsultant = iPid where phone1 = @str_Phone and Position = 'Consultant')
<BR><BR>
Select @int_LocID, @int_MCID
<BR><BR>
View 2 Replies
View Related
Apr 27, 2005
Hi
I am quite new to the complexities of MS SQL and have a problem, I would like to resolve. I have 2 tables with a unique identifier in both and want to populate a new table with information from both, but the second table I would like to populate just some fields that have a DOB eg
Table 1:
uniqueId
Name
Address
Table2:
uniqueId
Type
Setting
example of content for Table 2:
uniqueId Type Setting
123 DOB 03/04/74
234 TFN 12345678
567 POA Mr Smith
So the new table needs to be populated with a ll of info in table 1 and has a new field called DOB so only the clients with a DOB should populate this field, if the client in Table 1 has a TFN reference, this record should be added to the new table but no value needs to be entered eg
123 Chris Smith 1 high street 03/04/74
234 Jon brown 2 high terrace <Null>
Cheers
pommoz
View 1 Replies
View Related
Aug 29, 2004
I have a customer who is running a script that generates a custom report. IT is not populating as it should and is returning zeros for everything.
I have tested the the script in the office and it is populating as intended. I have run a debug on the script and it is executing the correct SQL commands. The debug results for the customer and for the one tested in the office are identical. For some reason, the script is not writing to file but is looking at the correct data. I suspect that it is an environment issue most likely on the SQL level.
Could this be an issue with character set? How can I check their character set and language preferences? I understand they are set during installation.
They are using the same collation as us.
What else can I check as I am running low on ideas.
I advised the client to create a new DB and restore over the top. The script was then tested and it was found to be working fine. As it was given an inappropriate name (ie test), I advised to create a new DB with a production name and restore over the top again. We have since returned back to where we started as the report is generating only zeros.
H E L P !
View 1 Replies
View Related
Jan 18, 2005
Hi
Need to populate data from SQL Server in a pdf file which is basically a government form.
Data should be fetched from the SQL server database and needs to be displayed in a pdf file.
Advice me on how to implement this.
Suggest me if there is any other idea for implementing the same.
Thanks in advance
View 1 Replies
View Related
Jan 19, 2005
Hi Everyone....
Crazy one here....
I need to populate a table with all the times that
are available in a 24 hour period, down to the 5 minute
interval.
So the table should look like....
id ds (datetime stamp)
--- --------------------------
0 1/1/2005 00:00:00
1 1/1/2005 00:05:00
2 1/1/2005 00:10:00
3 1/1/2005 00:15:00
.........
xx 1/1/2005 23:55:00
Please advise on a way to accomplish this in a script....
thanks
tony
View 14 Replies
View Related
Jul 13, 2007
I have a project that entails the following:
There are two separate SQL Server databases involved that reside on two different servers. One of the depts within our building wants to have building permit data imported from Permit Database on Server "A" to their own database on Server "B".
I dont think this will be an overly complicated process. There are only a few fields they want populated (5 or 6 tops). This will have to be ran every
weeknight via some sort of scheduled task in Windows or SQL.
I was just interested in seeing if anyone has had prior experience working on data transfer like this. I would like to know what would be the best and most efficient way to approach this.
Thanks in advance.
View 9 Replies
View Related
Aug 19, 2014
The stored procedure accepts a TVP table as a parameter. Will something like this work?
BEGIN
;with tree(Id) as
(
SELECT 1
UNION ALL
SELECT 2
)
EXECUTE [dbo].[Get_FooByIds] @tvpId = tree
END
View 5 Replies
View Related
May 14, 2008
Hi all,
I have a table that looks something like this: -
county fname sport
------ ----- -----
surrey tara squash
surrey tara hockey
surrey tara tennis
kent tom tennis
kent tom football
kent tom rugby
I want to read through the sport table and create a distinct list of sports which can be used to create a new table that would look like: -
County fname squash hockey tennis football rugby
------ ----- ------ ------ ------ -------- -----
surrey tara YES YES YES
kent tom YES YES YES
I am using the following code: -
DECLARE @sql NVARCHAR(MAX)
SELECT @sql = 'create table ey_report_temp (county nvarchar(100),fname nvarchar(100), ' +
STUFF((SELECT DISTINCT ',[' + sport + '] nvarchar(100) '
FROM ey_report FOR XML PATH('')), 1, 1, '') + ')'
SELECT @sql
exec sp_executesql @sql
SELECT * from ey_report_temp
--------------------------------------------
DECLARE @county nvarchar(max)
DECLARE @fname nvarchar(max)
DECLARE @sport nvarchar(max)
DECLARE merge_cursor CURSOR FAST_FORWARD
FOR SELECT county, fname, sport from ey_report
OPEN merge_cursor
FETCH NEXT FROM merge_cursor INTO @county, @fname, @sport
WHILE @@FETCH_STATUS = 0
BEGIN
select @sql = N'
update ey_report_temp
set ' + @sport + ' = ''YES''
where county = ''' + @county + '''
and fname = ''' + @fname + ''''
print @sql
exec sp_executesql @sql
if @@ROWCOUNT = 0
begin
select @sql = N'
insert into ey_report_temp (
county, fname, ' + @sport + '
) values ( ' + @county + ', ' + @fname + ', ' + @sport + ')'
exec sp_executesql @sql
end
FETCH NEXT FROM merge_cursor INTO @county, @fname, @sport
END
CLOSE merge_cursor
DEALLOCATE merge_cursor
select * from ey_report_temp
drop table ey_report_temp
This creates the new table fine however, when it trys to poulate I get the following EM, can anybody help? thanks in anticipation
(1 row(s) affected)
(0 row(s) affected)
update ey_report_temp
set squash = 'YES'
where county = 'surrey'
and fname = 'tara'
(0 row(s) affected)
Msg 128, Level 15, State 1, Line 4
The name "surrey" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
update ey_report_temp
set hockey = 'YES'
where county = 'surrey'
and fname = 'tara'
(0 row(s) affected)
Msg 128, Level 15, State 1, Line 4
The name "surrey" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
update ey_report_temp
set tennis = 'YES'
where county = 'surrey'
and fname = 'tara'
(0 row(s) affected)
Msg 128, Level 15, State 1, Line 4
The name "surrey" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
update ey_report_temp
set tennis = 'YES'
where county = 'kent'
and fname = 'tom'
(0 row(s) affected)
Msg 128, Level 15, State 1, Line 4
The name "kent" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
update ey_report_temp
set football = 'YES'
where county = 'kent'
and fname = 'tom'
(0 row(s) affected)
Msg 128, Level 15, State 1, Line 4
The name "kent" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
update ey_report_temp
set rugby = 'YES'
where county = 'kent'
and fname = 'tom'
(0 row(s) affected)
Msg 128, Level 15, State 1, Line 4
The name "kent" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
(0 row(s) affected)
View 7 Replies
View Related
Nov 28, 2007
Hi. I have a report which has several datasources which require a table to be populated before they read from it.
i.e. The first thing that needs to happen whenever the report is run, is a call to a stored procedure which populates the table the report datasources are based off of. The SP takes several minutes to complete and MUST complete before any of the datasources fetch their data.
How can this be achieved?
I can not find anything in the Visual Studio Report Designer which allows to me to instruct Datasource B to not execute before Datasource A has completed (or any other way to call a data population SP, before the data reader SP's execute).
Thanks.
View 2 Replies
View Related
Jul 9, 2006
I'm trying to do a table lookup in t-sql and runing into problems. I have two tables, City and County..
Table City:
CityID CountyID CountyName
1 3 NULL
2 2 NULL
3 1 NULL
Table County:
CountyID CountyName
1 Los Angeles
2 Contra Costs
I want to populate the NULL "CountyName" field in table City with the values from table County but I can't make it work! Any help appreciated.
Barkingdog
View 1 Replies
View Related
Feb 7, 2008
Hello,
Just when I thought I was starting to understand SSRS just a little and then I encounter a strange (maybe not too strange) of an issue.
I have a DataSet which runs a stored procedure and it requires 10 parameters. When I run it in the dataset portion itself it runs fine however, it will not work when I choose to Preview it. I refreshed my dataset and even rebooted my machine. Can anybody shed some light on this?
Thanks
View 6 Replies
View Related