Reference 2 Databases In SQL Statement

Sep 13, 2007

I need to join a table with another table in a different database. Is this possible?

Assume Table1 is in DB1 and Table2 is in DB2.


Thanks!
Brian

View 4 Replies


ADVERTISEMENT

How To Reference Different Databases On Different Servers In One Query

Apr 28, 2006

 

View 10 Replies View Related

SSIS Packages With Different Destination Databases... Removing Original DB Reference

Feb 26, 2007

Hi All,

OK, so I have an SSIS package that I build using the "test" database as the destination. Now I want to execute it using another database as the destination. This is basically for an installation script where the source is always the same, an access database.

So here I have:

"C:Program Files (x86)Microsoft SQL Server90DTSBinnDTExec.exe" /file e:data_import.dtsx /CONNECTION DestinationConnectionOLEDB;""Data Source=(local);Initial Catalog=Test2DB;Provider=SQLNCLI.1;Integrated Security=SSPI;Auto Translate=False;""

Which works (sort of). It does try to import the data into "Test2DB", but what happens is all of the destination tables in the dtsx package have names like [test1db].[dbo].[tablename]

So my question is: is there a way to remove the databasename reference in the table names for all 195 tables in my database without doing it manually?

Thanks in advance.

View 7 Replies View Related

Using The 'Like' Statement To Reference Another Table

Nov 4, 2007

Hi

Is it possible to to create a 'Like' statement that refernces all the data in a column from another table?
Thanks

View 1 Replies View Related

How To Reference A Text Box In An Insert Statement

Mar 28, 2006

    I am trying to take a value from at textbox and insert into a database. I think I need to convert the text to an integer - but I keep getting an error message saying I'm not allowed to use column names. Basically, I need to figure out how to take user input from these tet boxes and insert them into a database. Any ideas would be welcomed. the exact error is at the bottom the code.Here is the code:Imports System.DataImports System.Data.SqlClientPartial Class County_ConversionTest    Inherits System.Web.UI.Page    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click        Dim v1 As Integer        Dim v2 As Integer        'Dim v3 As Integer        v1 = Integer.Parse(TextBox1.Text)        v2 = Integer.Parse(TextBox2.Text)        TextBox3.Text = (v1 + v2)    End Sub    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click        Dim strconn As String = "Data Source=.SQLEXPRESS;AttachDbFilename=C:InetpubwwwrootHCBSApp_DataDivAging_Data.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True"        Dim cnnDivAging As SqlConnection = New SqlConnection(strconn)        Dim v1 As Integer        Dim v2 As Integer        Dim v3 As Integer        v1 = CInt(TextBox1.Text)        v2 = CInt(TextBox2.Text)        v3 = CInt(TextBox3.Text)                Dim strsql As String = "INSERT INTO tblTest (Name, fv1,fv2,fv3)" + _        "Values ('George',v1,v2,v3)"        Dim cmdUpdates As SqlCommand = New SqlCommand(strSQL, cnnDivAging)        cmdUpdates.Connection = cnnDivAging        cnnDivAging.Open()        cmdUpdates.CommandType = CommandType.Text        cmdUpdates.ExecuteNonQuery()        cnnDivAging.Close()    End SubEnd ClassHere is the error message -

The name "v1" is not permitted in this context. Valid expressions are
constants, constant expressions, and (in some contexts) variables.
Column names are not permitted.

View 2 Replies View Related

Statement Conflicted With The REFERENCE Constraint

Jun 21, 2006

Hello guys,

I would like to delete a row in a table, but I get the following message :

The DELETE statement conflicted with the REFERENCE constraint "FK_cs_Users". The conflict occurred in database "mytable", table "dbo.cs_UserProfile", column 'UserID'.
The statement has been terminated.
(0.701 sec)

But I did this :

alter table cs_Users disable trigger ALL

delete
from cs_Users
where MembershipID = 'xxx'

Thank you very much for any help to get this work !

