|
Dmitry Khudorozhkov wrote: First question: is this a good db structure?
No, you need a primary key on the address table AddressID INT Auto increment. You also need a foreign key between User and address. This means you need to put the userID (currently the ID field on the user table) on the address table.
Then to get the address for a user something like
Select *
From Users
inner join Addresses on Addresses.UserID = User.ID
where Users.ID = @IDno
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks a lot Mycroft.
Listen up! "Teamwork" means staying out of my way! (Seifer, Final Fantasy 8).
|
|
|
|
|
What is a good query to execute to see if the account you are logged in as has sysadmin rights?
modified on Tuesday, December 22, 2009 1:48 PM
|
|
|
|
|
Are you talking about South Africa or South America?
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Modified original message.
|
|
|
|
|
Try dropping the databases. If you succeed it means that you have more permission then you need.
|
|
|
|
|
|
Found this handy function IS_SRVROLEMEMBER ( 'role' [ , 'login' ] ). It will return either or a 1 or 0.
ex. SELECT IS_SRVROLEMEMBER( 'sysadmin', 'user_name' )
Problem solved.
|
|
|
|
|
Which is best datatype used in sqlserver2008...to store IList<string> C#.
|
|
|
|
|
|
You could try xml also (sql 2005 and later i believe), its serializable and shouldn't be to difficult, but a table is the best way like the first response.
|
|
|
|
|
I'd like to be able to see if credentials (server/instance, username/password or win authentication) specified by an administrator are actually able to connect to a database at my application installation time. I'm using WISE if that matters at all. How can I go about accomplishing this? Can it be done with something like osql.exe??
|
|
|
|
|
Yes, you can test your credentials. Execute a command like select count(*) from myTable and redirect the output to a file, then parse the file for the expected results and if there is no error you have validated that your username/password combination is correct.
Do this through osql.
|
|
|
|
|
Hi,
I have configured 2 SQL Server 2005 instances to replicate using Merge Replication. This is just a test environment at the moment, therefore both instances are on different servers but within the same domain and both running under the same administrator accounts.
The replication seems to run smoothly in that the snapshot agent runs successfully and then the subscriber synchronises with no errors. But, when I run my app on the subscriber I get a error when trying to perform a particular task:
Invalid object name 'dbo.MSmerge_genvw_5A046C944AD94C85AA554B95189A5399'.
The said task is calling a stored procedure which I have defined and which I can see has been replicated to the subscriber. I am new to replication so not entirely sure what is going on. Any help would be greatly appreciated.
Also, it may be worth pointing out that the subscriber is an express version, therefore all agents are running on the publisher.
Thanks.
|
|
|
|
|
Just in case anyone is interested, I solved the problem by replacing the SQL Express Server with the full version. All seems to be working correctly now.
|
|
|
|
|
Hi all,
I created a table in which there r n fields and in that two of them are date field i.e., startdate and enddate.
Now i want to write a query,to fetch the records from table which comes under startdate and enddate.
so,i need a help how to write the query.
Thanks in advance.
|
|
|
|
|
What you did so far? Have you try to write a query?
As I could understood you then query should be like:
select startdate,enddate from mytable where startdate >'2009.12.01' and enddate > '2009.12.22'
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
Try this
declare @t table(somevalue varchar(100),startdate datetime, enddate datetime)
insert into @t
select 'somevalue1','01/14/2009', '01/20/2009' union all
select 'somevalue2','01/15/2009', '01/22/2009' union all
select 'somevalue3','01/18/2009', '01/31/2009' union all
select 'somevalue4','02/01/2009', '02/10/2009' union all
select 'somevalue5','05/14/2009', '05/20/2009'
I want to get the records where between '01/14/2009' and '02/01/2009' (inclusive)
Query:
select * from @t
where startdate >='01/14/2009' and enddate <='02/01/2009'
Output:
somevalue startdate enddate
somevalue1 2009-01-14 00:00:00.000 2009-01-20 00:00:00.000
somevalue2 2009-01-15 00:00:00.000 2009-01-22 00:00:00.000
somevalue3 2009-01-18 00:00:00.000 2009-01-31 00:00:00.000
Niladri Biswas
|
|
|
|
|
i m using this stored procedure
CREATE PROCEDURE [dbo].[sp_db_restore]
@DBName varchar(60),
@BackName varchar(120),
@DataName varchar(60),
@DataFileName varchar(120),
@LogName varchar(60),
@LogFileName varchar(120)
AS
RESTORE DATABASE @DBName FROM
DISK = @BackName WITH MOVE @DataName TO
@DataFileName ,
MOVE @LogName TO @LogFileName,
REPLACE
it gives the following error
"RESTORE cannot process database 'databasename' because it is in use by this session. It is recommended that the master database be used when performing this operation.
RESTORE DATABASE is terminating abnormally."
plz help with any solution
Regards
Narendra Singh
(Jindal Tech Ventures)
|
|
|
|
|
I think the error says it all. It seems you are trying to run the stored proc in the database you are restoring, which obviously you can't
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
hey ashfield thanks for reply
i found the answer
before running restore command i have to use any other databse to make the restoring database free. After that when we run restore commands it works great.
Thanks for all ur replies
Regards
Narendra Singh
(Jindal Tech Ventures)
|
|
|
|
|
i usually have to Sp that Closes the Connection before i do a Back or Restore.
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[sp_ClearDatabaseConnections]
@DBNAME VARCHAR(255)
AS
SET NOCOUNT ON
DECLARE @SPID INT, @STR VARCHAR(255)
DECLARE USERS CURSOR FOR
SELECT SPID
FROM MASTER..SYSPROCESSES
WHERE DB_NAME(DBID) = @DBNAME
OPEN USERS
FETCH NEXT FROM USERS INTO @SPID
WHILE @@FETCH_STATUS <> -1
BEGIN
IF @@FETCH_STATUS = 0
BEGIN
SET @STR = 'KILL ' + CONVERT(VARCHAR, @SPID)
EXEC (@STR)
END
FETCH NEXT FROM USERS INTO @SPID
END
DEALLOCATE USERS
as you can see it accept the name of the DB that you want to Restore.
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
thanks for your reply
good code
Regards
Narendra Singh
(Jindal Tech Ventures)
|
|
|
|
|
You are Welcome
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
i have database of sql
in User table there is field which contain encrypted password
this database is using with an application. so i know the string using which these passwords are encrypt so please can any one help me how can i get that passwords.
Regrads
|
|
|
|