Assigning PK And FK

Feb 19, 2004

Hi,

I have three tables -

Table A
Col1...Col2
1.....A
2....B

Table B
Col3...Col4
1.....X
2....Y

TableC
Col1...Col3....Col5...Coln
1........1...........H....Y.

A&B serve as the parent table for C. A&B are the dimension tables and C is the fact table. How do I assign the PK and FK in EM?

Thanks

View 5 Replies


ADVERTISEMENT

Assigning A DB Value To A Variable

Mar 8, 2005

Consider the following:

Sub regUser(s as Object, e as EventArgs)

If IsValid Then

Dim stuTable as String
Dim connStr as String

stuTable = "mytable"
connStr = "myConnectionInfo"

'check to see that student num is in the db
Dim connect as SqlConnection
Dim strSelect as String
Dim cmdSelect as SqlCommand
Dim strDbResult as SqlDataReader

connect = New SqlConnection(connStr)
strSelect = "SELECT stu_num, stu_fname, stu_lname FROM " + stuTable + " WHERE stu_num=@stuNum"
cmdSelect = New SqlCommand(strSelect,connect)
cmdSelect.Parameters.Add("@stuNum", txtStdNum.text)

connect.Open()
strDbResult = cmdSelect.ExecuteReader()

Dim stuFName as String
Dim stuLName as String
Dim stuEmail as String
Dim strRandom as String
Dim strPassword as String
Dim i as Integer
Dim charIndex as String
Dim stuMailMessage as MailMessage
Dim strHTMLBody as String

'declare stuFname, stuLname, stuEmail
stuFName = strDbResult("stu_fname")
stuLName = strDbResult("stu_lname")
stuEmail = txtStdEmail.text

'more code follows ....

In my DB I have a table with the columns stu_num, stu_fname and stu_lname. Each of these columns contains rows with data. However, the proceeding code gives me this error: Invalid attempt to read when no data is present (line 58 --> stuFName = strDbResult("stu_fname") ).

What am I doing wrong here? How do I assign the stu_fname in the DB to the page level variable stuFName?

As a little aside how do I say "If no record was found matching stuNum Then" ... ??

Sorry, I'm a .NET beginner ...

View 1 Replies View Related

Assigning Value To A Variable

Feb 4, 2008

Hi,
Is it possible to assign the column value to a user defined variable?

View 3 Replies View Related

Assigning Value To An Variable

Aug 24, 2007



Hi ,

I have a typical scenario here where I am trying to assign a variable a value using another variable, for that I am using two execute SQL task , the fisrt one assigns the first variable a value and then the second one uses the first variable to evaluate and then assigns a value to another variable. The first execute sql task works fine , however the second one fails with the following error

"failed with the following error: "An error occurred while extracting the result into a variable of type (DBTYPE_I4)". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. "

Here is the query I am using to assign the value in my second execute sql task


select (CASE

WHEN Sum(col1) <> 0 AND ? = 'M' THEN 'M'

WHEN Sum(col2) <> 0 AND ? >= 'T' THEN 'T'

WHEN Sum(col3) <> 0 AND ? >= 'R' THEN 'R'

ELSE 'S'

END) as Current

FROM dbo.TABLE1


I am passing the variable by mapping the parameters and then assigning the value using a single row result set.
Can someone please tell me where am I going wrong?

Thanks

View 13 Replies View Related

Getting The Value Of The Sqldatasource And Assigning It To A Label

Mar 1, 2008

Hi,
I have a sqldatasource which returns the result I want, but I need to assign it to a label or text box.  Is there an easy way of doing this?  I attempted it using this code:
PropertyFriendIDLabel.Text = PropUserIdSqlDataSource
Thanks

View 4 Replies View Related

Assigning Value To SessionParameters In SqlDataSource

May 22, 2008

