T-SQL (SS2K8) :: CTE Populating TVP Parameter

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


ADVERTISEMENT

T-SQL (SS2K8) :: Populating Data For Every Day Of The Week?

May 21, 2015

I have a date table(A) for every day of the year from 1990-2016 including the week number.There is another table(B) that has a number, date and week number.

I would like to join these 2 tables together, in order to populate the number from table B on every day of the week (of the week number in table B).

What makes it a little more complex is that the dates in table B not always correspond with the week number in the same row. Adding to the problem are some conditions:

- Every day of the week should have a number, and it should never be 0.

- If the 1st date of all rows in table B with the corresponding week number is not the monday of the week (but for example wednesday) it should start with this number on monday.

- Thousands of rows are in table B and for some of them the date corresponds with the week and for some of them they don't

- The rows can be grouped together using the week number.

Take the following example of table B:

B:
ID Date Number WeekNo
1 21-5-2015 25 21
2 23-5-2015 30 21

In this example the dates correspond with the weeknumber, because the 21st and the 23rd of may are week 21. By joining this with the date table (A), by using for example cross apply, I would hope to get the following result;

Date Number WeekNo
18-5 25 21
19-5 25 21
20-5 25 21
21-5 25 21
22-5 25 21
23-5 30 21
24-5 30 21

The same should work if the same example had the week number 22 in every row.

Take the following example of table B:

B:
ID Date Number WeekNo
1 21-5-2015 25 22
2 23-5-2015 30 22

In this example the dates do not correspond with the weeknumber, because the 21st and the 23rd of may are week 21 and not 22. By joining this with the date table (A), I would hope to get the following result;

Date Number WeekNo
25-5 30 22
26-5 30 22
27-5 30 22
28-5 30 22
29-5 30 22
30-5 30 22
31-5 30 22

Because the last result (ordered by date) of the week number 22 is 30, the whole week shows 30 on every day.

View 2 Replies View Related

T-SQL (SS2K8) :: Populating Data By Date Intervals

Mar 6, 2015

Table Name: EmployeeDetails
Columns: EMpID - Date - WorkedHours

For each day I get details of number of hours worked by each employee in this table.

Now my HR wants a report with such columns

empid - Week - Month - Qtr

So, week will have Sum of hours worked by employee in that week
Month will have Sum of hours worked by employee in that Month
Qtr will have Sum of hours worked by employee in that Qtr

View 6 Replies View Related

T-SQL (SS2K8) :: Populating Tables With Entries From Windows Folders?

May 18, 2015

I have 14 Windows folders containing a mix of Word and PDF documents. Each folder contains up to 500,000 files and these documents are the source for a document management system.

I need to create an audit table which can take the file names and date modified for every document in each folder but I want to avoid having to do a DOS command like dir *.* > filenames.txt then importing as a text file 14 times. Is there a way of automating this in T-SQL?

Each Windows folder is named by year e.g. 2002Docs, 2003Docs, 2004Docs etc.

Documents within the folders are named like this - 20020401_doc1.doc, 20020401_doc2, 20020401_doc678.pdf etc.

View 9 Replies View Related

Report Parameter Populating Another Report Parameter

Feb 16, 2007

OK, I'm pretty sure that the answer to my questions is "no", but the boss is pushing, and I thought I'd double check.

I want the selection of one report parameter to decide what shows up for another report parameter. Specifically in my case it has to do with dates. I have narrowed the results down to monthly dates, meaning that the starting dates always start with mm/1/yyyy and the ending dates are always mm/31/yyyy (for a 31 day month).

The boss wants the ending dates to always be >= the month of the starting dates. So, if the user choose 1/1/2007 for starting, the minimum ending date would be 1/31/2007, etc.. Since the parameters are loaded at report initiation, and SSRS isn't really event driven, I didn't think this was possible. I just wanted to make sure before I tell the boss that it's not. Please advise.

View 2 Replies View Related

T-SQL (SS2K8) :: Default INT Parameter In SP?

Jul 7, 2014

in a StoredProc I want depending on whether a parameter is passed formulate the Where clause accordingly.

If parameter IS NOT NULL
THEN take all Rows
Else take the row with the ID (INTEGER)

How do I formulate the where clause?

View 3 Replies View Related

T-SQL (SS2K8) :: Stored Procedure With Parameter Option

Aug 29, 2014

I know ran across this some time ago when researching some other topic, but I would like to add an option to our stored procedures (which have multiple parameters) so a user could do something like:

EXEC dbo.usp_MyStoredProcedure - EXEC dbo.usp_MyStoredProcedure -?