Regards,
Fabian

my favorit hoster is ASPnix : www.aspnix.com !

View 6 Replies View Related

The DELETE Statement Conflicted With The REFERENCE Constraint FK__aspnet_Me__UserI__15502E78.

Nov 22, 2007

 Hello,         I try to delete a user from the Membership table but I receive this error. "The DELETE statement conflicted with the REFERENCE constraint "FK__aspnet_Me__UserI__15502E78". The conflict occurred in database "E:INETPUBWEBSITE4APP_DATAASPNETDB.MDF", table "dbo.aspnet_Membership", column 'UserId'.The statement has been terminated."...<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"        DataKeyNames="UserId" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display.">        <Columns>            <asp:CommandField ShowDeleteButton="True" />            <asp:BoundField DataField="UserId" HeaderText="UserId" SortExpression="UserId" />            <asp:BoundField DataField="UserName" HeaderText="UserName" SortExpression="UserName" />            <asp:BoundField DataField="LastActivityDate" HeaderText="LastActivityDate" SortExpression="LastActivityDate" />        </Columns>    </asp:GridView>    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>"        DeleteCommand="DELETE FROM [aspnet_Users] WHERE [UserId] = @UserId" InsertCommand="INSERT INTO [aspnet_Users] ([ApplicationId], [UserId], [UserName], [LoweredUserName], [MobileAlias], [IsAnonymous], [LastActivityDate]) VALUES (@ApplicationId, @UserId, @UserName, @LoweredUserName, @MobileAlias, @IsAnonymous, @LastActivityDate)"        ProviderName="<%$ ConnectionStrings:ASPNETDBConnectionString2.ProviderName %>"        SelectCommand="SELECT [ApplicationId], [UserId], [UserName], [LoweredUserName], [MobileAlias], [IsAnonymous], [LastActivityDate] FROM [aspnet_Users]"        UpdateCommand="UPDATE [aspnet_Users] SET [ApplicationId] = @ApplicationId, [UserName] = @UserName, [LoweredUserName] = @LoweredUserName, [MobileAlias] = @MobileAlias, [IsAnonymous] = @IsAnonymous, [LastActivityDate] = @LastActivityDate WHERE [UserId] = @UserId">        <InsertParameters>            <asp:Parameter Name="ApplicationId" Type="Object" />            <asp:Parameter Name="UserId" Type="Object" />            <asp:Parameter Name="UserName" Type="String" />            <asp:Parameter Name="LoweredUserName" Type="String" />            <asp:Parameter Name="MobileAlias" Type="String" />            <asp:Parameter Name="IsAnonymous" Type="Boolean" />            <asp:Parameter Name="LastActivityDate" Type="DateTime" />        </InsertParameters>        <UpdateParameters>            <asp:Parameter Name="ApplicationId" Type="Object" />            <asp:Parameter Name="UserName" Type="String" />            <asp:Parameter Name="LoweredUserName" Type="String" />            <asp:Parameter Name="MobileAlias" Type="String" />            <asp:Parameter Name="IsAnonymous" Type="Boolean" />            <asp:Parameter Name="LastActivityDate" Type="DateTime" />            <asp:Parameter Name="UserId" Type="Object" />        </UpdateParameters>        <DeleteParameters>            <asp:Parameter Name="UserId" Type="Object" />        </DeleteParameters>    </asp:SqlDataSource></Content> ...  cheers,imperialx   

View 1 Replies View Related

Getting An Error The DELETE Statement Conflicted With The REFERENCE Constraint FK_Detail_Header

May 14, 2008