Hello, 
I am using SessionParameters within a sqldatasource control, which is the datasource for a formview control.
The Session["PoolID"] has a value which is '0000009485'.<InsertParameters><asp:SessionParameter SessionField="PoolID" Name="pool_id"  Size="10" Type="String" ConvertEmptyStringToNull="true" />      
</InsertParameters>But when I click 'Save' I get the message 'Cannot insert the value null into column 'pool_id'. Column does not allow nulls. Insert fails'.Do i need to specify something like DefaultValue = <%Session["PoolID"] %>?Thank you in advance for your help.RajanP.S. How can I avoid double line spacing while writing a post? Thanks.

View 2 Replies View Related

Assigning Two Foreign Key To One Table

Jun 9, 2008

hi all
 
can we assign two foreign key to one table .
 
 

View 3 Replies View Related

Help With Assigning Variables To From A SQL Query

Dec 24, 2003

I’ve reconfigured Microsoft’s IBS Store shopping cart to function within a small e-commerce website. What I am trying to do is to modify the code slightly in order to use a third party credit card processing center. The situation is this: once the customer clicks the final "check out" button, a stored procedure writes all of the product ordering information into the database. I, then, capture what they're wanting to purchase with the following SQL statement:

Dim strSQL as String = "Select orderID, modelNumber from orderDetails" & _
"where CustomerID = " & User.Identity.Name & _
"And orderid = (SELECT MAX(orderid)FROM orderDetails" & _
"where CustomerID = " & User.Identity.Name & ")"

What I would like to do is assign specific values to variables based off of the above query. For example:

Dim orderItem as String = (all of the modelNumbers from the query)
Dim orderIdItem as String = (all of the orderIDs from the query)

How do I do this?? Any help is much appreciated! Thanks in advance.

Ron

View 6 Replies View Related

Assigning Rights To User

Apr 5, 2001

Hi,
I want to give 'Execute' permission for all the sp to a particular user.
Any straight way of doing this then to go to each sp and give him permission for every sp.
TIA.

View 2 Replies View Related

Error With Assigning Variable A Value

Dec 6, 2006

i am trying on this but hit error

Declare @var int
Set @var = select max(value) from xxx

anyone can help me?

View 2 Replies View Related

Assigning To Multipule Categories

Aug 18, 2004

Ok guys,
I'm realitvely new to the whole database development stuff, but I have a very important project to finish using SQL and ASP. I am to design a new links manager for a website.
Right now I have the following:
The ability to add a link, and edit it
The ability to add a category and edit it

When you go to add a link, a list of categories is provided for you, with checkboxes. What I need to do is figure out how to assign multipule categories to one link.
I have a Cross-Referencing table with three fields:
CrossRefID
LinkID
and CatID.

If you need more clarification, post here and let me know.

Thanks in Advance,
Aaron Hawn (aaron@ionzion.net)

View 2 Replies View Related

Assigning Or Changing A Schema Name

Mar 3, 2008

Hello everyone. I wanted to learn to assign and change a schema names used in my table. I dont want a dbo. in my tables. I want to give a personal name like the adventureworks database has. (Such as sales.salesdetails, humanresources.employee and all)

> So how i do create a table with a schema name sales
and
> How do i change my for example dbo.employee to sales.employee ??

I tried
Create table sales.employee
{
statements
}

but it doesnt work...
Please reply ASAP

Thanks

into the world of programming now :)

View 6 Replies View Related

Assigning Each Record To One String

Jul 23, 2005

hello,i would like to loop through a record set and assign each value to thesame string, (example i would like to return all of the first name inthe authors table = Authors_total.)should i use a cursor or just a loop to do this? I have had sometrouble with the syntax in a cursor.nicholas.gadacz

View 4 Replies View Related

Assigning User To A Database

Aug 11, 2007

Hi

I am using SQL SERVER 2000. Until now my application used the default user "sa", but now the illigal access to my database make me move to a more secure login.
i am new to this concept.
i need to create a login, which i am successful in creating, but my problem is
I need to allow only this user to access my database and no other user should login my database.
please can any one explain how to do this.
its very urgent.

