| Author |
Topic |
|
saahil_k
Starting Member
18 Posts |
Posted - 2008-02-01 : 23:36:01
|
| hi i am new to SQL server.how can i write a stored procedure to find out the currently logged in user and print if the user is using windows authentication or sql authentication for his loginthanks |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-02-01 : 23:49:11
|
| select distinct loginame, 'windows authentication' from master.sys.sysprocesses where nt_username is not nullunion allselect distinct loginame, 'sql authentication' from master.sys.sysprocesses where nt_username is null |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-01 : 23:51:58
|
| hi,use SYSTEM_USERSELECT SYSTEM_USER,CASE WHEN CHARINDEX('\',SYSTEM_USER) > 0 THEN 'windows authentication' ELSE 'sql authentication'END AS Authentication |
 |
|
|
saahil_k
Starting Member
18 Posts |
Posted - 2008-02-01 : 23:59:11
|
| hi,thanks a lot i got it. |
 |
|
|
Paulrpr
Starting Member
2 Posts |
Posted - 2008-02-02 : 00:39:00
|
| Is their any way to use ARRAY in Stored proceduresPAUL |
 |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-02-02 : 00:41:25
|
| T-sql doesn't support array. |
 |
|
|
saahil_k
Starting Member
18 Posts |
Posted - 2008-02-02 : 00:53:43
|
| hi,can anybody refer good website for performance tuning and also if possible video tutorials.thanks |
 |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-02-02 : 01:08:47
|
| TechNet has many articles of that. |
 |
|
|
saahil_k
Starting Member
18 Posts |
Posted - 2008-02-02 : 19:04:40
|
| Hello all,what is the query to get the date part only,time part only for get date().I want the date and time should be seperate.thanks |
 |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-02-02 : 21:30:04
|
| Use datepart function. |
 |
|
|
saahil_k
Starting Member
18 Posts |
Posted - 2008-02-02 : 21:57:59
|
| i got it by using the convert functionthanks |
 |
|
|
saahil_k
Starting Member
18 Posts |
Posted - 2008-02-02 : 23:15:53
|
| Hello,Query to find the Newest and Oldest table created in Adventure Works.Thanks in advance |
 |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-02-02 : 23:48:57
|
| Query sys.objects in the db. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-02 : 23:53:14
|
| Oldest created table(s):-SELECT s.* from sysobjects s INNER JOIN (SELECT MIN(crdate) AS crdate FROM sysobjects WHERE type='U')twhere t.crdate=s.crdateand s.type='U'Newest created table(s):-SELECT s.name from sysobjects s INNER JOIN (SELECT MAX(crdate) AS crdate FROM sysobjects WHERE type='U')twhere t.crdate=s.crdateand s.type='U' |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2008-02-03 : 23:55:42
|
quote: Originally posted by visakh16 Oldest created table(s):-SELECT s.* from sysobjects s INNER JOIN (SELECT MIN(crdate) AS crdate FROM sysobjects WHERE type='U')twhere t.crdate=s.crdateand s.type='U'Newest created table(s):-SELECT s.name from sysobjects s INNER JOIN (SELECT MAX(crdate) AS crdate FROM sysobjects WHERE type='U')twhere t.crdate=s.crdateand s.type='U'
use 'on' but not 'where' in <where t.crdate=s.crdate> part. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-04 : 01:28:06
|
quote: Originally posted by saahil_k i got it by using the convert functionthanks
If it is only formation, then do it in front end applicationAlso post unrelated questions as a new topicMadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-08 : 01:16:49
|
quote: Originally posted by visakh16 Oldest created table(s):-SELECT s.* from sysobjects s INNER JOIN (SELECT MIN(crdate) AS crdate FROM sysobjects WHERE type='U')twhere t.crdate=s.crdateand s.type='U'Newest created table(s):-SELECT s.name from sysobjects s INNER JOIN (SELECT MAX(crdate) AS crdate FROM sysobjects WHERE type='U')twhere t.crdate=s.crdateand s.type='U'
select top 1 * from sysobjects WHERE type='U' order by crdate ascselect top 1 * from sysobjects WHERE type='U' order by crdate descMadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-08 : 03:13:50
|
quote: Originally posted by madhivanan
quote: Originally posted by visakh16 Oldest created table(s):-SELECT s.* from sysobjects s INNER JOIN (SELECT MIN(crdate) AS crdate FROM sysobjects WHERE type='U')twhere t.crdate=s.crdateand s.type='U'Newest created table(s):-SELECT s.name from sysobjects s INNER JOIN (SELECT MAX(crdate) AS crdate FROM sysobjects WHERE type='U')twhere t.crdate=s.crdateand s.type='U'
select top 1 * from sysobjects WHERE type='U' order by crdate ascselect top 1 * from sysobjects WHERE type='U' order by crdate descMadhivananFailing to plan is Planning to fail
yup. this was easier way. sorry didnt felt this then |
 |
|
|
|