|
Member 4125480 wrote: Can you throw some keywords or techniques at me? Is it simply a bad idea to do what I'm talking about doing?
I can throw some mud at you. It is a horrible idea.
Come to think of it, are you by any chance the Lotus Notes architect?
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
modified on Monday, February 8, 2010 7:57 AM
|
|
|
|
|
Member 4125480 wrote: The Question: Is there a standard way of doing this kind of thing? Can you throw some keywords or techniques at me? Is it simply a bad idea to do what I'm talking about doing?
In effect, you'd be storing everything in a list, without type-safety. Using a database would be kinda overkill where a textfile would suffice. A bit of a mean remark, but a database is best suited for relational data
Member 4125480 wrote: or "Color," for which varchar would be the datatype.
I'd expect a color to be a number. You'd best prepare for a lot of conversion-problems, mostly centered around datetime and decimals.I are Troll
|
|
|
|
|
Hi.
i am currently building a project that contains data on a SQL server (2008),
i need to move some data from the server to a portable media (like SDF file or access file), the structure in both are the equal.
at certain queries i will want to query both databases , the server and portable one (so only one who has the portable database on the USB can get true results).
can anyone tel me which format would be the easiest to deal with this? for example is there a format that i can use to attach to the database and create a UNION query that should query the server and the file at once?
is it "healthy" to use a MDF file as the portable database and attach and deattach every time i want to use the database and then create a UNION query to the servers database?
|
|
|
|
|
|
Hello guys, i am using a module.
I want to run a query whenever user updates an article.
Reason is: During article update Fileid becomes FileID under ImageURL column,
and this causes broken image paths for my case.
I want to keep this Fileid thing same whenever an update occurs at database table.
Following trigger works for new entries:
CREATE TRIGGER FileID_replace ON Articles
AFTER INSERT
AS
BEGIN
update Articles set ImageUrl=REPLACE(ImageUrl,'FileID','Fileid') where ArticleID = (select max(ArticleID) as ArticleID from Articles)
END
However i need a one to keep Fileid whenever an update occurs.
Would you please help?
Thank you.
|
|
|
|
|
So create an UPDATE trigger. What difficulties are you having? I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Can you tell me which query to use?
I tried one, but it works for only latest entry. If editing a previous entry, it does not work. Because my query was relying on increase on articleId.
|
|
|
|
|
Maybe you'd like to show what you have tried. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Sure: (I simply changed AFTER CREATE with AFTER UPDATE) But i guess i am missing something.
I tried following:
CREATE TRIGGER FileID_replace ON Articles
AFTER UPDATE
AS
BEGIN
update Articles set ImageUrl=REPLACE(ImageUrl,'FileID','Fileid') where ArticleID = (select max(ArticleID) as ArticleID from Articles)
END
GO
|
|
|
|
|
Of course these queries are only going to work for the last record, that's what you're asking for.
idumlupinar wrote: select max(ArticleID)
If you read the documentation for triggers you will understand. Query the inserted or updated to get the record currently being affected. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Well, i am not a SQL Developer yet, i am trying to learn anyway
Can you share an url that would explain my case clearly?
I reviewed a few resources but i couldn't understand most of them
|
|
|
|
|
Try like this:
DECLARE @MyId VARCHAR(50)
SET @MyId = SELECT ID FROM INSERTED
UPDATE ........ WHERE ID = @MyId Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
Dictionary Table; Records in only 2 lines (for example, a table of sex: male, female) or as much as 40-50 lines and changing of future data in the table Insert / Update / Delete operations possibility of very low.
Combining these tables in a single table, Does it make sense?
For Example;
TBL_Sex
1 Male
2 Female
TBL_WorkType
1 Full-Time
2 Part-Time
TBL_BloodType
1 A Rh(+)
2 B Rh(+)
3 AB Rh(+)
4 0 Rh(-)
5 A Rh(-)
6 B Rh(-)
7 AB Rh(-)
8 0 Rh(-)
Instead of following table;
TBL_DICTIONARY
ID GROUP VALUE
-- ----- -----
1 Sex Erkek
2 Sex Kadın
3 WorkType Yarım Gün
4 WorkType Tam Gün
5 BloodType A Rh(+)
6 BloodType B Rh(+)
7 BloodType AB Rh(+)
8 BloodType 0 Rh(-)
9 BloodType A Rh(-)
10 BloodType B Rh(-)
11 BloodType AB Rh(-)
12 BloodType 0 Rh(-)
|
|
|
|
|
I'd use separate tables for such "enums".
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
So;
Do you use TBL_Sex, TBL_WorkType, TBL_BloodType
or use TBL_DICTIONARY ?
|
|
|
|
|
dataminers wrote: use TBL_Sex, TBL_WorkType, TBL_BloodType
I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
|
|
|
|
|
Using separate tables also allows you to create foreign key references so that you can guarantee that the data in your tables remain consistent.
For example:
Tbl_Patient
ID:
Sex:
Work_type:
Blood_type:
additional fields, blah, blah ...
On this new table,Tbl_Patient, you would create foreign key references to tbl_sex, tbl_worktype, tbl_bloodtype, so that only valid values can be stored in those columns.
Good luck on your project and keep asking questions ... it's the only way to learn.
|
|
|
|
|
Okay, here is what I have done. I went to sql manager and i made my database and all is fine.
I then wanna of course make a program to interface it. So I add linq to sql to my winform
then I take and add the dataconnection. I take and hit sql and i go and find the mdf file that is in the sql server data directory. That seems all fine and dandy.
Then visual studios tells me that it wants to make the files local so I hit yes( should i hit no, cause i wanna use the one that is on the server not local). Anyway I hit yes.
So then I have my tables and I can drag it to the dbml
that seems great. But the problem is when i go to load the dang program it constantly tells me login failed.
so i take and go back to sql manager and the dang database is no longer attached ?
why?
It is making me go in a circle.
I tried to add a connection string for the remote under settings it adds it but i can't select it on dbml for some reason it simply doesn't populate the connection dropdown box.
so i have been trying to do using (var db = mylittledatabase(properties.settings.default.remote)
and that is when i get the whole login issue.
Please help this is driving me nuts.
|
|
|
|
|
tonyonlinux wrote: Then visual studios tells me that it wants to make the files local so I hit yes( should i hit no, cause i wanna use the one that is on the server not local). Anyway I hit yes.
Try and edit your connection string to change the "UserInstance=True" to "UserInstance=False" and see what happens. You maybe copying the db to the output directory every time you run debug and the changes you make are not persisted in the db on the server. Just a guesss. I have been through all these issues many years ago. Just wish I had written everything down.I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
|
|
|
|
|
CREATE PROCEDURE usp_AddBook
--Variables
@Title varchar(200),
@Price decimal(18,2),
@Keywords varchar(200),
@Retired bit
AS
BEGIN
SET NOCOUNT ON
DECLARE @bookId int -- SET A VARIABLE TO HOLD THE BOOKID SQL MAKES
-- INSERT THE BOOK INFORMATION
SELECT @bookId = Book.ID from Book where Book.Title = @Title
IF @bookId = null
BEGIN
INSERT Book(Title,Price,Keywords,Retired)
VALUES
(@Title,@Price,@Keywords,@Retired)
SELECT @bookId = @@IDENTITY; -- SET THE BOOK ID TO THE ID SQL MADE
END
INSERT INTO BookNumber (BookID)
VALUES
(@bookId)
END
From my view It should check to see if the @bookID is null and if it is then do the insert
if its not null then the book already exist and i simply wanna insert the bookID into the booknumber table.
The sql manager keeps telling me I can't pass a null to booknumber.bookID (well yeah its non nullable column, but it shouldn't be getting a null value HELP PLEASE
THANKS!
|
|
|
|
|
Shouldn't that be
IF @bookId IS NULL ?I are Troll
|
|
|
|
|
ha thanks. let me give that a go. i appreciate it! <duh>
|
|
|
|
|
We have been tasked with listing the permissions users have (either by name or by group) on a SQLServer 2005 node. Can anyone provide a script or link to a script to help with this process?
I am cobbling one together from other pieces I've found, but if anyone has a finished product, it would be much appreciated.
Thanks in advance,
Tim
|
|
|
|
|
We have one that reads all the permissions for a database, deletes them and then restores them, used when restoring production over dev/uat databases. It would probably be another cobble but somewhere to start from (Monday at the earliest) Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I m using SQL 2008 express Edition and Management studio after I attach a database to it, when I go to that folder and try to delete that database , it simply get deleted which is not normal because in enterprise edition we have to first detach then then delete...
Can any one tell me that what is the issue, is this due to Express edition or Somethings wrong in installation or others..
THANKS,
|
|
|
|