|
This is an extremely simple query that is well documented. Have you even attempted to look? I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Look at the
BETWEEN keyword.
As Mark said, this is very basic T-SQL. What have you researched?I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
|
|
|
|
|
Just one more think that i would like to add is the datatype/format of your datetime variables, you may need to convert. 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.
|
|
|
|
|
Hi All,
I'm looking to be able to predefine a particular user input as String, Int, or Dec (maybe others), as the particular case may be.
The available datatypes are stored in a table, associated with the property (see below) that they apply to.
When the user submits the filled in textbox, that entry will be put in a table column, probably as a varchar, and converted as needed, to or from the appropriate datatypes as predefined.
For example, the textbox may be asking for the property of "Length," for which "Dec" is the predefined datatype. Or, the textbox may be asking for the property "Count," for which INT would be the datatype, or "Color," for which varchar would be the datatype. A single column will store all of the results, no matter which kind of datatype is actually involved.
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?
|
|
|
|
|
Member 4125480 wrote: Is it simply a bad idea to do what I'm talking about doing?
Yes.
You could store the values as string (VARCHAR) and convert as necessary, but this is frought with dangers and misuses. Another option may be use a UDT, user defined type. Or possible use an xml column and store value and data type information. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I looked up UDTs today, and one thing that has come up is that they aren't supported in Azure, which is somewhat part of the long term plan.
|
|
|
|
|
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
|
|
|
|