regards
James Alvin

View 6 Replies View Related

Assigning A Variable A Table Value

Aug 8, 2006

Hi I'm new to SQL and I'm trying to build a store procedure. What I'm trying to find out is how to assign a variable a value from a table.

So, I declare a variable:
DECLARE @variable int
Then I want to assign a single int value to that variable that is already in a table. For instance the id value from a single row in a table.

I've tried SELECT INTO and SET, but nothing has worked so far and I'm lost after searching for a few hours.

Thanks in advance for any help

View 3 Replies View Related

Assigning A Select Value To Each Row Of A Dataset

Oct 4, 2007

I have the following problem:
in a data flow, if inserting new records, there are columns that take some default values. These default values are kept in a table in case the user wants to change them some day. Def. values could not be assigned at a table level because there's another dataflow that populates the same table, but the rules for the default values are different.

Since I want to extract these values only if there is at least one new row, I'm not fond of the idea to use Execute SQL Task (to save the default values in a variable) before the actual Data Flow. What are my options in getting these values in a Data Flow right before inserting? Thank you for the help.

View 5 Replies View Related

Assigning Value Of A Variable To A Column Name

Mar 25, 2008



Hi,

I would like to assign the value of a variable to a column name of a table. For eg:

declare @sam varchar(100)
set @sam = 'Insert'
create table #temp(Sample varchar(100) not null)
insert into #temp(Sample) Values(@sam)
drop table #temp

I would like to generate a table whose column name should be generated dynamically. The value of @sam that is "Insert "should be set to the column name. Is there a way to assign like this. Can anyone please help me in achieving this.

Thanks,
Sana.

View 1 Replies View Related

Assigning Value To The Variable At Runtime.

Mar 20, 2008

Hi,

1 20031012121212 200 (recordtype, CreationDateTime(YYYYMMDDHHMISS), Rec_Count) -- Header records
2 ABCD, XYZ, 9999, 999999999, 1234 ---- Detailed Record
2 ABCD, XYZ, 9999, 999999999, 1234 ---- Detailed Record

For the above given sample data I am having two outputs at Condition Split (based on the recordtype). I want to store the 1st record datetime value into a variable and then I want to use that variable value into 2nd and 3rd row.

Basically, detailed records would be stored into the database not the header record. Is there any way I can use the variable while doing processing for 2nd and 3rd records.

Please suggest me.

Regards,

View 10 Replies View Related

Assigning The Value Of Variables In A Subpackage

Feb 14, 2006

Hi,

I have a parent SSIS package that executes various subpackages. Each of the subpackages contain variables that are required for their successful execution, e.g. one has a variable of datetime datatype and a variable of varchar datatype.

This date will essentially change with every running of the package as it specifies the date that additional data has been added to the back-end SQL Server 2005 database.

I can't find anything in the expressions of the Execute Package Task that would allow me to pass these variables into the package.

Can anyone advise?

Thanks,

Paul

View 2 Replies View Related

Assigning Values To Parameters Dynamically

Oct 25, 2006

i using a bound data grid which is using a stored proc. The stored proc needs the ClientID "if logged in" there is no form or control on the page outside of the loginstatus.  I am wanting to pass the Membership.GetUser.ProviderUserKey.ToString()  to the asp:parameter but I cant get it to work.So How do I pass a variable to a stored proc parameter using a bound data grid.I this its very strange that this cant be dont and there are a raft of reason why you wold want to do this with out the need to pass it to a form control.please helpjim

View 2 Replies View Related

Help Assigning A Datasource To The Gmap Control In C#

Sep 18, 2007

I'm trying to assign a datasource to a gmap control in 2.0 so that i can get pushpins in the map for all the locations in the sql db. I've enclosed my code below as well as a link to the site that provides the control and their sample. Can anyone tell me why it won't show the pins? What am I doing wrong?
Thanks.
 My Code (sqllocations is a datasource):
