Monday, March 26, 2012
No dbo for a database - but there are db_owner users
I assume that any user for such a database that's assigned to the db_owner role can admin everything in this database? Which means that the lack of a dbo doesn't cause any other problem than making it impossible to run a sp_helpdb for the database, or...?
Of course I'd like to make someone the owner, but it seems difficult to make an already existing database user the owner, without dropping the user and re-creating it.Methinks you need sp_changedbowner (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_sp_ca-cz_30s2.asp), which makes the fix trivial anywhere you can execute a stored procedure (such as in Query Analyzer).
-PatP|||Yes, but it doesn't work if the user to be the new owner is already a user in that database. Seems like I need to drop the user and re-create it?|||Yep. Otherwise, SQL Server would have to make a choice about what permissions to grant that user. Especially if that user were dropped from db_owners. The user should see no difference, unless they have created objects under their own username.
Friday, March 9, 2012
Next Inserts ID Number, someone please help
I have a table with a primary key being a bigint and its set to auto increment (or identity or whatever ms calls it). Is there anyway I can get the ID number that will be assigned to the next Insert before I insert it? I want to use that ID number within another field when inserted.
I hope that makes sense.
Thanks for any help.
Robboare you using a stored procedure?? If so, you can get the id from the @.@.IDENTITY variable
select @.@.IDENTITY|||Sorry, the id won't be allocated until the actual insert
(You have to think of there might be many parallell inserts..)
What you can do is to leave the other field blank
and then create an after-trigger that picks up the inserted id and
updates the other field with it.
Regards
Fredrik|||::Is there anyway I can get the ID number that will be assigned to the next Insert before I
::insert it?
Waht good would this be, given that another instance of the ap etc. could already have used up the number? This ppiece of information is unreliable unless you get into VERY bad programming practices.
Or do you seriously propose to create a table level lock at this moment?
Or have you simply not thought about the consequences of your wish?
Next day occurance in a week
I have a table that stores a day number and a time and I need to be
able to get the next occurance of the w

For example in DB if I have:
4 as dayNo (Thursday) and 08:34 as Time and I want to return
18/Aug/2005 08:34
5 as dayNo (Friday) and 15:00 as Time I want to return 19/Aug/2005
15:00
5 as DayNo (Friday) and 23:45 as Time I want to return 12/Aug/2005
23:45 (as the current time is 19:30)
Can anyone help me with a UDF?
Thankshttp://www.aspfaq.com/show.asp?id=2519
Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
--
"Rippo" <info@.rippo.co.uk> wrote in message
news:1123871644.325175.149000@.z14g2000cwz.googlegroups.com...
> Hi
> I have a table that stores a day number and a time and I need to be
> able to get the next occurance of the w

