How To Connect To SQL Database, Create Tables

Jan 2, 2006

Hi All, 1st of all happy New Year to all asp.net forum members

    I am new at asp.net. I want to design a website
using asp.net as frontend and sql database as backend. I am able to
connect and add,update as well delete records when I use MsAcess and
Asp.net using the following connection strings...

**********

sub Page_Load

dim dbconn,sql,dbcomm,dbread

dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & server.mappath("/database/northwind.mdb"))

dbconn.Open()

sql="SELECT * FROM customers where city LIKE 'Berlin' order by city ASC"

dbcomm=New OleDbCommand(sql,dbconn)

dbread=dbcomm.ExecuteReader()

customers.DataSource=dbread

customers.DataBind()

dbread.Close()

dbconn.Close()

end sub

**********



But when I try to connect to sql database using the following connection strings I am unable to do so...



**************

SqlConnection myConnection = new SqlConnection("server=PLATINUMVSdotNET;database=pubs;Trusted_Connection=yes");

        SqlDataAdapter myCommand = new SqlDataAdapter(" * from Authors", myConnection);



        DataSet ds = new DataSet();

        myCommand.Fill(ds, "Authors");



        MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;

        MyDataGrid.DataBind();



**************

I have written the servername as "PLATINUMVSdotNET" because when I
installed SQL SERVER 2000 I found a tray icon where the server name was
displaying the same (my computer name is PLATINUM).

When I used webmatrix I enterd the same server name and  windows
authentication I was able to create a database but How to create
table...



Please help me out

Thanks in advance...

View 4 Replies


ADVERTISEMENT

Delay Between CREATE DATABASE And Ability To Connect To That Database

Oct 9, 2006

I have an application that creates a new database during installation,and I've noticed some strange behavior. Once I've created thedatabase, I am able to immediately create tables and populate lookupdata, provided I remain connected to the server. If, however, Idisconnect and attempt to reconnect immediately, I'll get an errorsaying that my login is invalid for the new database.I can get around this by having my code simply wait 5 seconds beforeattempting to reconnect, but I'm curious to see if anybody here cangive an explaination for why this is happening. Here is a bit ofpseudo code to explain what I'm seeing:open new connectioncreate databasecreate tablespopulate tablesclose connection// open new connection /* can't do this yet, as it would break */for (int a=0; a<5; a++){Thread.Sleep(2000)try{open new connectionbreak;}catch{Debug("still waiting...");}}Running my version of this code, I'll see that "still waiting..."message go past 2-3 times before SQL Server wakes up and realizes thatI'm allowed to connect to it. Anybody know why?Thanks,Jason KesterExpat Software Consulting Serviceshttp://www.expatsoftware.com/---Get your own Travel Blog, with itinerary maps and photos!http://www.blogabond.com/

View 1 Replies View Related

Solution!-Create Access/Jet DB, Tables, Delete Tables, Compact Database

Feb 5, 2007

From Newbie to Newbie,



Add reference to:

'Microsoft ActiveX Data Objects 2.8 Library

'Microsoft ADO Ext.2.8 for DDL and Security

'Microsoft Jet and Replication Objects 2.6 Library

--------------------------------------------------------

Imports System.IO

Imports System.IO.File





Code Snippet

'BACKUP DATABASE

Public Shared Sub Restart()

End Sub



'You have to have a BackUps folder included into your release!

Private Sub BackUpDB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BackUpDB.Click
Dim addtimestamp As String
Dim f As String
Dim z As String
Dim g As String
Dim Dialogbox1 As New Backupinfo


addtimestamp = Format(Now(), "_MMddyy_HHmm")
z = "C:Program FilesVSoftAppMissNewAppDB.mdb"
g = addtimestamp + ".mdb"


'Add timestamp and .mdb endging to NewAppDB
f = "C:Program FilesVSoftAppMissBackUpsNewAppDB" & g & ""



Try

File.Copy(z, f)

Catch ex As System.Exception

System.Windows.Forms.MessageBox.Show(ex.Message)

End Try



MsgBox("Backup completed succesfully.")
If Dialogbox1.ShowDialog = Windows.Forms.DialogResult.OK Then
End If
End Sub






Code Snippet

'RESTORE DATABASE

Private Sub RestoreDB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