Hello All, i have 2 files in excel which i am uploading them to a folder which is located in the root directory. then i am importing these two files into a sqldatabase. i needed some help in importing them and i got it from my previous post at http://forums.asp.net/t/1261155.aspx but now i have a problem. the import works perfectly first time but when i do it the second time i am getting an error on of the file (header). to explain clearly, what i am doing is , every time i upload a new file , i am deleting the data from the tables, so the new data can be inserted (  basically trying to achieve overwirting the existing data). now this technique works fine with the Detail table but not with the Header table. i think the reason is the header table has a primary key on OrderID and a relationship does exists between the Header and Detail. now how would i overcome this error. can some one please guide me. I really appreciate it.here is my code:  // connection for header file
protected OleDbCommand headExcelConnection() { // Connect to the Excel Spreadsheet
string headConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath("~/imports/headerorder.xls") + ";" + "Extended Properties=Excel 8.0;"; // create your excel connection object using the connection string
OleDbConnection headXConn = new OleDbConnection(headConnStr); headXConn.Open(); // use a SQL Select command to retrieve the data from the Excel Spreadsheet // the "table name" is the name of the worksheet within the spreadsheet // in this case, the worksheet name is "Sheet1" and is expressed as: [Sheet1$]

OleDbCommand headCommand = new OleDbCommand("SELECT * FROM [Sheet1$]", headXConn); return headCommand; } // importing header information


protected void BtnImpHeader_Click(object sender, EventArgs e) { PanelUpload.Visible = false; PanelView.Visible = false; PanelImport.Visible = true; LabelImport.Text = ""; // reset to blank // Create a new Adapter
OleDbDataAdapter objDataAdapter = new OleDbDataAdapter(); // retrieve the Select command for the Spreadsheet
objDataAdapter.SelectCommand = headExcelConnection();

// Create a DataSet
DataSet objDataSet = new DataSet(); // Populate the DataSet with the spreadsheet worksheet data
objDataAdapter.Fill(objDataSet);

// deleting the exisitng table before copy
SqlConnection mycon = new SqlConnection(ConfigurationManager.ConnectionStrings["ImportexcelConnectionString"].ConnectionString); SqlCommand SqlCmd = null; mycon.Open(); SqlCmd = mycon.CreateCommand(); SqlCmd.CommandText = "DELETE FROM Header"; ---- showing error over on second time SqlCmd.ExecuteNonQuery(); mycon.Close(); // entering the newer header information

SqlConnection mysqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["ImportexcelConnectionString"].ConnectionString); mysqlcon.Open(); foreach (DataRow dr in objDataSet.Tables[0].Rows) { String sqlinsert = "insert into Header values(@param1,@param2,@param3,@param4,@param5,@param6,@param7,@param8,@param9,@param10,@param11,@param12,@param13,@param14,@param15,@param16,@param17,@param18,@param19,@param20,@param21,@param22,@param23,@param24,@param25,@param26,@param27,@param28,@param29,@param30,@param31,@param32)"; SqlCommand cmd = new SqlCommand(sqlinsert, mysqlcon); cmd.Parameters.AddWithValue("@param1", dr[0].ToString()); cmd.Parameters.AddWithValue("@param2", dr[1].ToString()); cmd.Parameters.AddWithValue("@param3", dr[2].ToString()); cmd.Parameters.AddWithValue("@param4", dr[3].ToString()); cmd.Parameters.AddWithValue("@param5", dr[4].ToString()); cmd.Parameters.AddWithValue("@param6", dr[5].ToString()); cmd.Parameters.AddWithValue("@param7", dr[6].ToString()); cmd.Parameters.AddWithValue("@param8", dr[7].ToString()); cmd.Parameters.AddWithValue("@param9", dr[8].ToString()); cmd.Parameters.AddWithValue("@param10", dr[9].ToString()); cmd.Parameters.AddWithValue("@param11", dr[10].ToString()); cmd.Parameters.AddWithValue("@param12", dr[11].ToString()); cmd.Parameters.AddWithValue("@param13", dr[12].ToString()); cmd.Parameters.AddWithValue("@param14", dr[13].ToString()); cmd.Parameters.AddWithValue("@param15", dr[14].ToString()); cmd.Parameters.AddWithValue("@param16", dr[15].ToString()); cmd.Parameters.AddWithValue("@param17", dr[16].ToString()); cmd.Parameters.AddWithValue("@param18", dr[17].ToString()); cmd.Parameters.AddWithValue("@param19", dr[18].ToString()); cmd.Parameters.AddWithValue("@param20", dr[19].ToString()); cmd.Parameters.AddWithValue("@param21", dr[20].ToString()); cmd.Parameters.AddWithValue("@param22", dr[21].ToString()); cmd.Parameters.AddWithValue("@param23", dr[22].ToString()); cmd.Parameters.AddWithValue("@param24", dr[23].ToString()); cmd.Parameters.AddWithValue("@param25", dr[24].ToString()); cmd.Parameters.AddWithValue("@param26", dr[25].ToString()); cmd.Parameters.AddWithValue("@param27", Convert.ToDecimal(dr[26].ToString())); cmd.Parameters.AddWithValue("@param28", Convert.ToDecimal(dr[27].ToString())); cmd.Parameters.AddWithValue("@param29", Convert.ToDecimal(dr[28].ToString())); cmd.Parameters.AddWithValue("@param30", Convert.ToDecimal(dr[29].ToString())); cmd.Parameters.AddWithValue("@param31", Convert.ToDecimal(dr[30].ToString())); cmd.Parameters.AddWithValue("@param32", dr[31].ToString()); cmd.ExecuteNonQuery(); // new SqlCommand (stmt, mysqlcon).ExecuteNonQuery();
LabelImport.Text = "Rows Inserted"; } mysqlcon.Close(); }// connection for detail file

