|
I just found a solution it helped me a lot now. To remove all ""rowguid" column from all table in SQL server which used replication you just run this script "exec sp_removedbreplication" in sql query and then all rowguid column will be deleted.
thanks,
Han
|
|
|
|
|
Hi All,
I am using Table value parameter for bulk insert in my database. So it will be rolling back all the changes even if atleast one row fails. Is there any way that i can find out which row is failed? i hope u are able to understand my question. Can any one help me on this?
Thanks
Lijo
|
|
|
|
|
Hi,
I'm trying to setup a SSIS Package to migrate data between two databases.
There are many tables to migrate, and there are some tables that I cannot/do not want to migrate (i.e. I create the records by hand in the destination database - there are not a lot of records in these particular tables).
An example of the tables I do not want to migrate is the 'Users' table. The primary key of this table is of type GUID. It is used in almost every other table, that I have to migrate, as foreign key. So I have to setup a translation of this GUID.
Of course, for one particular table/data flow I can do the translation with a script component ; but then I have to rewrite the same long code for every other table/data flow.
So I wondered if there could be a way of defining a global transformation method that I could call in each of my script component ; something that would look as below :
public static Guid GetUserGuid(Guid sourceGuid)
{
if (sourceGuid == new Guid("589CD136-4AED-4E3E-A391-DDAE8A790D1B"))
return new Guid("4D0947C1-5746-4DD6-AAFE-5ECB5BACBB9F");
else if (sourceGuid == new Guid("286BCF1A-8CDD-DE11-9EA4-000C29FC4D89"))
return new Guid("05F0CAD9-4095-E011-8ED0-00155D785E00");
}
But I did not find the way to achieve this. I've been searching for three hours without finding some relevant help.
I also thought of setting up a specific database that could provide the matching ; for example :
CREATE TABLE [Users](
[SourceId] [uniqueidentifier] ROWGUIDCOL NOT NULL,
[DestinationId] [uniqueidentifier] NOT NULL
)
But then again I did not find a way to use this matching-table in my transformation process.
Does anyone have some clues about my problem and where I should search for some hints about it ?
|
|
|
|
|
if I use the Seek method with multiple criteria, does Seek use any of the fields to match or all fields must match?
I have an ADODB Recordset. My syntax follows:
Dim cnn As ADODB.Connection
Dim rst As ADODB.RecordSet
'set connection (assume correct)
Set cnn = CurrentProject.Connection
Set rst = New ADODB.Recordset
rst.Open "MyTable", cnn, adOpenKeyset, adLockOptimistic, adCmdTableDirect
'rst.index = "PrimaryKey"
'check if recordset valid - if rst.RecordCount >0
rst.Seek fld_cmpr1 & fld_cmpr2 & fld_cmpr3, adSeekFirstEQ
Does this mean ALL 3 fields must match otherwise Seek result in rst.EOF??
(likewise, if this were DAO and i used rstDAO.Seek "=", fld_cmpr1..... do ALL fields must match?)
Thanks!
JJM
|
|
|
|
|
I think it means that it should concatenate the fields, and search for that.
If you need to specify a value for more than one field, use the VBA Array function to pass those values to the KeyValues argument of the Seek method. If you only need to specify one value, it is not necessary to use the Array function.
Bastard Programmer from Hell
|
|
|
|
|
how to moving column in sql ?
by code ?
|
|
|
|
|
Which database?
MS SQL server from 2005 on - can't be done anymore. They took the ability out.
Other databases...don't know...but a Google for ALTER COLUMN ORDER might bring some up.
|
|
|
|
|
What do you mean "move"? Do you mean move it from one table to another? Or change the order in which the column appears in a query result set? Or change the order in which the column is defined in the table?
|
|
|
|
|
Hi
Thank you for the answer
In your table, not the other table
I mean, is the priority fields
|
|
|
|
|
|
What this command do?
EXEC sp_rename @objname = ‘test.col3_new’, @newname = ‘col3′, @objtype = ‘COLUMN’
Whether the priorities are changed?
This will only change the name?
But I want to change priority
Thanks!
|
|
|
|
|
What do you mean by change priority? Do you mean you want to affect how the result is ordered (in other words, how it is sorted)?
|
|
|
|
|
I have the following tables (I left out fields that don't apply to this question).
Employees, Stores, and Groups. Each employee can belong to one or more Stores, and each Store is in one Group
Employees
EmployeeId Number
Certified DateTime
EmployeeStores
EmployeeStoreId Number
EmployeeId Number
StoreId Number
Stores
StoreId Number
GroupId Number
I need to produce a query that displays the percentage of the Certified field completed in the Employees table by Group. So, assuming Group A, Group B, and Group C, the result set should have:
Group A 13
Group B 42
Group C 21
Other 24
Since I'm very new to Access, I could use some help forming this query.
Thank you
Everything makes sense in someone's mind
|
|
|
|
|
Anyone have any ideas why this won't work? I just want to check whether some fields are not null before I set the value of @UserName
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = Object_ID('[dbo].[__Reporting_GetUserName]')
AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
BEGIN
DROP FUNCTION [dbo].[__Reporting_GetUserName]
END
BEGIN
EXEC dbo.sp_executesql N'
CREATE FUNCTION [dbo].[__Reporting_GetUserName] (@userId int)
RETURNS VARCHAR(MAX)
AS
BEGIN
DECLARE @UserName VARCHAR(MAX)
SET @UserName =
(
IF [FirstName] is not null
BEGIN
SELECT [FirstName] + '' '' + [LastName]
FROM __User
WHERE Id = @userId
END
)
RETURN @UserName
END
'
END
|
|
|
|
|
Why not use a CASE?
SELECT CASE WHEN [FirstName] is not null THEN [FirstName] + '' '' + [LastName] ELSE null END FROM __User WHERE Id = @userId
(Or something.)
|
|
|
|
|
Etienne_123 wrote: Anyone have any ideas why this won't work?
What would it fill the variable with if FirstName does equall null? You'd better assign it directly without the IF statement, and use the <a href="http://msdn.microsoft.com/en-us/library/ms184325.aspx">ISNULL</a>[<a href="http://msdn.microsoft.com/en-us/library/ms184325.aspx" target="_blank" title="New Window">^</a>] function.
Bastard Programmer from Hell
|
|
|
|
|
I am working on a simple game where you take creatures into battle and they fight against each other. Everything is working fine minus figuring out the best way to store the results.
I want something similar to this data structure.
int ID (identity)
int AttackerID
int DefenderID
int AttackerCreatureID1
int AttackerCreatureID2
int AttackerCreatureID3
int DefenderCreatureID1
int DefenderCreatureID2
int DefenderCreatureID3
and then more for the creatures that died, ect
The problem is, I want the characters to be able to buy more battle slots and bring more into battle at a time. So, say they know can bring 5 creatures in, I don't want to have to make a bunch of new columns. Using XML this exercise would be pretty easy since you can just add a couple extra tags here and there whenever you want.
Like:
<AttackerCreatures>
<Creature>
<ID>12</ID>
</Creature>
<Creature>
<ID>12</ID>
</Creature>
<Creature>
<ID>12</ID>
</Creature>
</AttackerCreatures>
I've done lots of work with SQL before but never come across doing something like this with variable amounts of data column wise...
Any help would be awesome! Thanks ahead of time.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
You could try this:
Procedure with following params
int ID (identity)
int AttackerID
int DefenderID
NVARCHAR AttackerCreatureIDs (this would be comma separated ids)
NVARCHAR DefenderCreatureIDs (this would be comma separated ids)
then in your proc, split the Ids string
the below function could be used
CREATE FUNCTION [dbo].[Split]
(
@List nvarchar(2000),
@SplitOn nvarchar(5)
)
RETURNS @RtnValue table
(
Id int identity(1,1),
Value nvarchar(100)
)
AS
BEGIN
While (Charindex(@SplitOn,@List)>0)
Begin
Insert Into @RtnValue (value)
Select
Value = ltrim(rtrim(Substring(@List,1,Charindex(@SplitOn,@List)-1)))
Set @List = Substring(@List,Charindex(@SplitOn,@List)+len(@SplitOn),len(@List))
End
Insert Into @RtnValue (Value)
Select Value = ltrim(rtrim(@List))
Return
END
GO
|
|
|
|
|
I thought about doing that but it feels dirty, doesn't feel very relational databaseish...
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
It looks to me as if you've got a many to many relationship there. A battle joins many attackers to many defenders. So you would have a table Battles which has a unique BattleId, plus AttackerId and DefenderId plus whatever other information you want to hold against a battle (date, location, whatever).
Then you have a number of options. One option would be to have an Attackers table which holds BattleId and CreatureId for all the attackers, and another table Defenders which holds BattleId and CreatureId for all the defenders. Or another option would be to have just one table BattleCreatures which holds BattleId, ArmyId and CreatureId where ArmyId is either the AttackerId or the DefenderId depending which side the creature is on.
Whether you separate out Attackers from Defenders into two separate tables or whether you have them all together in one table is a bit of a judgement call. There are arguments for and against both options.
|
|
|
|
|
i have two tables
ROOM(nbROOM primary key) : ML002
STUDENT(nbROOM) : ML002
How can i change the ROOM(nbROMM) : ML002 => ML003
=========> the STUDENT(nbROOM) must also change : ML002 =>ML003 ?
|
|
|
|
|
Simple - you can't.
The first problem is that you are using business data for keys. And you now know why that is a problem.
Your only solution now requires.
1. Create a new room row with ML003
2. Update STUDENT to point to MLO03.
3. Delete the existing ML002 record.
Second problem is that what you are doing isn't logical anyways. If you have a list of rooms you don't change them unless you are in fact relabeling all of the rooms themselves (ie someone is going down the hallway in the school and putting new numbers on the doors.)
In contrast if a person is assigned to the wrong room or needs to be moved then you update the person, not the room, to indicate the change. (In databases in general there is another way to do this but it wouldn't apply to room assignment.)
Your solution should be
ROOM(primary key, room label): {1, ML002}, {2, ML003}
STUDENT(room primary key): {1}
In the above you would just update '1' in the student record to be a '2'
|
|
|
|
|
^^~ u didn't understand my problem
ROOM(nuROOM primary key, nameROOM)
STUDENT(nuSTUDENT primary key,nameSTUDENT,nuROOM)
this is my database !
|
|
|
|
|
What JSchell is saying is that your database is designed WRONG and you should fix it before you get into even more trouble. Whats more he gave you the ideas of how to fix it.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
lyngocquy wrote: u didn't understand my problem
No you don't understand my reply.
1. Your database design is wrong.
2. This problem is a specific example of why it is wrong.
3. I told you how to do the update with your existing design.
|
|
|
|