RestoreDB.Click
Dim Filename As String
Dim Restart1 As New RestoreRestart
Dim overwrite As Boolean
overwrite = True
Dim xi As String


With OpenFileDialog1
.Filter = "Database files (*.mdb)|*.mdb|" & "All files|*.*"
If .ShowDialog() = Windows.Forms.DialogResult.OK Then
Filename = .FileName



'Strips restored database from the timestamp
xi = "C:Program FilesVSoftAppMissNewAppDB.mdb"
File.Copy(Filename, xi, overwrite)
End If
End With


'Notify user
MsgBox("Data restored successfully")


Restart()
If Restart1.ShowDialog = Windows.Forms.DialogResult.OK Then
Application.Restart()
End If
End Sub








Code Snippet

'CREATE NEW DATABASE

Private Sub CreateNewDB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

CreateNewDB.Click
Dim L As New DatabaseEraseWarning
Dim Cat As ADOX.Catalog
Cat = New ADOX.Catalog
Dim Restart2 As New NewDBRestart
If File.Exists("C:Program FilesVSoftAppMissNewAppDB.mdb") Then
If L.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
Exit Sub
Else
File.Delete("C:Program FilesVSoftAppMissNewAppDB.mdb")
End If
End If
Cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Program FilesVSoftAppMissNewAppDB.mdb;

Jet OLEDB:Engine Type=5")

Dim Cn As ADODB.Connection
'Dim Cat As ADOX.Catalog
Dim Tablename As ADOX.Table
'Taylor these according to your need - add so many column as you need.
Dim col As ADOX.Column = New ADOX.Column
Dim col1 As ADOX.Column = New ADOX.Column
Dim col2 As ADOX.Column = New ADOX.Column
Dim col3 As ADOX.Column = New ADOX.Column
Dim col4 As ADOX.Column = New ADOX.Column
Dim col5 As ADOX.Column = New ADOX.Column
Dim col6 As ADOX.Column = New ADOX.Column
Dim col7 As ADOX.Column = New ADOX.Column
Dim col8 As ADOX.Column = New ADOX.Column

Cn = New ADODB.Connection
Cat = New ADOX.Catalog
Tablename = New ADOX.Table



'Open the connection
Cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Program FilesVSoftAppMissNewAppDB.mdb;Jet

OLEDB:Engine Type=5")


'Open the Catalog
Cat.ActiveConnection = Cn



'Create the table (you can name it anyway you want)
Tablename.Name = "Table1"


'Taylor according to your need - add so many column as you need. Watch for the DataType!
col.Name = "ID"
col.Type = ADOX.DataTypeEnum.adInteger
col1.Name = "MA"
col1.Type = ADOX.DataTypeEnum.adInteger
col1.Attributes = ADOX.ColumnAttributesEnum.adColNullable
col2.Name = "FName"
col2.Type = ADOX.DataTypeEnum.adVarWChar
col2.Attributes = ADOX.ColumnAttributesEnum.adColNullable
col3.Name = "LName"
col3.Type = ADOX.DataTypeEnum.adVarWChar
col3.Attributes = ADOX.ColumnAttributesEnum.adColNullable
col4.Name = "DOB"
col4.Type = ADOX.DataTypeEnum.adDate
col4.Attributes = ADOX.ColumnAttributesEnum.adColNullable
col5.Name = "Gender"
col5.Type = ADOX.DataTypeEnum.adVarWChar
col5.Attributes = ADOX.ColumnAttributesEnum.adColNullable
col6.Name = "Phone1"
col6.Type = ADOX.DataTypeEnum.adVarWChar
col6.Attributes = ADOX.ColumnAttributesEnum.adColNullable
col7.Name = "Phone2"
col7.Type = ADOX.DataTypeEnum.adVarWChar
col7.Attributes = ADOX.ColumnAttributesEnum.adColNullable
col8.Name = "Notes"
col8.Type = ADOX.DataTypeEnum.adVarWChar
col8.Attributes = ADOX.ColumnAttributesEnum.adColNullable



Tablename.Keys.Append("PrimaryKey", ADOX.KeyTypeEnum.adKeyPrimary, "ID")