protected OleDbCommand detExcelConnection() { // Connect to the Excel Spreadsheet
string detConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath("~/imports/detailorder.xls") + ";" + "Extended Properties=Excel 8.0;"; // create your excel connection object using the connection string
OleDbConnection detXConn = new OleDbConnection(detConnStr); detXConn.Open(); // create your excel connection object using the connection string // use a SQL Select command to retrieve the data from the Excel Spreadsheet // the "table name" is the name of the worksheet within the spreadsheet // in this case, the worksheet name is "Sheet1" and is expressed as: [Sheet1$]
OleDbCommand detCommand = new OleDbCommand("SELECT * FROM [Sheet1$]", detXConn); return detCommand; }// importing detail information

protected void ButtonImport_Click(object sender, EventArgs e) { PanelUpload.Visible = false; PanelView.Visible = false; PanelImport.Visible = true; LabelImport.Text = ""; // reset to blank // Create a new Adapter
OleDbDataAdapter objDataAdapter = new OleDbDataAdapter(); // retrieve the Select command for the Spreadsheet
objDataAdapter.SelectCommand = detExcelConnection();

// Create a DataSet
DataSet objDataSet = new DataSet(); // Populate the DataSet with the spreadsheet worksheet data
objDataAdapter.Fill(objDataSet);

// deleting the exisitng table before copy
SqlConnection mycon = new SqlConnection(ConfigurationManager.ConnectionStrings["ImportexcelConnectionString"].ConnectionString); SqlCommand SqlCmd = null; mycon.Open(); SqlCmd = mycon.CreateCommand(); SqlCmd.CommandText = "DELETE FROM Detail"; SqlCmd.ExecuteNonQuery(); mycon.Close(); // entering newer detail information
SqlConnection mysqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["ImportexcelConnectionString"].ConnectionString); mysqlcon.Open(); foreach (DataRow dr1 in objDataSet.Tables[0].Rows) { String sqlinsert = "insert into Detail values(@param1,@param2,@param3,@param4,@param5,@param6,@param7,@param8,@param9,@param10,@param11,@param12,@param13)"; SqlCommand cmd = new SqlCommand(sqlinsert, mysqlcon); cmd.Parameters.AddWithValue("@param1", dr1[0].ToString()); cmd.Parameters.AddWithValue("@param2", dr1[1].ToString()); cmd.Parameters.AddWithValue("@param3", dr1[2].ToString()); cmd.Parameters.AddWithValue("@param4", dr1[3].ToString()); cmd.Parameters.AddWithValue("@param5", dr1[4].ToString()); cmd.Parameters.AddWithValue("@param6", dr1[5].ToString()); cmd.Parameters.AddWithValue("@param7", dr1[6].ToString()); cmd.Parameters.AddWithValue("@param8", Convert.ToDecimal(dr1[7].ToString())); cmd.Parameters.AddWithValue("@param9", Convert.ToDecimal(dr1[8].ToString())); cmd.Parameters.AddWithValue("@param10", dr1[9].ToString()); cmd.Parameters.AddWithValue("@param11", dr1[10].ToString()); cmd.Parameters.AddWithValue("@param12", dr1[11].ToString()); cmd.Parameters.AddWithValue("@param13", dr1[12].ToString()); cmd.ExecuteNonQuery(); LabelImport.Text = "Rows Inserted"; } mysqlcon.Close(); } the error is as follows:
Server Error in '/WebSite6' Application.


