|
If 'C' is constant or it is positional you can use substring to identify the following #n characters and isolate them into a variable. Then just include it in your insert.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi friends
Has anyone done a db for a multi-level compensation structure? I'm talking about a company that is MLM or a multi-level marketing network. Where distributors sign up under other distributors and the "downline" can go down many levels(but limited levels!). I need a sample MLM structure.Could anybody help me please.
Thank You
http://tutorialcode.blogspot.com/
|
|
|
|
|
wajans wrote: Has anyone done a db for a multi-level compensation structure?
Yes, lots of people
wajans wrote: I need a sample MLM structure
Think in terms of parent/child relationships, that should get you going in the right direction.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Hello.
I am a total newbie to SQL Server, having worked extensively on MS Access and VB 6.0 only. But now i have upgraded to Visual studio 2008 and have slowly started to update myself on the new platform. I have SQL Server 2005 and I i know how to create tables and database files. But I don't have any clue whatsoever as to how to deploy/migrate the database that I have created as on a server whose address I can reference by its IP address.
Could someone help me or point me out to good articles or links to PDF's where I might find step by step instructions? By the way, my next project is a web application in ASP.Net.
Thanks and regards,
Kumar.
|
|
|
|
|
Backup and Restore is the best option. Back your db up, copy the file to the server and restore it from there. Job done.
In many places they use something like LiteSpeed or Red Gate's SqlBackup for this.
Regards,
Rob Philpott.
|
|
|
|
|
I'm new to sqlite and a novice at sql in general. I have a sqlite 3.1 database that I would like to edit. I have used several browsers/editors but seem to be running into a small problem.
It seems that the varchar fields are terminated by what I thing is a NULL,it looks like a small box with 00 00 inside, close to this but not quite ->.
Any select or update statement I run comes up blank because I can not reproduce that char.
Something Like:
UPDATE table SET field = 'text' WHERE field = 'text';
but with the correct termination on the field.
Thanks in advance for any help.
|
|
|
|
|
Sounds like you have some unicode in your data. You may want to try LIKE in your where clause but you are going to have to look into your data source and identify the crappy char and deal with it on the way in.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thats what I was thinking but I don't have any way to modify the data source. The LIKE will work to query data just fine but when I need to update the field, the source program will not read the data correctly. It seems to look for the terminator to separate each varchar field. If it is not there, the data from the next varchar field is mixed in with the first when displayed.
If I use a browser such as Sqliteman I can copy and paste the data just fine including the terminator but if I try it with an update statement it breaks down. Not going to update each line one at a time for 2000 fields lol.
If I use the SQlite manager plug-in for Firefox and copy/paste the update statement in sql as it should be, it drops everything after the terminator.
If I can use SQliteman to do a record at a time I would think there should be a way to include it in an UPDATE statement.
Thanks
|
|
|
|
|
You have a table with 2000 fields
I see some empirical testing coming your way.
Get the incriminating char into a variable using select & substring
loop through each record/field and do a replace on the variable value (you do not need to know it's value)
you still have a problem with crappy data getting into your DB!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi All,
I have a problem that when I going to create new package in SQL Server DTS package the enterprise window closed automatically, even when I open my previous package same problem is occurred.
I can not restore msdb database..
Please help me out
Thanks
Rajesh
|
|
|
|
|
I spent hours trying to get a Starter Kit from asp.net to install and run - well, most of two days anyway - and I finally got it to load in VS2008. I don't quite recall how; I tried everything I could find on the Internet, everything I knew 'should' work, and quite a few things that just seemed like they ought to work. I finally got it working, but I haven't a clue which combinations of bizarre workarounds finally did the trick.
Anyway, per the instructions on the help page I pressed ctrl-F5 to build and run the project, which was supposed to create the database in the default SQL Server 2005 server on this machine. There is a permissions error, in that user instances are not enabled. Searching for this led to the clue - run aspnet_regsql. It doesn't exist on my machine. Another, more specific clue was to run sp_configure 'user instances enabled' but there was no information about where to do that. SQL Server 2005 doesn't come with a GUI interface, or documentation. I found the download for the Management Console tool and installed it - works like a charm. Except that executing the stored procedure above returns 'command completed successfully', and displays the result that user instances are indeed enabled up to a limit of 1. The project still reports that user instances are not enabled, however, and will not run.
The package also included a set of queries to manually add the database, so I copied them into the management console Query window and executed them. Again, the result was a success, except that there is no database present.
What's the trick here? Or is this all just an elaborate scheme to finally push me over the edge?
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
I using access database for some application that i wrote in C# ( using ADO.NET). I update some values in my table - and i getting the information from the same table in same thread - ( i have only one thread in my application ) and i see that the values are not right and not update correctly.
How can i know if the data was update already ?
How to avoid this update delay ?
Is there some option to get some event ( some trap ) when the database table update done ??
|
|
|
|
|
Hi,
Running SQL server 2000 and working on a store procedure.
Basically, I need to get the tbPayRate id in order to insert into another table but having several payrate tables for different tasks and it means @table varies. But got an error that I must declare the variable '@table'. Does anyone know how to get round this issue?
DECLARE @table varchar(30)
SET @table='tbPayRate'
SELECT MAX(id) AS id FROM @table WHERE employee=5
Thanks,
Joe
|
|
|
|
|
unfortunately you can not use variables for table names in sql statement. The work around is as follows
declare @sql varchar(255)
decalre @table varchar(30)
set @table = 'tbPayRate'
set @sql = 'SELECT MAX(id) AS id FROM ' + @table + 'WHERE employee=5'
Now that you constructed your sql statement dynamically, you can execute it
Exec(@sql)
will do it
|
|
|
|
|
You must use a schema or database name to differentiate
the different table E.g schemaname.tbPayRate or Databasename.SchemaName.Tablename
you First declare a variable
and set the what u r select to the
value of the variable as shown below
Declare @tbPayRateID varchar(50)
set @tbPayRateID = (Select MAX(id) AS ID FROM schemaname.tbPayRate
Where Employee = 5
Try this out
|
|
|
|
|
Hi,
I am in Urgent need of query. I have 4 tables:
MeterSettings
MadeByID ConsumerTypeID AllocatedPowerID MeterID Date
1 2 3 22 5/11/2009
1 1 23
MeterMadeBy
ID Company TimeInterval
1 L&T 5
2 ABB 10
3 Rishab 15
ConsumerType
ID Type TimeInterval
1 SSI 5
2 MSI 20
3 LSI 30
PowerSanctioned
ID Power TimeInterval
1 5kw-10kw 5
2 10kw-15kw 10
3 15kw-20kw 20
4 25kw-30kw 25
now the requirement is I have to get MeterIds and corresponding Time Intervals in the following manner
if a Meter is having value for MadeByID in MeterSettings then we have to get TimeInterval of corresponding Meter.otherwise get the TimeInterval of
the meter based on value of ConsumerType. Otherwise go for PowerSanctioned.
I can't use Stored Procedures for this. The only option is query
|
|
|
|
|
Create a OUTER JOIN with all four answers and then use application logic to pick the correct one.
|
|
|
|
|
select MS.MadeByID, CT.TimeInterval, PS.TimeInterval
From MeterSettings AS MS INNER JOIN
ConsumerType AS CT
ON MS.ConsumerTypeID = CT.ID
INNER JOIN PowerSanctioned AS PS
ON MS.AllocatedPowerID = PS.ID
WHERE MeterID = enter meterID
This should be able to select
the MadeByID from the
MeterSettings table,
check and fetch the TimeInterval
with the same ID From ConsumerType table
and finally gets the TimeInterval
From the power sanction table
REad More on Joins
Jondo
|
|
|
|
|
select MS.MadeByID, CT.TimeInterval, PS.TimeInterval
From MeterSettings AS MS INNER JOIN
ConsumerType AS CT
ON MS.ConsumerTypeID = CT.ID
INNER JOIN PowerSanctioned AS PS
ON MS.AllocatedPowerID = PS.ID
WHERE MeterID = enter meterID
This should be able to select
the MadeByID from the
MeterSettings table,
check and fetch the TimeInterval
with the same ID From ConsumerType table
and finally gets the TimeInterval
From the power sanction table
|
|
|
|
|
|
How is this a database question? The answer is, name@domain, the same as all email addresses.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
hello sir,
i am new to sql and my problem is that how to find records having two selection criteria
for example
i have a table headname and month
Headname month fees
exam fee jan 100
tution fee jan 120
water fee feb 100
games fee march 50
now how can i select row having month=jan,feb and calculate the fees according to headname
thanks in advance
|
|
|
|
|
Hi,
the WHERE clause supports logic operators AND, OR, NOT as well as parentheses, so you could do things like
SELECT ... FROM ... WHERE (field1='jan' OR field1='feb') AND NOT field2=12 ORDER BY ...
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
thanks for reply
i have done this by
select headname,frequency,sum(c1) from feeshead where months in('jan','feb','march')group by headname,frequency
|
|
|
|
|
Select SUM(fees) FROM TABLENAME
WHERE headname = 'jan' OR 'feb' OR 'march'
NOTE: The (fees) in the query
is the name of the column and
the "TABLENAME" should be replaced
with the table you want to perform
de query on.
NOTE ALSO: that SQL SERver is not case
sensitive
Jondo
|
|
|
|