'You have to append all your columns you have created above
Tablename.Columns.Append(col)
Tablename.Columns.Append(col1)
Tablename.Columns.Append(col2)
Tablename.Columns.Append(col3)
Tablename.Columns.Append(col4)
Tablename.Columns.Append(col5)
Tablename.Columns.Append(col6)
Tablename.Columns.Append(col7)
Tablename.Columns.Append(col8)



'Append the newly created table to the Tables Collection
Cat.Tables.Append(Tablename)



'User notification )
MsgBox("A new empty database was created successfully")


'clean up objects
Tablename = Nothing
Cat = Nothing
Cn.Close()
Cn = Nothing


'Restart application
If Restart2.ShowDialog() = Windows.Forms.DialogResult.OK Then
Application.Restart()
End If

End Sub








Code Snippet



'COMPACT DATABASE

Private Sub CompactDB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

CompactDB.Click
Dim JRO As JRO.JetEngine
JRO = New JRO.JetEngine


'The first source is the original, the second is the compacted database under an other name.
JRO.CompactDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Program

FilesVSoftAppMissNewAppDB.mdb; Jet OLEDB:Engine Type=5", "Provider=Microsoft.Jet.OLEDB.4.0;

Data Source=C:Program FilesVSoftAppMissNewAppDBComp.mdb; JetOLEDB:Engine Type=5")


'Original (not compacted database is deleted)
File.Delete("C:Program FilesVSoftAppMissNewAppDB.mdb")


'Compacted database is renamed to the original databas's neme.
Rename("C:Program FilesVSoftAppMissNewAppDBComp.mdb", "C:Program FilesVSoftAppMissNewAppDB.mdb")


'User notification
MsgBox("The database was compacted successfully")

End Sub

End Class

View 1 Replies View Related

Can't Create And Connect To A New Database (.mdf File)

Jun 28, 2006

Unfortunately I was sent to this product by my Hosting Site since all I was trying to do was Create and Manage a User Login with authentication to my subsites in MS Frontpage. (rant: Why doesn't Frontpage support this technology???)

Anyway, I have now spent (wasted?) 8 hours downloading, installing, and tyring to configure SQL Express along with MS Visual Web Developer Express for ASP.NET 2.0 ... For the life of me I can't find detailed configuration informatin and setup information to build a SIMPLE database to connect to the VW product. Folk: this HAS to be simpler to do than what you present in the product! This is way too difficult to deal with compare with frontpage.

Is there a simple "how to" link someplace that is specific enough to preclude me from uninstalling this entire suite ????

View 1 Replies View Related

Setup And Upgrade :: LocalDB - Create And Connect To Database Programmatically

Jul 10, 2012

I need to be able to create & connect to temporary databases programmatically, and NOT using the command-line, within a C# program. How would one go about doing this?

View 7 Replies View Related

How Do I Connect To Tables Within Another Database Via View Designer/gui

Nov 21, 2007

I'm using the gui to create a view which requires my connecting to another database on the same server. I've tried to create synonyms; however, I can not access them (they do not display) on the synonym tab when I try to add them to the view.

I'm a novice so any suggestions to get me on my way is greatly appreciated.

Thank you in advance,
Steve

View 1 Replies View Related

Create Tables Within A New Database

Jan 20, 2012

I'm attempting to use SQL statement to create tables within a new database, and I'm somewhat lacking in experience for this. Normally I'd simply create them through the GUI, but I want to get the hang of DDL statements.

I have written what I think are scripts to create one table with a primary key, create a unique index on it, and then create another table with a primary key and constrain two columns in the second table to the non-primary unique index in the first.

Code:
Use SKUTracking
CREATE TABLE
SKUTracking.dbo.tblOraUnits

[code]...

View 7 Replies View Related

Create Tables For A Database?

Jul 16, 2014

Create a Database with the following:

a) Database to contain a list of people, their addresses, email addresses, and phone numbers.

b) Database to contain a list of cars, their names, their type (2 doors,4 doors, etc.), and their colour.

c) Database to allow only one owner per car

d) Database to allow multiple people to be able to act upon behalf of one car. (Disclosure of MOT details, request change of parts, etc)

View 4 Replies View Related

How To Create Database And Tables In MSDE

Sep 25, 2005

I have install the MSDE from Ofiice 2000 cd and my MSDE sql server is running fine that I can see from my tray bar with green arrow button. Now i want to create the database so can any body tell me how do i create database. Is there ne query analyser or enterprise manager by which I can create database. Also when i try to install starterkit it doen not allow me to install it. It ask me to select database from the dropdown list and when I select Localhost (only option available) and click on test connection it gives me error UnsuccessfullI am new at MSDN so please help me.