The DELETE statement conflicted with the REFERENCE constraint
"FK_Detail_Header". The conflict occurred in database "C:DOCUMENTS AND
SETTINGSMEMY DOCUMENTSVISUAL STUDIO
2005WEBSITESWEBSITE6APP_DATADATABASE.MDF", table "dbo.Detail", column
'OrderID'.The statement has been terminated. 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: The DELETE statement conflicted with the
REFERENCE constraint "FK_Detail_Header". The conflict occurred in database
"C:DOCUMENTS AND SETTINGSMEMY DOCUMENTSVISUAL STUDIO
2005WEBSITESWEBSITE6APP_DATADATABASE.MDF", table "dbo.Detail", column
'OrderID'.The statement has been terminated.Source Error:




Line 176: SqlCmd = mycon.CreateCommand();Line 177: SqlCmd.CommandText = "DELETE FROM Header";Line 178: SqlCmd.ExecuteNonQuery();Line 179: mycon.Close();Line 180:  again i really appreciate.Thanks 

View 1 Replies View Related

How To Reference Dataflow Elements In A SQL Statement Embedded In A Lookup Transformation?

May 8, 2008



Hi guys,

I need to use a SQL statement to lookup a value from a SQL server database table that relates to a column in my dataflow.

Imagine a SQL database table called 'cars' with values of

Year | Description
2005 Ferrari 355
2005 Ferrari 355 Spider
2006 Ferrari 355 F1

In my data flow I have Year and Model eg.

Year | Model
2005 355
2006 355


In my SQL statement I want to select from the 'cars' table where the years match exactly but the 'description' is like the 'Model'. eg. %355%

So essentially, how do I construct the 'like' clause in the select statement to reference the 'Model' column please?

thanks for your help,

Chris

View 4 Replies View Related

How To Trap DELETE Statement Conflicted With COLUMN REFERENCE Constraint Error

Oct 26, 2004

Hi,

On my aspx Web page, I want to delete a member from database table 'tblMember', but if this MemberID is used as FK in another table, I want to display a user friendlier message like "You cannot delete this member, ....." I am using Try, Catch blocks in my Web Page.

Currently it display this message:
"DELETE statement conflicted with COLUMN REFERENCE constraint 'FK_..._....' The conflict occurred in database '...', table 'tblMembers', column 'MemberID'. The statement has been terminated. "

So how should I precisely trap this error? Does anybody know what Exception is it? or what error number in SQL server?


Thanks

View 2 Replies View Related

Transact SQL :: Find All Stored Procedures That Reference Oracle Table Name Within Server OPENQUERY Statement

Aug 10, 2015

One of our Oracle Tables changed and I am wondering if there's any way that I can query all of our Stored Procedures to try and find out if that Oracle Table Name is referenced in any of our SQL Server Stored Procedures OPENQUERY statements?

