Forum Replies Created

Viewing 15 posts - 5,386 through 5,400 (of 13,460 total)

  • RE: Using datediff/dateadd function

    here's two examples of getting monday or friday of the current week.

    --Monday of the Current Week

    select DATEADD(wk, DATEDIFF(wk,0,getdate()), 0)

    --Friday of the Current Week

    select dateadd(dd,4,DATEADD(wk, DATEDIFF(wk,0,getdate()), 0))

    from there. you can modify...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: Programmatically creating a table alias

    easy peasy:

    CREATE SYNONYM MailView FOR msdb.dbo.sysmail_allitems

    select * from MailView

    * note a synonym must point to an object.

    so you cannot try to make it part of a name, like getting...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: Programmatically creating a table alias

    table alias meaning synonym? or table alias in the middle of a SQL statement?

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: Kill All Spid(s) according to Database Name

    here's my other proc: note that it "toggles" the setting from single user to multi user for multiple calls;

    that way if i need exclusive access, i can get it do...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: Kill All Spid(s) according to Database Name

    SQLKnowItAll (6/14/2012)


    Lowell, in what cases do you use this? For the operation of restoring a database, I would prefer to use the

    ALTER DATABASE DatabseName

    SET SINGLE_USER WITH ROLLBACK IMMEDIATE

    GO because of...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: How can I return value from function that comes from dynamic sql

    can you give us the CREATE TABLE definition of dbo.ExRates and a few sample rows?

    i suspect you could do this with a pivot, but i'd have to see the table...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: Kill All Spid(s) according to Database Name

    here's something i use a lot;

    it's just a proc that cursors thru all the spids for a given database name;

    sp_kill SandBox would kill all spids attached to the database, except...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: Find lottery winner

    farax_x (6/13/2012)


    ...a customer who has more score has greater chance to win.

    you'd have to explain the rules. for example, if i have a "score" of 5, do i have 5...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: Issue Connecting Classic ASP pages to SQL Express 2012

    well, sql express does not allow remote connections by default...did you explicitly change that?

    can you connect to that server via SSMS from a machine that is not the server itself?

    your...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: BCP when a NTEXT column contains carriage return

    yes that is correct; because i'm using a specific delimiter, no format file is needed.

    format files are useful when you have stuff like fixed width files or quote delimited...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: BCP when a NTEXT column contains carriage return

    i use a special delimiter that I know will not exist in theactual data;

    here's my classic example,w hich i use to export html a lot...that always contains a ton of...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: Find lottery winner

    Using SELECT TOP ....ORDER BY NEWID() is probably the most popular way to get randomized results

    SELECT TOP 5 *

    FROM dbo.tblLottery

    ORDER BY NEWID()

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: Separate field based on \ character

    a neat trick with the PARSENAME function, which is used to chop up object names like ServerName.DatabaseName.SchemaName.ObjectName:

    --Results:

    /*

    ServerName Instance

    ----------- --------

    MyServer SQL2005

    */

    SELECT

    PARSENAME(Replace(instancename,'\','.'),2) AS ServerName,

    PARSENAME(Replace(instancename,'\','.'),1) AS Instance

    from(SELECT 'MyServer\SQL2005' AS...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: How to query AD to return IF ORIGINAL_LOGIN() is in a specific AD group

    I'm not familiar with the inner workings of the extended proc xp_logininfo, but it does query the domain controller for the groups a user belongs to, or the users that...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: How to query AD to return IF ORIGINAL_LOGIN() is in a specific AD group

    another possibility, but where you would have to grant execute permissions to Everyone ON xp_logininfo (or the trigger has to Execute AS a power user's context) so they can...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 15 posts - 5,386 through 5,400 (of 13,460 total)