View 4 Replies View Related

How To Create Multiple Tables In A Database

Mar 6, 2008

I am trying to create multiple tables in a database using a SQL Script. First i want to find all the tables that have an Identity Column as a primary key in the database. Then for all the tables that meet the Identity Column and primary key criteria, I want to create a New Table.

For example if the Orders table has a Identity Column as a primary key, I want to Create a New Table called ProdID_Orders. The ProdID_Orders will have 1 column called ProdID.

If the OrdersDetails table has a Identity Column as a primary key, I want to Create a New Table called ProdID_OrdersDetails. The ProdID_OrdersDetails will have 1 column called ProdID.

If the Employee table has a Identity Column as a primary key, I want to Create a New Table called ProdID_Employee. The ProdID_Employee will have 1 column called ProdID.


so the Create Table Statement for the ProdID_Orders will look like this:


CREATE TABLE [dbo].[ProdID_Orders](

[ProdID] [int] NULL

) ON [PRIMARY]


The Create Table Statement for the ProdID_OrdersDetails will look like this:


CREATE TABLE [dbo].[ProdID_OrdersDetails](

[ProdID] [int] NULL

) ON [PRIMARY]

This sequence will continue for all the tables in the database that have an Identity Column as a primary key. Thanks. I will appreciate some assistance with this.

View 1 Replies View Related

Create Fields In Tables If They Do Not Exist In Database

Mar 31, 2008

Hello.
I need some help constructing a query i need to run on my database. I need to add 2 fields to every table in my databse. However, some of the tables already have1 or both these fields so i need to somehow do a check if the dield already exists. If it does not create the fields. Im using a MS SQL express 2005 server.
Could anyone help me construct this. Im pretty novice at SQL.
Thanks.

View 7 Replies View Related

Stored Procedure To Create A New Database With Tables

Feb 28, 2007

I want my application to create a new database/tables when run for thefirst time. I have created a stored procedure to create the newdatabase named "budget". When I run the stored procedure, it createsthe budget database but the tables are created in the "master"database. Please help.

View 6 Replies View Related

Running Create Scripts For Database, Tables And Procedures

Jul 7, 2005

Hi there,I am trying to create a Sql Server 2005 Express database by running Sql Scripts. I have a script that has CREATE statements for tables and procedures. What I'd like it to do is create a new database with a name and a file location I specify.I searched high and low, tried lots of options with the SqlCmd tool but I keep getting authentication or other errors.Is this even possible? If so, does someone know of a good reference? I know I can create a new database and tables from within VWD but I need to create this database based on a .sql file....Thanks in advance....Imar

View 22 Replies View Related

SQL Server Express Is Working - What Tool Do I Use To Create Database And Tables?

Aug 16, 2006

Hello,

I have SQL Server Express working however I don't see any tools to create a database and tables.

I am trying to create a database to store stock quotes that I will input from a c# program.

What tool should I use to design the database?

Thank you!
Toben

View 4 Replies View Related

SQL Security :: Create Database User And Give Grants To Few System Tables

Aug 12, 2015

Need to create a user in sql server provide grants to few system tables to the above user.

View 10 Replies View Related

Trouble Using ADOX To Create Linked Tables In Jet Database From An ODBC Datasource

Jun 5, 2007

Hai,

I am using ADOX to create linked tables in a jet database from an ODBC datasource.
The tables in the ODBC data source does not have a primary key.
so I am only able to create read only linked tables.But I want to update the records also.
I tried adding a primary key column to the linked table while creating the link.
but I am getting an error while adding the table to the catalog.

The error message is "Invalid Argument".

I use the following code for creating the linked table

Sub CreateLinkedTable(ByVal strTargetDB As String, ByVal strProviderString As String, ByVal strSourceTbl As String, ByVal strLinkTblName As String)

Dim catDB As ADOX.Catalog
Dim tblLink As ADOX._Table

Dim ADOConnection As New ADODB.Connection