View 2 Replies View Related

SQL 2012 :: DTSX Giving Errors - Object Reference Not Set To Instance Reference

Sep 10, 2014

I am using vs 2010 to write my dtsx import scripts.I use a script component as a source to create a flat file destination file.Everything have been working fine,but then my development machine crashed and we have to install everything again.Now when i use the execute package utility to test my scripts i get the following error:

Error system.NullReferenceException: Object refrence not set to an instance reference.

In PreExecute section
TextReader = new system.io.streamreader(" file name")
In the CreateNewOutputRows:
dim nextLine as string
nextLine = textReader.ReadLine

[code]...

is there something which i did not install or what can be the error?

View 0 Replies View Related

One SQL Statement To Access Databases On Different Servers

Dec 8, 2004

I know the SQL syntax to join two tables in different databases on the ame server, but does anyone know if a SQL statement will allow you to join tables from different databases on different servers?

View 8 Replies View Related

USE Statement In Stored Procedures Two Databases, How Please?

May 23, 2008

This works great in a query:


USE KCADOWNLOAD

USE OUTHOUSE

GO

DELETE FROM OUTHOUSE.KCA_BLDGS_ACCES

INSERT INTO OUTHOUSE.OUTHOUSE.KCA_BLDGS_ACCES

(MAJOR, MINOR, ACCYTYPE, ACCYDESCR,

QUANTITY, SIZE, UNIT, GRADE, EFFYR, PCNTNETCONDITION, ACCYVALUE, DATEVALUED, UPDATEDBY,

UPDATEDATE,PID)

SELECT MAJOR, MINOR, ACCYTYPE, ACCYDESCR,

QUANTITY, SIZE, UNIT, GRADE, EFFYR, PCNTNETCONDITION, ACCYVALUE, DATEVALUED, UPDATEDBY,

UPDATEDATE,PID

FROM KCADOWNLOAD.dbo.KCA_BLDGS_ACCES AS KCA_BLDGS_ACCES_1



But the stored procedure only creates ONE Use statement:


USE [KCADOWNLOAD]

...etc.


I assume I can run an SP utilizing two databases...


The SP fails because it hasn't got a clue what OUTHOUSE is...


Thank you!!!

View 3 Replies View Related

How To Join Tables From Different Databases In SQL Select Statement?

Apr 30, 2008

I have a basic sql statement, where I have a usersID, and I want to joing that usersID to another table in another database to get the users first and last names.  How do I join across databases... each with a different connection string? 
 Here's what I want..
Select usersID from tableA in databaseA, and usersFirstName, usersLastName from table B in database B where the usersID from tableA = the usersID in tableb. 

View 6 Replies View Related

UPDATE Statement Involving Tables In Different Databases

Feb 22, 2006

I want to create an UPDATE statement that updates a value in a table indatabase A based on the results of an inner join between tables eachresiding in deifferent databases.What is the correct syntax for doing this?The following should give you an idea of what I'm trying to do:UPDATE A.dbo.tblCarsSET A.dbo.tblCars.Car = 'Ferrari'FROMA.dbo.tblCars INNER JOIN B.dbo.tblHouses ONA.dbo.tblCars.RecID = B.dbo.tblHouses.RecIDWHERE (B.dbo.tblHouses = 'Mansion')

View 7 Replies View Related

Linking Tables From Different Databases Or Querying From Multiple Databases

Dec 10, 2007

Dear Readers,Is it possible, like in Access, to link to tables in other SQL databases that are on the same server? I have a query that I originally had in Access that queered from multiply databases. It did this by having those other tables in the other databases linked to the database that had the query. 
 

View 3 Replies View Related

Service Broker Not Working For Restored Databases (SQL 2000 Databases Restored On 2005)

Jan 24, 2006

