|
I have a stored procedure that returns the max. number of publication views by author. I will not pass the author name, my stored procedure will select the top 1 like here.
SELECT DISTINCT TOP 1
dbo.FnGetNoOfPublicationViewsByAuthor(C.CUSTOM2) AS 'TotalPublicationsViews',
C.CUSTOM2 AS 'Author'
FROM HDS_CUSTOM C
GROUP BY C.CUSTOM2
I want to get the value of this Author seperately to use in other select statements in the same SP. how can I get it. Is there possibility?
Thanks.
|
|
|
|
|
<br />
DECLARE @TotalPublicationsViews AS VarChar(100)<br />
DECLARE @Author AS VarChar(100)<br />
<br />
SELECT DISTINCT TOP 1<br />
@TotalPublicationsViews = dbo.FnGetNoOfPublicationViewsByAuthor(C.CUSTOM2),<br />
@Author = C.CUSTOM2 <br />
FROM HDS_CUSTOM C <br />
GROUP BY C.CUSTOM2<br />
<br />
SELECT @TotalPublicationsViews, @Author<br />
Declare variables as per their respective DataTypes
Regards
KP
|
|
|
|
|
hi friends
How to disable password complexity check while creating a new user.here I am getting the error message " The password does not meet Windows policy requirements because it is not complex enough".I want to disable this check.I used the script "EXEC dbo.sp_grantdbaccess @loginame = N'name', @name_in_db = N'name'" for creating user.
Thanks in advance
thomas
|
|
|
|
|
You can't disable it. This is a policy that is enforced on either the server (the entire Windows server) or domain wide, not just SQL Server. There is no way to disable this policy just to add a user and turn it back on.
|
|
|
|
|
Hi, I am getting a problem with my MySQL 5 database table while inserting a row which is having a primary key of two fields (A,B).
<br />
A=INTEGER<br />
B=AUTOINCREMENT FIELD<br />
PRIMARY KEY(A,B)
B is having maximum entry of 561629 (checked by query SELECT MAX(B) FROM TABLE1 .
Whenever i used to insert next entry into data table with any integer value for A.
It is showing error "DUPLICATE ENTRY '232-561630'
But this type of entry is not shown with the query
SELECT * FROM TABLE WHERE B=561630
which is not already exit.
Is there a problem with my db server or anything else..?
|
|
|
|
|
I am not dead sure, but the problem *may* have something to do with MYSQL as well (people around here do not use a lot of MYSQL). Have you tried asking it in the MySql forums[^]?
Besides that, we have a separate site for MYSQL[^]now.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
You need to increment the value of B after using it
The Developer is right all the time
No Fear The Developer is Here
|
|
|
|
|
currently i m using sql server 2000.
my column consist of mixture of country values.
i need to take the count of each countries.
example....
colA : india,japan,india,china,japan,USA,india,singapore,china,india
the output should be.....
india japan china USA singapore
4 2 2 1 1
how to achieve it? - KARAN
|
|
|
|
|
SELECT ColA, Count(*) <br />
FROM TblA <br />
GROUP BY ColA
Regards
KP
|
|
|
|
|
thx dude!
|
|
|
|
|
This will not actuall give the required results. The original question wanted
india japan china USA singapore
4 2 2 1 1
This will give
india 4
japan 2
china 2
USA 1
singapore 1
You actually need to pivot the data.
This code should show you how to do it
<br />
<br />
create table #b1(cola varchar(20))<br />
<br />
insert into #b1<br />
select 'India'<br />
union all<br />
select 'USA'<br />
union all<br />
select 'India'<br />
union all<br />
select 'UK'<br />
<br />
<br />
<br />
<br />
<br />
DECLARE @SQL nvarchar(4000)<br />
SET @SQL='' <br />
<br />
SELECT @SQL= @SQL +<br />
'SUM(CASE WHEN cola=''' + a.cola + ''' THEN 1 ELSE 0 END) AS [' + a.cola + '],'<br />
FROM (select distinct cola from #b1) as a<br />
<br />
select @SQL = left(@SQL,len(@SQL)-1)<br />
<br />
SET @SQL='SELECT ' + @SQL + ' FROM #b1'<br />
EXEC(@SQL)
Hope this helps
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi,
Im having two tables in sql server 2000 with same structure in first table if the current sysdate is equal to first table BDate column value means the first table that current sysdate record should be automatically insert to the second table,How can i acheive this one..any suggestions...
First Table:
---------------
Name BDate Content
-------------------------------
Kanna 12/5/2008 Hapy birthday
Second Table:
--------------
Name BDate Content
-------------------------------
Regards
Kanna
|
|
|
|
|
Create a job to fetch all rows from first table that matches to the current date and copies to second table
Schedule the job to execute daily
Regards
KP
|
|
|
|
|
Thanks for ur reply how should i create job.. im new to this concept..can u give me the example code???
regards
Kanna
|
|
|
|
|
From SQL Enterprise Manager, select your server instance and go to
Management -> SQL Server Agent -> Jobs
right click "New Job"
write your SQL query under "step"
then schedule the job
Regards
KP
|
|
|
|
|
Hi everyone,
Does anyone know of an easy way or trick to switch between System.Data.OracleClient and System.Data.SqlClient (and later MySQL's .NET Connector)? I want to give the user the choice of database to use without writing the same database code twice - once for each type of database.
I appreciate all comments or ideas. Thanks!
|
|
|
|
|
Why not use the OleDB classes, which should work for all of those but will be optimised for none ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: OleDB classes
I heard oledb and odbc adds an extra processing to the communication and makes it slow. What do you think ?
|
|
|
|
|
I doubt that, I suspect it just means a standard ODBC connection is used instead of an optimised one. But, if he wants to change DBs, then that seems like a simple way to do it.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Ignorance would be the reason.
Thanks a lot!
|
|
|
|
|
Classes like SQLConnection ,OracleConnection and MySQLConnection (.NET connector) are derived from abstract DbConnection class. All the command classes are derived from DbCommand class. So if your data layer uses these and uses a provider model, changing data store would be easy. Colin has written something here[^] which is worth reading.
|
|
|
|
|
Thanks for that and the link.
|
|
|
|
|
I am using the 2005 Edition and I couldn't find a simple "books online" like in the 200 Edition where it gives you basic syntax and code examples.
So I was wondering, is there a way to download the 2000 books online as a document or a stand alone piece of software that doesn't need me to overwrite anything in 2005?
Thanks
modified on Tuesday, May 6, 2008 5:27 AM
|
|
|
|
|
If you install a named instance of 2000, it won't interfere with 2005.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|