ADOConnection.Open("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & strTargetDB & ";User Id=admin;Password=;")

catDB = New ADOX.Catalog

catDB.ActiveConnection = ADOConnection

tblLink = New ADOX.Table

With tblLink

' Name the new Table and set its ParentCatalog property
' to the open Catalog to allow access to the Properties
' collection.
.Name = strLinkTblName
.ParentCatalog = catDB

' Set the properties to create the link.
Dim adoxPro As ADOX.Property

adoxPro = .Properties("Jet OLEDB:Create Link")
adoxPro.Value = True

adoxPro = .Properties("Jet OLEDB:Link Provider String")
adoxPro.Value = strProviderString

adoxPro = .Properties("Jet OLEDB:Remote Table Name")
adoxPro.Value = strSourceTbl


End With

'Adding primary key,
'***** the source column name is "Code" ******
tblLink.Keys.Append("PrimaryKey", ADOX.KeyTypeEnum.adKeyPrimary, "Code")

'Append the table to the Tables collection.
'******The exception occurs on the following line***********
catDB.Tables.Append(tblLink)

'Append the primary index to table.
catDB = Nothing

End Sub

If I avoid the line for adding the primary key,everything works fine,but the table ctreated is readonly.

Thanks in advance
Sudeep T S

View 4 Replies View Related

Integration Services :: Automate Process Using SSIS To Create Tables In Corresponding Database And Load Data

Oct 6, 2015

We are using SQL Server 2014 and SSDT-BI 2013. We have a reporting environment where business users create objects which need to be persisted for fiscal year reporting. Let's say for instance SQLSERVER1SRVR1 they create table objects like below in the reporting environment.

Accounting2014, Accounting2015 in AccountingDB; 
Sales2014, Sales2015 in SalesDB; 
Products2014, Products2015 in ProductsDB; 
Inventory2014, Inventory2015 in InventoryDB etc....

These tables are persisted for auditing in a different environment SQLSERVER2SRVR2 for finance & audit folks.We would want to automate this process using SSIS to create tables in corresponding database and load data. I tried using For Each Loop container but the catch is I could loop the source or destination but how do we loop on Source & Destination at the same time (i.e when source is in AccountingDB destination to be AccountingDB, source SalesDB then destination SalesDB so on etc....

View 6 Replies View Related

Cant Create New Database / CREATE DATABASE Permission Denied In Database Master (error 262)

Oct 2, 2007

 
 I am using SQL express and Visual web developer on windows Vista.
When I try to create a new database the following message appears.
 
CREATE DATABASE permission denied in database master (error 262)
I log on to my computer as an administrator.
Help appreciated
 Prontonet
 
 
 

View 4 Replies View Related

Why I Cannot Create/edit Tables In VS.Net Server Explorer For SQL Server 2000 Developer Local Database?

Apr 7, 2006

I found that when I install MSDE, then I can create/edit database objects for MSDE database in Visual Studio 2003 Server Explorer, but when I try to create/edit database objects under the default database created by the SQL Server 2000 installation, I cannot do these tasks as no option for these tasks appear when I right-click on the database object in Server Explorer.  Anyone knows why this is happening?

View 3 Replies View Related

How To Create Multiple Tables On The Fly So That Every User Each Has His/her Own Set Of Tables?

Aug 12, 2006

Hello all,

Being still a relative newcomer to SQL Server (people may say I'm trying to take on too much being somewhat inexperienced once they read about the problem I'm trying to tackle, but alas...) I'm running into the following problem: I need to create tables in my user database on the fly (using Stored Procedures) so that each table can be created many times in the database but only once for every user. The tables should be named something like "username.Table1", "username.Table2" etc. as opposed to "dbo.Table1". I then want to use the stored procedure from .NET/C# in my web application, so that i can create the complete set of usertables for each of my clients.

Now, I tackled the stored procedure part (that is, it creates all the tables I need with all the parameters I want) and am able to use it from my web application (which took some time to learn but proved quite easy to do), but I cannot seem to get it coupled to the current user (instead of the dbo). Every time I trie, the tables are created as dbo.Table1 and when I try to create a new set, it gives a warning ("table with name such and so already exists..."). I made sure to log in as an authenticated user (using forms authentication) before trying to create the tables but this gives the aforementioned result.

What am I doing wrong? I use Visual Web Developer Express, SQL Server 2005 Express and IIS version 5.1

Please help :-D

Greetingz,

DJ Roelfsema

View 6 Replies View Related

Create App By VB.net 2003 And Connect To SQL XE

Jul 18, 2006

Hi ,

Would it be available to connect from VB.net 2003 to SQL Server XE? VB.net 2003 works on .net framework1.1 while SQL XE works on .net framwork 2.0 so i think this couldn't be done!!

is this true?

View 1 Replies View Related

SQL Everywhere - Can't Connect From VS.NET After Create DB W/ Mgmt Studio

Sep 7, 2006

I have created a SQL Everywhere database using SQL Server Management Studio (because I couldn't figure out a way to create it with VisualStudio.NET).

Then, I try to open it in Visual Studio.NET, using the following steps:

Add New Data Source
Pick type Database
Click New Connection
Pick Data Source "<other>", and Data Provider ".NET Framework Data Provider for OLE DB".
Pick OLE DB Provider "Microsoft SQL Server 2005 Everywhere Edition OLE DB Provider for Windows".
Enter a full path to the filename as the Server or File Name. (I've tried it with and without doubling the backslashes in the pathname - no difference.)
Click Advanced and enter the Password that I assigned to the DB.
Click Test Connection - it says it succeeded.
Click OK. It says "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done."

Now what? Thanks.

View 1 Replies View Related

Can Create Login But Cannot Connect (sa Doesn't Even Work Also)

Jan 19, 2006

Hi,

Please direct me to the right forum if this is not the right one.

Upon installation of SQL Server 2005, I opened the SQL Server Management Studio, connected using Windows Authentication and went to the security node in the tree. I created a log in called "TestLogin". I restarted my server just to make sure everything took and when I tried to log in using TestLogin via SQL Server Authentication, I get the below error. I have mixed mode enabled as well as named pipes. I am not sure what the issue is or what to try next. I even get the same error when trying to use "sa".

Thanks,

- Joel

TITLE: Connect to Server
------------------------------

Cannot connect to TestServer.

------------------------------
ADDITIONAL INFORMATION:

A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) (Microsoft SQL Server, Error: 233)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=233&LinkId=20476

------------------------------
BUTTONS:

OK
------------------------------

View 3 Replies View Related

Cannot Connect To Sql Server 2005 From Xp Client When Trying To Create ODBC Dsn

Mar 2, 2007

Newbie here,

I am trying to link tables from an access 2003 frontend to sql server 2005 backend.

I am doing this in a vmware test environment. I am using vmware server and running sbs 2003 and xp sp2 client. Both virtaul machine can talk to each other(using local host connection).

I have tried to create a dsn to the sql server but i cannot connect. I can ping the sbs server through the command interface but the error i get when i try to connect is :

Connection failed:
Sql state: hyt00
sqlserver error: 0
microsoft odbc sql server driver timeout expired.

spent a day trying various combinations - still no joy.

Any help would be much appreciated

View 3 Replies View Related

Two Databases/servers - Can I Connect To Both To Create New Table On One Server?

Nov 20, 2007



Good morning all,

I need to create a new table on a SQL Server 2005 Database, but the data needed for the table is kept in different databases on different servers.

Half the data is on the SQL 2005 database, so that shouldn't be too much of a problem, but the other half is on a SQL Express database on a different server, is it possible to write a T-SQL query to retrieve this data on the other server?

Normally I use a create table + insert into kind of query to create custom tables but I don't know how to connect to the SQL Express server/database using T-SQL (if it's possible at all?) to do this.

Any tips, hints, ideas very welcome. Please use small words and short sentences.

Thanks,

Paul

View 3 Replies View Related

How Can I Connect Tables.

May 27, 2007

Hi,How do i connect tables so they are interrelated to each other. like the asp.net 2.0 membership tables have the "id"  and how can i use that? i have multiple tables that are all connected.like i have a table for profile. and images profile with include their profile, while images will include there avatar.now when i display there profile on page, i need to grab the data from both the profile table and avatar. right now i've been using the "JOIN" statement. but is tehre any other way 

View 6 Replies View Related

How To Basically Copy Tables With New Names Rather Than Create Similar Tables From Similar Manual Input.

May 26, 2007

I have a table that I am basically reduplicating a couple of times for each part of this database that I want to create.Each table basically has the same data: The tables will be called motherTable, fatherTable, sonTable, daughterTable and so on.I am pretty much using the following in each column: UserID, MotherID(or FatherID or SonID, etc., etc. and so on for each unique table), FirstName, LastName, MiddleName, BirthPlace, Photo, Age.I don't see an option to copy a table and just modify the second ID part and rename that table accordingly.How can I make this an easier way of creating these similar tables without retyping all these columns over and over again?Thanks in advance. 

View 4 Replies View Related

Boolean: {[If [table With This Name] Already Exists In [this Sql Database] Then [ Don't Create Another One] Else [create It And Populate It With These Values]}

May 20, 2008

the subject pretty much says it all, I want to be able to do the following in in VB.net code):
 
{[If [table with this name] already exists [in this sql database] then [ don't create another one] else [create it and populate it with these values]}
 
How would I do this?

View 3 Replies View Related

Dynamic Create Table, Create Index Based Upon A Given Database

Jul 20, 2005

Can I dynamically (from a stored procedure) generatea create table script of all tables in a given database (with defaults etc)a create view script of all viewsa create function script of all functionsa create index script of all indexes.(The result will be 4 scripts)Arno de Jong,The Netherlands.

View 1 Replies View Related

Can CREATE DATABASE Or CREATE TABLE Be Wrapped In Transactions?

Jul 20, 2005

I have some code that dynamically creates a database (name is @FullName) andthen creates a table within that database. Is it possible to wrap thesethings into a transaction such that if any one of the following fails, thedatabase "creation" is rolledback. Otherwise, I would try deleting on errordetection, but it could get messy.IF @Error = 0BEGINSET @ExecString = 'CREATE DATABASE ' + @FullNameEXEC sp_executesql @ExecStringSET @Error = @@ErrorENDIF @Error = 0BEGINSET @ExecString = 'CREATE TABLE ' + @FullName + '.[dbo].[Image] ( [ID][int] IDENTITY (1, 1) NOT NULL, [Blob] [image] NULL , [DateAdded] [datetime]NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]'EXEC sp_executesql @ExecStringSET @Error = @@ErrorENDIF @Error = 0BEGINSET @ExecString = 'ALTER TABLE ' + @FullName + '.[dbo].[Image] WITHNOCHECK ADD CONSTRAINT [PK_Image] PRIMARY KEY CLUSTERED ( [ID] ) ON[PRIMARY]'EXEC sp_executesql @ExecStringSET @Error = @@ErrorEND

View 2 Replies View Related

Create Script To Create/Refresh Identical Database

Mar 26, 2008



I'm new to using SSIS and have been reading and learning slowly how to use it. I'm trying to create an identical copy of our database for reporting. I've used the Import/Export wizard, but have had some issues with foreign keys and with sql_variant columns.

I've tried searching for anything but haven't had any luck as of yet. I guess I don't even know where to start or what to look for.

Any help would be appreciated. Thanks!

View 9 Replies View Related

Stored Procodure To Connect 4 Tables

Apr 28, 2006

I have 4 tables connected with one particular Id.
I will explain the table with sample data to make it more clear.
table 1                                                             Table 2
Id(PK)       Firstname   Lastname                   T2Id(PK)   Id(FK)           Pfirstname     Plastname
65                   a                  b                                 22             65                     AA                        BB
                                                                              
Table 3                                                                                    Table 4
 T3Id(PK)     Id(FK)     Firstname Lastname                     T4Id(PK)  Id(FK)   T3Id(FK)  Pfirstname   Plastname
45                  65               c                 d                                       33            65            45            CC                     DD
46                  65               e                 f                                         44            65            46            EE                     FF
I want the output to be
               Firstname          Lastname      Pfirstname       PlastName
                  a                               b               AA                           BB
                  c                              d               CC                              DD
                  e                                f               EE                              FF
I am able to join table3 and table 4 to get the last 2 rows of output but not able to get all three rows by inner join of 4 tables.
 
pls help me
 
 

View 2 Replies View Related

Best Way To Connect MS Access To SQL 2000 Tables?

Oct 5, 2005

Hello All;

I've about read myself to death, and have yet to find the simple answer to the question of what is the best way to connect my MS Access 2003 front-end to an SQL 2000 back-end?

Can anyone answer that simple question?

Grarful for ANY resonse,

Larry.

View 2 Replies View Related







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