The result would just list the parameters in the stored procedure and the options available for each parameter/what the parameter was use for.

Here is an example of one stored procedure in use:

CREATE PROCEDURE [dbo].[usp_MyStoredProcedure]
( @BCP INT = 0---- 0 [Default]: No BCP Import, 1: Insert TempBCP Data
, @Debug INT = 0---- 0 [Default]: Run process, 1: Create temp tables, run queries
, @StartDate smalldatetime = '1/1/1900' ---- Enter StartDate; [Default]: otherwise use Max of Invoice date
, @Date INT = 0 ---- 0 [Default]: Use std process (get last Saturday date from @StartDate), 1: Use @StartDate as is
)
WITH EXECUTE AS 'ADBAccount'
AS
BEGIN
....
END

View 2 Replies View Related

T-SQL (SS2K8) :: Stored Procedure With OUTPUT Parameter

Oct 15, 2014

Note: @procName,@strAccount,@intHospital,@patType are passed to this procedure from another procedure
Note: The @procname procedure also takes the above parameters and @outDupCheck as output parameter

DECLARE @sqlStr NVARCHAR(500)
DECLARE @ParmDefinition NVARCHAR(500)
DECLARE @parmINAccount VARCHAR(30),@parmINHospId int , @ParmINpatType varchar(1)
DECLARE @parmRET1 int
SET @parmINAccount = @strAccount
SET @parmINHospId = @intHospital
SET @ParmINpatType = @patType

SET @sqlStr = N'Exec ' + @procName + ' @strAccount,@intHospital,@patType, @outDupCheck OUTPUT'

SET @ParmDefinition=N'@strAccount varchar(50),@intHospital int,@patType varchar(1), @outDupCheck int OUTPUT';
EXECUTE sp_executesql @sqlStr, @ParmDefinition, @strAccount = @parmINAccount, @intHospital=@parmINHospId,@patType=@ParmINpatType,@outDupCheck = @parmRET1

SELECT @parmRET1

--The parameter @parmRET1 returns NULL instead of 1 .
The @procName returns value 1 correctly if I run it separately ( outside of the dynamic sql)

Not sure what is wrong here...

View 2 Replies View Related

T-SQL (SS2K8) :: SSRS Report Parameter To Get Date

Mar 16, 2015

I've a SSRS monthly sales report with the sales details for current year and last year. I've 4 paramaters in the report. StartDate1, EndDate1, StartDate2 (hidden), EndDate2 (hidden).

For

StartDate1 - Beginning of Last month -
DateAdd(DateInterval.Month, -1, DateSerial(Year(Date.Now), Month(Date.Now), 1)) (Will give me Feb 1 2015)

EndDate1 - End of Last month -
DateAdd(DateInterval.Minute, -1, DateSerial(Year(Date.Now), Month(Date.Now), 1)) (Will give me Feb 28 2015)

StartDate2 - Need to get startdate as Feb 1 2014

EndDate2 - Need to get enddate as Feb 28 2014

View 2 Replies View Related

T-SQL (SS2K8) :: Finding Rows From CSV Column With CSV Parameter

Nov 2, 2015

I have a split string function that will take a comma delimited string and give back a table with all the values.I have a table that has a column with a comma delimited comma delimited list of states.

I can use a where clause to find one state in the table (such as all records that have CA in the states string).But need to find out how to find all the rows that have all or any of the states from a comma delimited parameter.Here is the schema

CREATE FUNCTION [dbo].[split] (@list nvarchar(MAX))
RETURNS @tbl TABLE (svar nvarchar(10) NOT NULL) AS
BEGIN
DECLARE @pos int,
@nextpos int,
@valuelen int

[code]....

View 9 Replies View Related

T-SQL (SS2K8) :: How To Pass Array Of Values As Parameter Of Function

Mar 4, 2014

I am trying to find out a way to pass an array of pbaseid's to a function.I have a function defind something like this

Fport(@portfoliobaseid, @reportingcurr, @rowno,@todate)
(
returning a table
)

trying to execute it like this but its giving error related to subquery must return single value

select * from Fport((select pbaseid from dbo.pbaseid),'us',1,'12/31/2013')

I think i need to find a way to pass this pbaseid one by one but i dont know how to do this ...

View 1 Replies View Related

T-SQL (SS2K8) :: Insert Multiple Values Based On Parameter

Jul 22, 2014

I need to write SP where user select SUN to MON check boxes. If user select Class A with sun,mon and wed check boxes then i need to insert data as below