GMap1.DataSource = sqllocations;
GMap1.DataBind();
Their site: http://en.googlemaps.subgurim.net/ejemplos/ejemplo_991000_DataSource.aspx
Their example (part of their explanation is not english, sorry):
 List<DataSourceField> fields = new List<DataSourceField>(); fields.Add(new DataSourceField(45, 2, "hola"));fields.Add(new DataSourceField(46, 3));// Lo comentamos porque al utilizar la clase DataSourceField, // pero si fuera un dataset o cualquier otra cosa, // le deberíamos dar los nombres correspondientes// GMap1.DataLatField = "lat";// GMap1.DataLngField = "lng";// GMap1.DataGInfoWindowTextField = "gInfoWindowText";GMap1.DataSource = fields;GMap1.DataBind();  
 

View 1 Replies View Related

Stored Procedure And Assigning @@IDENTITY Value

Nov 3, 2003

In the following stored procedure I would like to test whether @TopCategoryID is null. If so I would like to insert the @CategoryID value into the @TopCategoryID value. So, once @CategoryID recieves the @@IDENTITY value, how do I enter this same value into @TopCategoryID as well???



CREATE PROCEDURE sp_CT_InsertCategory



@Namevarchar(50),
@Description varchar(250),
@topCategory bit,
@ParentCategoryID int,
@TopCategoryID int,
@CategoryID int OUTPUT
AS
DECLARE @CurrID int


IF @CurrID IS NULL
BEGIN

INSERT
INTO CT_Category
(CategoryName, CategoryDescription, topcategory, parentcategoryid, topcategoryid)
VALUES
(@Name, @Description, @topcategory, @ParentCategoryID, @TopCategoryID)

SET @CategoryID = @@IDENTITY

IF @@ERROR > 0
BEGIN

RAISERROR ('Insert of Category failed', 16, 1)
RETURN 99

END

END
ELSE
BEGIN

SET @CategoryID = -1

END
GO



Thanks in advance

View 9 Replies View Related

Assigning Data From An SQL Query To A Variable

Apr 27, 2006

Hello all,
for a project I am trying to implement PayPal processing for orders
public void CheckOut(Object s, EventArgs e)    {        String cartBusiness = "0413086@chester.ac.uk";        String cartProduct;        int cartQuantity = 1;        Decimal cartCost;        int itemNumber = 1;        SqlConnection objConn3;        SqlCommand objCmd3;        SqlDataReader objRdr3;        objConn3 = new SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);        objCmd3 = new SqlCommand("SELECT * FROM catalogue WHERE ID=" + Request.QueryString["id"], objConn3);        objConn3.Open();        objRdr3 = objCmd3.ExecuteReader();        cartProduct = "Cheese";        cartCost = 1;        objRdr3.Close();        objConn3.Close();                cartBusiness = Server.UrlEncode(cartBusiness);        String strPayPal = "https://www.paypal.com/cgi-bin/webscr?cmd=_cart&upload=1&business=" + cartBusiness;        strPayPal += "&item_name_" + itemNumber + "=" + cartProduct;        strPayPal += "&item_number_" + itemNumber + "=" + cartQuantity;        strPayPal += "&amount_" + itemNumber + "=" + Decimal.Round(cartCost);        Response.Redirect(strPayPal); 
 
Here is my current code. I have manually selected cartProduct = "Cheese" and cartCost = 1, however I would like these variables to be site by data from the query.
So I want cartProduct = Title and cartCost = Price from the SQL query.
How do I do this?
 
Thanks
 

View 1 Replies View Related

Assigning Password To SQL Service Account

Jul 6, 2000

We have changed NT Administration Password. Now how to reassign the new password setting for sql server service account. As right now all schedule jobs are getting failed & needs to be executed manually.

Thanks in Advance

Manoj

View 1 Replies View Related

Assigning Column Types In Select Into

Jul 23, 2005