> For example in DB if I have:
> 4 as dayNo (Thursday) and 08:34 as Time and I want to return
> 18/Aug/2005 08:34
> 5 as dayNo (Friday) and 15:00 as Time I want to return 19/Aug/2005
> 15:00
> 5 as DayNo (Friday) and 23:45 as Time I want to return 12/Aug/2005
> 23:45 (as the current time is 19:30)
> Can anyone help me with a UDF?
> Thanks
>|||Perfect!
Thanks, Rippo
Newspaper Columns
trying to create a company address and phone number directory.
Thanks for any help you can offer.In the Body section of the report, open your properties window. There is a
property under layout called columns. Set the number of columns here.
Then, if you want 2 3" columns w/ 1/2" between them, you would set your
report width to 6.5 and your body width to 3".
msflinx
"GR Pilot" wrote:
> Does anyone know how to create Newspaper Columns in Reporting Services? I am
> trying to create a company address and phone number directory.
> Thanks for any help you can offer.
Newsgroup Suggestion
newsgroup. I've bounced around a number of MS SQL Server newsgroups for some
very useful info.
I noticed that there is one for MICROSOFT.PUBLIC.VSNET.SERVICEPACKS.
FrankM
You know you are in trouble when
the learning curve turns into a death spiralHi Frank,
There is already a newsgroup out there: microsoft.public.sqlserver.setup -
this newsgroup is the most appropriate for posting any issues related to
installation of Service Packs. Did you get bounced around posting to this
newsgroup?
Regards,
Jyothi Pai
Microsoft Online Support Engineer
Get Secure! ? www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--
| From: "frankm" <frank@.nxspxm.mallardcentral.com>
| Subject: Newsgroup Suggestion
| Date: Mon, 25 Aug 2003 12:59:20 -0500
| Lines: 13
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <OOEedKzaDHA.2580@.TK2MSFTNGP09.phx.gbl>
| Newsgroups: microsoft.public.sqlserver.server
| NNTP-Posting-Host: angrboda.ms.acxiom.com 206.66.66.9
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.sqlserver.server:302989
| X-Tomcat-NG: microsoft.public.sqlserver.server
|
| It may be extremely useful for MS to start a SQL Server Service Pack
| newsgroup. I've bounced around a number of MS SQL Server newsgroups for
some
| very useful info.
|
| I noticed that there is one for MICROSOFT.PUBLIC.VSNET.SERVICEPACKS.
|
|
| FrankM
| You know you are in trouble when
| the learning curve turns into a death spiral
|
|
|
||||No offense, but one could spend hours searching for relevent material
in the KB or support or other places on MS site. Just to find days/weeks
later that there was something that did not show up in a Microsoft search or
something that some other person found.
"Jyothi Pai [MSFT]" <jyothip@.online.microsoft.com> wrote in message
news:Yv1djTMbDHA.2080@.cpmsftngxa06.phx.gbl...
> Hi Frank,
> Thanks for the additional feedback. I'll forward this to the concerned
> folks and see if this can be done. In the meantime, please post any
> setup-related issues with the Service Packs to the
> microsoft.public.sqlserver.setup newsgroup. As you've noted yourself,
> readme is the best place to start before applying the service pack. We
also
> publish KB articles if there are any known issues with a Service Pack and
> this would be another place to go to.
> Regards,
> Jyothi Pai
> Microsoft Online Support Engineer
>
> Get Secure! - www.microsoft.com/security
> =====================================================> When responding to posts, please "Reply to Group" via
> your newsreader so that others may learn and benefit
> from your issue.
> =====================================================> This posting is provided "AS IS" with no warranties, and confers no
rights.
>
>
> --
> | From: "Frank" <frm@.nobs.com>
> | Newsgroups: microsoft.public.sqlserver.server
> | References: <OOEedKzaDHA.2580@.TK2MSFTNGP09.phx.gbl>
> <SABa#HDbDHA.2108@.cpmsftngxa06.phx.gbl>
> | Subject: Re: Newsgroup Suggestion
> | Lines: 65
> | X-Priority: 3
> | X-MSMail-Priority: Normal
> | X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
> | Message-ID: <83U2b.15802$Ih1.5335836@.newssrv26.news.prodigy.com>
> | NNTP-Posting-Host: 68.72.136.177
> | X-Complaints-To: abuse@.prodigy.net
> | X-Trace: newssrv26.news.prodigy.com 1061948740 ST000 68.72.136.177 (Tue,
> 26 Aug 2003 21:45:40 EDT)
> | NNTP-Posting-Date: Tue, 26 Aug 2003 21:45:40 EDT
> | Organization: SBC http://yahoo.sbc.com
> | X-UserInfo1:
>
FKPO@.MC@.@.S@.KRV@.YJZHJOFXBWR\HPCTL@.XT^OBPLAH[\BQUBLNTC@.AWZWDXZXQ[K\FFSKCVM@.F_N
>
_DOBWVWG__LG@.VVOIPLIGX\\BU_B@.\P\PFX\B[APHTWAHDCKJF^NHD[YJAZMCY_CWG[SX\Y]^KC\
> HSZRWSWKGAY_PC[BQ[BXAS\F\\@.DMTLFZFUE@.\VL
> | Date: Wed, 27 Aug 2003 01:45:40 GMT
> | Path:
>
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!news-out.cwix.com!newsfeed.cwix.co
>
m!prodigy.com!newsmst01.news.prodigy.com!prodigy.com!postmaster.news.prodigy
> com!newssrv26.news.prodigy.com.POSTED!not-for-mail
> | Xref: cpmsftngxa06.phx.gbl microsoft.public.sqlserver.server:303304
> | X-Tomcat-NG: microsoft.public.sqlserver.server
> |
> | There is no service pack newsgroup to go to. People go to the newsgroup
> that
> | is the closest to the problem they are having with service pack, like
> | replication or connectivity. So, basically to find out about a
collective
> | set of sp issues you need to bounce groups. MS says to plan and test.
So,
> I
> | plan by going through what documentation I can find, like the readme,
> then I
> | go around the newsgroups trying to find posts that pertain to the sp
> | specifically. There are times that people are told to go to another
> | newsgroup when the subject does not match. Unfortunately MS does not
have
> a
> | one stop shop for info about sp problems, planning and gotcha's. Most of
> the
> | time you need to search and scratch for any info in any number of
places.
> | The sp readme is just a starting point.
> |
> |
> | "Jyothi Pai [MSFT]" <jyothip@.online.microsoft.com> wrote in message
> | news:SABa#HDbDHA.2108@.cpmsftngxa06.phx.gbl...
> | > Hi Frank,
> | >
> | > There is already a newsgroup out there:
> microsoft.public.sqlserver.setup -
> | > this newsgroup is the most appropriate for posting any issues related
to
> | > installation of Service Packs. Did you get bounced around posting to
> this
> | > newsgroup?
> | >
> | > Regards,
> | > Jyothi Pai
> | > Microsoft Online Support Engineer
> | >
> | >
> | > Get Secure! - www.microsoft.com/security
> | > This posting is provided "AS IS" with no warranties, and confers no
> | rights.
> | >
> | > --
> | > | From: "frankm" <frank@.nxspxm.mallardcentral.com>
> | > | Subject: Newsgroup Suggestion
> | > | Date: Mon, 25 Aug 2003 12:59:20 -0500
> | > | Lines: 13
> | > | X-Priority: 3
> | > | X-MSMail-Priority: Normal
> | > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
> | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> | > | Message-ID: <OOEedKzaDHA.2580@.TK2MSFTNGP09.phx.gbl>
> | > | Newsgroups: microsoft.public.sqlserver.server
> | > | NNTP-Posting-Host: angrboda.ms.acxiom.com 206.66.66.9
> | > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
> | > | Xref: cpmsftngxa06.phx.gbl microsoft.public.sqlserver.server:302989
> | > | X-Tomcat-NG: microsoft.public.sqlserver.server
> | > |
> | > | It may be extremely useful for MS to start a SQL Server Service Pack
> | > | newsgroup. I've bounced around a number of MS SQL Server newsgroups
> for
> | > some
> | > | very useful info.
> | > |
> | > | I noticed that there is one for MICROSOFT.PUBLIC.VSNET.SERVICEPACKS.
> | > |
> | > |
> | > | FrankM
> | > | You know you are in trouble when
> | > | the learning curve turns into a death spiral
> | > |
> | > |
> | > |
> | > |
> | >
> |
> |
> |
>|||Hi Frank,
Thanks for the additional feedback. As I mentioned earlier, I'll forward
this to the appropriate folks and see if this can be done. In the meantime,
please post any
setup-related issues with the Service Packs to the
microsoft.public.sqlserver.setup newsgroup.
Regards,
Jyothi Pai
Microsoft Online Support Engineer
Get Secure! ? www.microsoft.com/security
=====================================================When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
=====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
| From: "frankm" <frank@.nxspxm.mallardcentral.com>
| References: <OOEedKzaDHA.2580@.TK2MSFTNGP09.phx.gbl>
<SABa#HDbDHA.2108@.cpmsftngxa06.phx.gbl>
<83U2b.15802$Ih1.5335836@.newssrv26.news.prodigy.com>
<Yv1djTMbDHA.2080@.cpmsftngxa06.phx.gbl>
| Subject: Re: Newsgroup Suggestion
| Date: Wed, 27 Aug 2003 14:20:35 -0500
| Lines: 153
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <ugXtLBNbDHA.2024@.TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.sqlserver.server
| NNTP-Posting-Host: angrboda.ms.acxiom.com 206.66.66.9
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.sqlserver.server:303440
| X-Tomcat-NG: microsoft.public.sqlserver.server
|
| No offense, but one could spend hours searching for relevent material
| in the KB or support or other places on MS site. Just to find days/weeks
| later that there was something that did not show up in a Microsoft search
or
| something that some other person found.
|
|
| "Jyothi Pai [MSFT]" <jyothip@.online.microsoft.com> wrote in message
| news:Yv1djTMbDHA.2080@.cpmsftngxa06.phx.gbl...
| > Hi Frank,
| >
| > Thanks for the additional feedback. I'll forward this to the concerned
| > folks and see if this can be done. In the meantime, please post any
| > setup-related issues with the Service Packs to the
| > microsoft.public.sqlserver.setup newsgroup. As you've noted yourself,
| > readme is the best place to start before applying the service pack. We
| also
| > publish KB articles if there are any known issues with a Service Pack
and
| > this would be another place to go to.
| >
| > Regards,
| > Jyothi Pai
| > Microsoft Online Support Engineer
| >
| >
| > Get Secure! - www.microsoft.com/security
| > =====================================================| > When responding to posts, please "Reply to Group" via
| > your newsreader so that others may learn and benefit
| > from your issue.
| > =====================================================| >
| > This posting is provided "AS IS" with no warranties, and confers no
| rights.
| >
| >
| >
| >
| > --
| > | From: "Frank" <frm@.nobs.com>
| > | Newsgroups: microsoft.public.sqlserver.server
| > | References: <OOEedKzaDHA.2580@.TK2MSFTNGP09.phx.gbl>
| > <SABa#HDbDHA.2108@.cpmsftngxa06.phx.gbl>
| > | Subject: Re: Newsgroup Suggestion
| > | Lines: 65
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
| > | Message-ID: <83U2b.15802$Ih1.5335836@.newssrv26.news.prodigy.com>
| > | NNTP-Posting-Host: 68.72.136.177
| > | X-Complaints-To: abuse@.prodigy.net
| > | X-Trace: newssrv26.news.prodigy.com 1061948740 ST000 68.72.136.177
(Tue,
| > 26 Aug 2003 21:45:40 EDT)
| > | NNTP-Posting-Date: Tue, 26 Aug 2003 21:45:40 EDT
| > | Organization: SBC http://yahoo.sbc.com
| > | X-UserInfo1:
| >
|
FKPO@.MC@.@.S@.KRV@.YJZHJOFXBWR\HPCTL@.XT^OBPLAH[\BQUBLNTC@.AWZWDXZXQ[K\FFSKCVM@.F_N
| >
|
_DOBWVWG__LG@.VVOIPLIGX\\BU_B@.\P\PFX\B[APHTWAHDCKJF^NHD[YJAZMCY_CWG[SX\Y]^KC\
| > HSZRWSWKGAY_PC[BQ[BXAS\F\\@.DMTLFZFUE@.\VL
| > | Date: Wed, 27 Aug 2003 01:45:40 GMT
| > | Path:
| >
|
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!news-out.cwix.com!newsfeed.cwix.co
| >
|
m!prodigy.com!newsmst01.news.prodigy.com!prodigy.com!postmaster.news.prodigy
| > com!newssrv26.news.prodigy.com.POSTED!not-for-mail
| > | Xref: cpmsftngxa06.phx.gbl microsoft.public.sqlserver.server:303304
| > | X-Tomcat-NG: microsoft.public.sqlserver.server
| > |
| > | There is no service pack newsgroup to go to. People go to the
newsgroup
| > that
| > | is the closest to the problem they are having with service pack, like
| > | replication or connectivity. So, basically to find out about a
| collective
| > | set of sp issues you need to bounce groups. MS says to plan and test.
| So,
| > I
| > | plan by going through what documentation I can find, like the readme,
| > then I
| > | go around the newsgroups trying to find posts that pertain to the sp
| > | specifically. There are times that people are told to go to another
| > | newsgroup when the subject does not match. Unfortunately MS does not
| have
| > a
| > | one stop shop for info about sp problems, planning and gotcha's. Most
of
| > the
| > | time you need to search and scratch for any info in any number of
| places.
| > | The sp readme is just a starting point.
| > |
| > |
| > | "Jyothi Pai [MSFT]" <jyothip@.online.microsoft.com> wrote in message
| > | news:SABa#HDbDHA.2108@.cpmsftngxa06.phx.gbl...
| > | > Hi Frank,
| > | >
| > | > There is already a newsgroup out there:
| > microsoft.public.sqlserver.setup -
| > | > this newsgroup is the most appropriate for posting any issues
related
| to
| > | > installation of Service Packs. Did you get bounced around posting to
| > this
| > | > newsgroup?
| > | >
| > | > Regards,
| > | > Jyothi Pai
| > | > Microsoft Online Support Engineer
| > | >
| > | >
| > | > Get Secure! - www.microsoft.com/security
| > | > This posting is provided "AS IS" with no warranties, and confers no
| > | rights.
| > | >
| > | > --
| > | > | From: "frankm" <frank@.nxspxm.mallardcentral.com>
| > | > | Subject: Newsgroup Suggestion
| > | > | Date: Mon, 25 Aug 2003 12:59:20 -0500
| > | > | Lines: 13
| > | > | X-Priority: 3
| > | > | X-MSMail-Priority: Normal
| > | > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | > | Message-ID: <OOEedKzaDHA.2580@.TK2MSFTNGP09.phx.gbl>
| > | > | Newsgroups: microsoft.public.sqlserver.server
| > | > | NNTP-Posting-Host: angrboda.ms.acxiom.com 206.66.66.9
| > | > | Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| > | > | Xref: cpmsftngxa06.phx.gbl
microsoft.public.sqlserver.server:302989
| > | > | X-Tomcat-NG: microsoft.public.sqlserver.server
| > | > |
| > | > | It may be extremely useful for MS to start a SQL Server Service
Pack
| > | > | newsgroup. I've bounced around a number of MS SQL Server
newsgroups
| > for
| > | > some
| > | > | very useful info.
| > | > |
| > | > | I noticed that there is one for
MICROSOFT.PUBLIC.VSNET.SERVICEPACKS.
| > | > |
| > | > |
| > | > | FrankM
| > | > | You know you are in trouble when
| > | > | the learning curve turns into a death spiral
| > | > |
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|
Saturday, February 25, 2012
newbie: TSQL command for number of rows ?
Any suggestions ?
TIA
-steveSELECT COUNT(*)
FROM YourTable
David Portas
SQL Server MVP
--|||Use the TOP statement
Example:
USE NORTHWIND
GO
Select TOP 5 From Orders
But remember that TOP is also recommended with the use of order because the
TOP clause will produce an unpredictable subset of n-Rows.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"steve" <steve@.here.com> schrieb im Newsbeitrag
news:Ph4ie.56688$th3.616072@.wagner.videotron.net...
>I couldnt find on google a command to get the number of rows in a table.
> Any suggestions ?
> TIA
> -steve
>|||SELECT COUNT(*) FROM tbl
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"steve" <steve@.here.com> wrote in message news:Ph4ie.56688$th3.616072@.wagner.videotron.net.
.
>I couldnt find on google a command to get the number of rows in a table.
> Any suggestions ?
> TIA
> -steve
>|||Ok, guess I didnt get your questions that right X-)
"Jens Smeyer" <Jens@.Remove_this_For_Contacting.sqlserver2005.de> schrieb
im Newsbeitrag news:u7Wq6ljWFHA.1796@.TK2MSFTNGP15.phx.gbl...
> Use the TOP statement
> Example:
> USE NORTHWIND
> GO
> Select TOP 5 From Orders
> But remember that TOP is also recommended with the use of order because
> the TOP clause will produce an unpredictable subset of n-Rows.
> --
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
> "steve" <steve@.here.com> schrieb im Newsbeitrag
> news:Ph4ie.56688$th3.616072@.wagner.videotron.net...
>|||I am useless!
Thanx a lot!!
-steve
"steve" <steve@.here.com> a crit dans le message de news:
Ph4ie.56688$th3.616072@.wagner.videotron.net...
>I couldnt find on google a command to get the number of rows in a table.
> Any suggestions ?
> TIA
> -steve
>