CLASS Days
A sun
A Mon
A wed

View 6 Replies View Related

T-SQL (SS2K8) :: Pass A Column Name Using Parameter In Select Statement

Sep 5, 2014

I have a temp table that hosts data from a MDX query, I want to select a column from that table by passing in a parameter and then insert to a new table.

Here's the table structure, let's call it #temp

[Product].[Product Hierarchy].[level 03].[Member_CAPTION], [Measures].[Gross Sales]
Bike, 200
Accessory , 100

I have a table in the DB created as [ProductSales]

Here's what works for me:

insert into [ProductSales](Product, Sales)
Select convert(varchar(20), "[Product].[Product Hierarchy].[level 03].[Member_CAPTION]") as 'Product' , convert(decimal(18,2), [Measures].[Data]) as 'Sales'
From #temp

But in reality the product level is not always on level 03, I want to define a parameter @Product and pass it to the select list.

Here's what I tried to do:

Declare @Product varchar(500) = convert(varchar(20), "[Product].[Product Hierarchy].[level 01].[Member_CAPTION]")
Declare @SQL varchar(MAX)
SET @SQL='insert into [ProductSales](Product, Sales)
Select '+@Product+' as 'Product' , convert(decimal(18,2), [Measures].[Data]) as 'Sales'
From #temp'
Exec @SQL

But it threw me error, what is the right way to do it, is it because the double quote or single quote thing?

View 1 Replies View Related

T-SQL (SS2K8) :: Embedding A Variable Into A Parameter When Calling A Stored Procedure

Apr 8, 2014

I want to add the result of a Select statement inside a parameter, not too sure how to pull this off, but here it is...

--Declare needed variables
Declare @NoOfApprovals Int

--Get count of approvals
Select @NoOfApprovals =
(
select NoOfApprovalsToClaim

[code]...

View 2 Replies View Related

T-SQL (SS2K8) :: Passing Multiple Parameters With Table Valued Parameter To Stored Procedure?

May 21, 2014

Can we Pass table valued parameters and normal params like integer,varchar etc..to a single stored procedure?

View 1 Replies View Related

T-SQL (SS2K8) :: Procedure That Create Views With Table Name And A Table Field Parameter?

Aug 4, 2015

I would like to create a procedure which create views by taking parameters the table name and a field value (@Dist).

However I still receive the must declare the scalar variable "@Dist" error message although I use .sp_executesql for executing the particularized query.

Below code.

ALTER Procedure [dbo].[sp_ViewCreate]
/* Input Parameters */
@TableName Varchar(20),
@Dist Varchar(20)
AS
Declare @SQLQuery AS NVarchar(4000)
Declare @ParamDefinition AS NVarchar(2000)

[code]....

View 9 Replies View Related

T-SQL (SS2K8) :: Procedure Parameter Length Declaration Less Than Column Length?

Jun 30, 2014

is there any way or a tool to identify if in procedure the Parameter length was declarated less than table Column length ..

I have a table

CREATE TABLE TEST001 (KeyName Varchar(100) ) a procedure
CREATE PROCEDURE SpFindNames ( @KeyName VARCHAR(40) )
AS
BEGIN
SELECT KeyName FROM TEST001
WHERE KeyName = @KeyName
END
KeyName = @KeyName

Here table Column with 100 char length "KeyName" was compared with SP parameter "@KeyName" with length 40 char ..

IS there any way to find out all such usage on the ALL Procedures in the Database ?

View 2 Replies View Related

T-SQL (SS2K8) :: Report Parameter Textbox In SSRS Report

Aug 12, 2014

I have a report parameter textbox in my SSRS report which has the parameter properties as "allow null value" and "allow blank value" checked.

How I can ensure that when the value is entered in textbox, it should accept any character ie. The SQL code I should write so that all the characters inputted via the report parameter are accepted.

View 1 Replies View Related

Need Help Populating A Variable (using .Net && C#)

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

Populating Dropdownlist

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

Populating A Table

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

Populating A Table

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

One Of The DatSets Is Not Populating

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

Populating A Table With A Dataset

Apr 17, 2007

I am running a program that populates tables on my local database by querying another database. 

View 2 Replies View Related

Populating Data Between Ranges

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

Populating Labels From A Query

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

Populating An Array From A Sqlreader

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

Populating 2 Variable At The Same Time In An SP.

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

Populating A DB From 2 Tables (Dynamic)

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

Report Populating Incorrectly

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

Populating Data In A Pdf File

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

Populating Database With Timestamps...

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

Populating Data From One SQL Database To Another

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







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