Group,Is there a way to assign nullability on a column when using a select into?I've tried some of the usual things like coalsce, isnull, and cast. Sincethe new table gets definition from the source table or can be somewhatadjusted with cast is there a way to cast a not null? In the example belowhow can I select into causing tableone_new..col2 to be not null. Wetypically must use an alter statement after the select into but this seemsinefficient.Thanks,Raycreate table tableone (col1 int not null,col2 int )goinsert tableone values (1, 1)insert tableone values (2, 2)insert tableone values (3, 3)goselectcol1,col2into tableone_newfrom tableonegoexec sp_help tableone_newgodrop table tableonegodrop table tableone_newgo

View 3 Replies View Related

Assigning Foreign Key To New SQL Server Table

Aug 31, 2005

HiI am creating new SQL Server Tables using SQL Server 2005. I have setprimary key to the tables .But I do not know how to assign Foreign keyto the tables .I need to do some joins later and that is why I have toput Foreign key to the table . The Primary key is visible and can beassigned easily .But How do I assign foreign key .Thanks*** Sent via Developersdex http://www.developersdex.com ***

View 3 Replies View Related

Assigning Current Date To A DTS Parameter

Oct 28, 2007



How do I assign the current date to a DTS parameter using a script - the following fails:


Imports System

Imports System.Data

Imports System.Math

Imports Microsoft.VisualBasic

Imports Microsoft.SqlServer.Dts.Runtime

Public Class ScriptMain

Public Sub Main()

Dts.Variables("RunDate").Value = Now.Date

Dts.TaskResult = Dts.Results.Success

End Sub

End Class

Error message:

Error: The wrapper was unable to set the value of the variable specified in the ExecutionValueVariable property.

Thanks.

Dan

View 3 Replies View Related

Dynamically Assigning Dataset To A Report

Jan 31, 2008



Hi All,

How to assign dataset(meaning SQL Query) to a report at RunTime. Please help me in doing this it's urgent.

-SR

View 4 Replies View Related

Assigning Report Permission In Bulk

Jan 22, 2008

Hi,

As I understand correctly, SSRS is able to assign a domain user to a report item. I have more than 2000 reports which need to be assigned to > 2000 unique domain users, is there a way I can run a script to automate this process? Otherwise what is the right way to do this?

Thanks!

View 4 Replies View Related

Return And Assigning Values In Functions

Dec 19, 2007

Hi ,

I will need some examples in assigning and getting values using SQLServer 2005. For eg. How can I store the value that I retrieved in a variable and return that value ? How can I use a function inside a stored procedure ? Do we have any examples or some simple sample code just to take a look ?

For eg I have written the following function which I called from a stored procedure.
BEGIN
--Declare the return variable here
DECLARE @Rows NUMERIC(10)
DECLARE @RETURN_ENABLED VARCHAR(1)
-- Add the T-SQL statements to compute the return value here

SELECT @Rows = MAX(PROFILE_INDEX) FROM PROFILE_PERMISSION PP
INNER JOIN sys_menu_item ON PP.MENU_ITEM=sys_menu_item.menu_item
WHERE PP.PROFILE_INDEX in (select up.profile_index from user_profile up where up.user_id= @is_user) and
not exists (select up.profile_index from user_profile up where up.user_id= @is_user and up.profile_index=1) and
PP.APPLICATION_CODE = @is_appl AND
PP.MENU_NAME=@menu_name
Group By Profile_INdex

IF @Rows > 0
SELECT @RETURN_ENABLED = 'N'
ELSE
SELECT @RETURN_ENABLED = 'Y';


-- Return the result of the function
RETURN @RETURN_ENABLED;

END

Is it correct ? The variable @ROWS will be assigned with the values that the sql statement will return ?

From the stored procedure I'm calling the function inside a CTE.