I just restored my SQL server 2000 database on the SQL server 2005. after this i ran the Service broker sample ("Hello World") on this database by changing the AdventureWorks name to the new database name. The "setup.sql" runs fine. When i run the "SendMessage.sql" i was not getting any rows in the output (The message was not getting inserted into the queue). I checked the Service broker is enabled on this databased using the query "select is_broker_enabled from sys.databases where name = 'newdbname' " It was 1. I even tried the ALTER DATABASE SET ENABLE_BROKER. but it didnt work.

When i tried the sample on a newly created database it worked fine.

Is there any solution to make the restored database to work for service broker.

Thanks

Prashanth

View 3 Replies View Related

T-SQL Reference?

Feb 6, 2004

Hi y'all

Does anybody know reference or pdf file or free e-learning on the web?

View 1 Replies View Related

Reference

Jun 18, 2001

DECLARE Loan_cursor CURSOR FOR
SELECT Loan_No,store
FROM loan
WHERE maturity_date > '2001-04-30' and loan_no like 'ABL%'

OPEN Loan_cursor

-- Perform the first fetch.
FETCH NEXT FROM Loan_cursor

-- Check @@FETCH_STATUS to see if there are any more rows to fetch.
WHILE @@FETCH_STATUS = 0
BEGIN
Declare @LoanNo varchar(12)
** Set @LoanNo = Loan_No

-- This is executed as long as the previous fetch succeeds.
FETCH NEXT FROM Loan_cursor
END

CLOSE Loan_cursor
DEALLOCATE Loan_cursor


when l run the cursor l get the error
Server: Msg 207, Level 16, State 3, Line 15
Invalid column name 'Loan_No'.
.
If l reference it as Set @LoanNo = LoanTable.Loan_No l get the error

Server: Msg 107, Level 16, State 3, Line 15
The column prefix 'loan' does not match with a table name or alias name used in the query.
All l'm trying to do is to compare the loan number that l get from the cursor to the value in the loans table. Maybe reference is a better word

View 1 Replies View Related

Old Sp Reference

Jun 6, 2008

Hi friends,

Just i modified one sub stored procedures which is not getting affected in the main stored procedures

Create procedure main
as
begin
set nocount on

--First sp
exec Data_transfer_sp

--Second sp
Exec Clearance_sp

set nocount off
end

In data_transfer_sp,i have commented the select statement
but still iam use to the select result while execution the main sp.
Note:I have compiled the data_transfer_sp after making comment
.Txs in advance

View 3 Replies View Related

Reference CTE More Than Once In A SP

Sep 11, 2007



Hi All ...

WITH myCTE (x,y,z) AS (SELECT x,y,z, from myTable)

SELECT x,y,sum(z) from myCTE

SELECT y,z,sum(x) from myCTE

the second SELECT fails, and says invalid object name. does the CTE go out of scope after i reference it once?

never mind the semantics of what I am SELECTing, I just want to be able to reference the CTE more than once in my SP

am I trying to use the CTE in a way that was not intended?

View 5 Replies View Related

Reference CTE More Than Once In A SP

Sep 11, 2007



Hi All ...

WITH myCTE (x,y,z) AS (SELECT x,y,z, from myTable)

SELECT x,y,sum(z) from myCTE

SELECT y,z,sum(x) from myCTE

the second SELECT fails, and says invalid object name. does the CTE go out of scope after i reference it once?

never mind the semantics of what I am SELECTing, I just want to be able to reference the CTW more than once in my SP

am I trying to use the CTE in a way that was not intended?

View 1 Replies View Related

How To Get Reference Of .net Dll

Oct 15, 2007

hi ,

can any body help me that how can i use my .net dll into my rdl file.
thanks

Gorla

View 1 Replies View Related

The Reference

Feb 3, 2008

in this code ,whtat is the references of
RelationalDataSourceView
and also
what are the references of these?

OleDbConnection

OleDbCommand

OleDbDataAdapter

View 1 Replies View Related

Copying Databases Between Databases

