|
It should be an insert statement
Insert into [Instance1].targetDB.dbo.TargetTable
select * from [Instance2].SourceDB.dbo.SourceTable
Hope that helps.
Ben
|
|
|
|
|
the problem is, how do I specify the Instances because "[Instance2].SourceDB.dbo.SourceTable" doesn't work. It has too many qualifiers.
I think I add a linked server on my side. But how do I specify in one line which instance to use?
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
Your [Instance2] includes the sqlserver name right?
You know it might just be easier to DTS the table that is the way I do most of my table moving. Then you don't need to worry about link servers or any of that.
It is the Import export Data. If you have access to sql server 2005 management studio, you go to the database you want to export a table from right click -> tasks -> export data.
Then you just need to enter your destination sql server and database. Then select the table you want to copy.
Hope that helps.
Ben
|
|
|
|
|
You need to link the two instances together before you can do that. See: sp_addlinkedserver in the books online.
|
|
|
|
|
Hi
What is the best way to manage the user logins in the database for a school information system where there are students, teachers, system administrators, etc. Would you have separate tables for students, teachers and administrators, each with columns for username and password or one Users table with all the info including usernames and passwords? The problem is then that teachers and students may have different information that is captured for the database.
Kobus
|
|
|
|
|
kbalias wrote: Would you have separate tables for students, teachers and administrators, each with columns for username and password or one Users table with all the info including usernames and passwords?
I prefer to use single table with all info
kbalias wrote: The problem is then that teachers and students may have different information that is captured for the database.
Add one column in the user table for identifying the user type. It can be something like user_type and store the user type in that colunmn
|
|
|
|
|
I would normalise that out a bit more, and have a role table with the user table having a foreign key to the role table. By doing this, you can associate permissions to roles so you could have a student being able to view an item, and a teacher being able to view or edit it.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
First at the DB security level you create roles of student, teacher, sysAdmin
Next you create only one user table and define your users.
Finally you bind each user to a specific role and use permissions to define the CRUD for each role.
|
|
|
|
|
hi,
anyone any idea if there is some SQL syntax for converting an integer to hexadecimal ?
Thx
Kurt
|
|
|
|
|
i've found HEX in the books online but seems that it isn't available in SQL2005...
but i've found this (ofcourse microsoft undocumented) one :
DECLARE @x BINARY(16) ( or int if you please)
SET @x = 255
SELECT master.dbo.fn_varbintohexstr(@x)
greetz...
|
|
|
|
|
SQL Server is not designed to present data. It is designed to store and retrieve data efficiently.
If you need to show integers in hexadecimal in your application, make the client-side application do it. The same goes for things like string concatenation.
|
|
|
|
|
That's true,
but the (my concept) SQl server needs to prepare some things so the (dum and transparant) applications just need to pickup data end send it to hardware...
if the hardware gets a firmware update we don't need to replace all the applications, we only need to modify one stored proc.. so easy to maintain..
the apps are installed on embeddeds also so we don't want them to do a lot of time absorbing work.
ofcours we can also use services on the server who can do the work but that takes a lot of extra work and my experience is that MSSQL is very powerfull en can handle those things without any problems..
but i guess this is my opinion..ofcourse any suggestions or better concepts to do this are very welcome..
Thx..
Kurt
|
|
|
|
|
So why are stored procedures, views and functions implemented in MSSQL then ?
i solve things this way :
insert into A
select fielda, fieldb, LEFT(fieldc, 50) from B Where fieldd = 1
i suppose retrieve all the 50.000 records to a service truncate the string in the client app and sending 50.000 update records from a client app to your MSSQL server is taking more time then this query...
greetz..
tell me if i'm wrong.
|
|
|
|
|
I am new to reports so might this question seamed stupid ... I am using Report Application Sever .I create a table and populate all the data required.Now I want to create a cross-tab (pivot table) instead and embed a report within the cell of cross-tab ... is it possible ?
Best Regards,
Madni
|
|
|
|
|
hi ,
i have created views in database Test, in sqlServer.when i had to import Test to another database Test1, the views become hiddden.
i can't see the views and when i try to create them again, i get this msg:
There is already an object named 'view1' in the database.
so how can i resolve this problem?
thanks,
|
|
|
|
|
Hi,
check whether the views are converted to tables.
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
Hello,
I have a table with a primary key on Serial No. I need to add a new column called softwareID and set that to the new primary Key.
It is possible to write some sql what will remove the PK from Serial No, and set the softwareID as the new PK?
I was thinking about dropping the table and creating a new one, but I don't want to lose the data.
Many thanks,
Steve
|
|
|
|
|
|
Hello,
I have a sql 2005 server database and using .Net 2005.
The client has a database when contains all there business data. In the currently I have been making changes to the schema i.e. creating new table, altering procedures, etc. All these has been done by writing the scrips and when the program installs it will execute these scripts. The customer gets an update every few months.
However, the updates are becoming more and more frequent and also becoming more complex and sometimes difficult to keep track of all the table's schema.
Is it possible to send them a backup so that they can restore it with all the changes I have made to the schema without destroying all their data?
Is there any software that can be used to automate this process?
What could make this difficult as we are in different offices. Development office and the customer's office in different countries.
Many thanks for any advice,
|
|
|
|
|
Try using Red-Gate SQL compare. You can use it to compare both schema and data and it can be automated using .Net scripts. The best thing to do would be to keep a backup of the schema for each series of updates. When you make a new release, create a backup. Then the next time you need to release a new set of changes, restore the last backup to a place where you can run SQL compare to generate the change scripts. Then you can send those scripts with your update to the customer.
|
|
|
|
|
hi,
Everyone know this error? the database has been placed in state by user "Admin"!
We are using a shared database in access databases. When more than one user has connect to my databases by my application (my program developed by vb.net) at the same time, the following error message appears. "The
database has been placed in a state by user 'Admin' on machine XXXXX that
prevents it from being opened or locked."
* Although i already add the "Persist Security Info=False;Mode=Share Deny None" in my OleDbConnection, it still got same error!
How to solve this error? please help!
My following code as below:
Try
DB = New OleDbConnection("Provider=microsoft.jet.oledb.4.0; data source=C:\prdsystem\prdnsf.mdb; Persist Security Info=False;Mode=Share Deny None")
DB.Open()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "")
End
End Try
Da = New OleDb.OleDbDataAdapter(sql, DB)
Ds = New DataSet
Da.Fill(Ds, "emp")
|
|
|
|
|
I'm trying to create a SqlDbType.SmallDateTime parameter and have been unable to find the correct answer.
I'm trying to take a date in mm/dd/yyyy format from a text box and pass it to a stored procedure.
This is about as close I have got but it still doesnt work:
SelectCommand.Parameters.Add("@dateofbirth", SqlDbType.SmallDateTime).Value = DateTime.Parse(StoredProcedureValues[3]).ToShortDateString();
Does anyone know what the answer is ?
Thanks
|
|
|
|
|
When you are adding a datetime value of any sort to a database leave it in a date, I mean DATE, format if possible. Otherwise you must format it correctly to insert. So ensure that the value you are parsing to DateTime is a date value and dont set it to short date string.
SmallDateTime is about precision not how it looks in the DB[^]
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
hi every one,
well I've set up transactional replication here and the problem is that when I try to insert a new record at the subscriber it gives me an error that the primary key is being dupicated. I have the NOT FOR REPLICATION Option for the ideantity column but its not working..
can u plz help me
thanks in advance
Rocky
|
|
|
|
|
Hello EveryBody
I got 2 Table Customer and Order
Customer Table got two column CustomerID, CustomerName
Order Table got Two Column OrderID, ProductID
CustomerTable:
CustomerID CustomerName
101 James
102 Andy
103 Bryan
OrderTable:
OrderID ProductID CustomerID
1001 10001 101
1002 10002 101
1003 10003 101
1004 10004 102
1005 10005 102
1006 10006 103
I want the output as below
CustomerID CustomerName OrderID ProductID
101 James 1001,1002,1003 10001,10002,10003
102 Andy 1004,1004 10004,10005
103 Bryan 1006 10006
Please help me.
Thanks
Sarfarj Ahmed
|
|
|
|