;WITH GetHierarchy (item_text ,orden , read_order, item_parent , menu_item , enabled)
AS
(--Anchor.
select tb1.item_text, tb1.orden, tb1.read_order, tb1.item_parent , tb1.menu_item ,
dbo.f_sty_print_menu_per_role_per_app2(@menu_name , @is_user , @is_appl) as enabled
From sys_menu_item as tb1
where tb1.MENU_ITEM not in ('m_window','m_help','m_toolbar') and tb1.item_parent not in ('m_toolbar','m_window','m_help')
And tb1.item_parent= @menu_name
--Members
UNION ALL
select tb2.item_text, tb2.orden, tb2.read_order, tb2.item_parent , tb2.menu_item ,
dbo.f_sty_print_menu_per_role_per_app2(@menu_name , @is_user , @is_appl) as enabled
from sys_menu_item as tb2 , GetHierarchy
where tb2.MENU_ITEM not in ('m_window','m_help','m_toolbar') and tb2.item_parent not in ('m_toolbar','m_window','m_help')
And tb2.item_parent = GetHierarchy.menu_item and tb2.menu_name = @menu_name
)
select Space(5*(orden)) + item_text as menui, orden, read_order, item_parent , menu_item ,enabled
From GetHierarchy

Am I doing it correctly ?

I would appreciated any help you could give me.

Thank you

View 5 Replies View Related

Assigning And Using Parent Package Variables

May 2, 2007

I have read a few different threads on this and I am still not having any luck. I have 4 dtsx files in my project. One represents the parent package. I have set up 3 Parent Package Variables and have assigned each to the value property of 3 variables within the parent package.



Not sure if I did this correct because when I execute the parent package, it in turn executes the first child package, but the child fails because the variables needed did not set the correct value for a connection string in the child's data connection.



I just need to know how to use these parent variables from Package A within the child (Package B) when setting up my expression for a connection- example: "@[User::varParentFilePath] " - This is the local variable name in the child. This is the variable I am assuming that I am supposed to be able to set the value property of from the parent variable?


I feel that I am close, but may need a little more direction. Thanks

View 10 Replies View Related

Assigning Variables Via Execute SQL Task

Apr 15, 2008

Somebody provided me with this link http://www.sqlis.com/58.aspx that helped me understand Execute SQL Task and how to assign values to variables from a resulting SQL query.

But I'm not sure if this tutorial addresses my particular example.

Here is what I'm trying to do.

I have a a simple table called VarTable with 2 columns. Col1 is called VarName, and Col2 is called VarVal. As you may have guessed from the column names, I want to hold variable and value pairs in this table.

Right now, I have 2 entries as follows.

Var1, Hello
Var2, Bye

I want to assign Hello and Bye into two variables in my package.

In using the above tutorial, I figured out how to assign one variable by doing the following SQL and using "Single row" Result Set property.

Select VarVal from VarTable
Where VarName = 'Var1'

Then in Result Set section of the Execute Task Editor I map VarVal with one of my user variables.

How do I take care of the 2nd variable in the same Execute SQL Task, or do I need to have another Execute SQL Task? Based on my understanding, in order for me assign multiple variables in one Execute SQL Task, I need somehow construct a SQL statement to return as many columns as I have variables to assign, but this seems hard to do given the variable table structure I have.

Please let me know if my example is unclear.

View 13 Replies View Related

Assigning Values For Variables From Ref Table

Nov 16, 2006

I have variables and values stored in a table in this format

process_id | t_variable | t_value
-----------------------------------------------------
1 | Remote_Log_Server | AUSCPSQL01
...
many such rows

how to assign values to variables in SSIS?

basically i'm looking for SQL equivalent of the following query i currently use to assign values to multiple variables (in a single query)

SELECT
@varRemoteLogServer=MAX(CASE WHEN [t_variable] = 'Remote_Log_Server' THEN [t_value] END)
,@varVariable2=MAX(CASE WHEN [t_variable] = 'variable2_name' THEN [t_value] END)
FROM Ref_Table
WHERE process_id=1

View 3 Replies View Related







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