Feb 8, 2000

hi from France !!!

i would like how to duplicate a database to another server with all datas, constraints, keys, indexes...
should i use sp_attach_db, dts, backup/restore, sql scripts... ???

thanks to all, nico

View 1 Replies View Related

Object Reference Not Set

Nov 16, 2006

Can anyone see why I would get the 'Object Referenece not set to an instance of an object error in the following code?
It happens on this line:
MyAdapter.SelectCommand = New SqlCommand(SelectStatement, MyConnection) 'Populate the text boxes from database for alumni fields.
Dim MyAdapter As SqlDataAdapter
Dim MyCommandBuilder As SqlCommandBuilder
Dim DetailsDS As DataSet
Dim Row As DataRow
Dim SelectStatement As String = "Select ClientID,ClassYear,HouseName,CampusName,EducationMajor,GraduationDate FROM tblclient Where [ClientID]=" & _
ClientIDSent
Dim ConnectStr As String = _
ConfigurationManager.ConnectionStrings("TestConnectionString").ConnectionString
Dim MyConnection As SqlConnection = New SqlConnection(ConnectStr)
MyAdapter.SelectCommand = New SqlCommand(SelectStatement, MyConnection)
MyCommandBuilder = New SqlCommandBuilder(MyAdapter)
MyAdapter.Fill(DetailsDS, "tblClient")

Row = DetailsDS.Tables("tblClient").Rows(0)
ClassYearText.Text = Row.Item("Classyear").ToString()
HouseNameText.Text = Row.Item("HouseName").ToString()
CampusNameText.Text = Row.Item("CampusName").ToString()
EducationMajorText.Text = Row.Item("EducationMajor").ToString()
GraduationDateText.Text = Row.Item("GraduationDate").ToString() 

View 2 Replies View Related

SQL Reference Online?

Jan 21, 2004

Hi,

I'm looking for a good reference guide online as I am more used to mysql (and stil quite limited vocab at that)

I create table outside of a database by accident and I'm now looking for the sql syntaxt for moving tables, but I can't find it anywhere?

most simple guides don't seem to provide the syntax to do this. :(

View 11 Replies View Related

Reference Material

Feb 23, 2004

does any one know any good pages to get some sql commands
and explainations thanks

View 2 Replies View Related

Why Must My SQL Object Reference With The DBO Name.

Sep 20, 2000

Hi,

I am access SQL 7 via ADO in some ASP pages. My database objects were created under a user name aliased to the dbo. As a result, when I have my client logon to make a connection, I have to preface all my object references with the name of the owner, i.e., Select * from mydboname.people . Is there a way to avoid having to prefix all my transact sql statements with the owner?

thanks,

steve

View 2 Replies View Related

Un Reference Tables

Sep 1, 2004

I have two tables that are reference to each other by foreign key, now I would like to alter the table so the it doesn't reference each other any more. What is the syntax to alter a table so that the fk field doesn't reference a table anymore. Thanks in advance for the help.

View 1 Replies View Related

MDX Reference Book

Feb 17, 2004

What would you recommend for a good MDX book ?
specifically, for syntax, data structures and sample code.



thx

C

View 1 Replies View Related

Reference Materials

Jun 21, 2008

As I posted earlier, I am relatively new to TSQL. I have been given a few books:
O'Reilly SQL on SQL Server 2005
O'Reilly SQL in a Nutshell
Mastering SQL Server 2005 - Sybex
Beginning SQL Server 2005 Programming - Wrox

I have a copy of SQL2005 Developers Edition on a development server. So I think I have some decent tools at my disposal.

I was wondering if there are any other sites or forums that might be suggested for learning SQL programming? Right now, I am just making stuff up and following examples in books, etc. I would like to find a site where there are beginner level projects for no other purpose than educational. Something where I can get more hands on of the design and programming aspects. Just to practice.

Thanks,
grinch

View 5 Replies View Related







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