Showing posts with label proc. Show all posts
Showing posts with label proc. Show all posts

Wednesday, March 21, 2012

need brief answers

what are pseudo tables
how queries run by MSDE
how stored procedures run in backend by MSDE
how triggers run by MSDE
where triggers and stored proc stored in MSDE and in which form
where logs are being maintained of transactions/DML statement by default

what are pseudo tables - Never heard of them, you may mean Derived Tables (A table created in a query that lives only during that query), or Views (a sql statement describing a virtual table)


how queries run by MSDE - You have to use a tool, like Query Analyzer or a client application to send queies to the MSDE engine


how stored procedures run in backend by MSDE - Same as above


how triggers run by MSDE - Triggers are run automatically by the database engine when the proper event happens to a table with a trigger on it.


where triggers and stored proc stored in MSDE and in which form - They are stored in system tables, you access them to create and edit them through Enterprise Manager or writing a DDL query in Query Analyzer


where logs are being maintained of transactions/DML statement by default - The log file(s) are where ever you tell the database to put them when you create a database. By default I think they are in the <SQl Server install location>\Data folder.

|||I sometimes use the term "pseudo table" to describe the INSERTED and DELETED logical tables that are available in triggers. I am not sure if that is what applies here or not.|||ah, good point. I have never heard that term though, always heard them referred to as virtual tables.

Monday, March 19, 2012

Need an example of failed CREATE PROC...

This is an example of a working CREATE PROCEDURE.
USE Northwind
GO
CREATE PROC dbo.OverdueOrders
AS
SELECT *
FROM dbo.Orders
WHERE RequiredDate < GETDATE() AND ShippedDate IS Null
What does it mean that "a CREATE PROCEDURE statement cannot be combined with
other TSQL statements in a single batch?" I see a TSQL stmt in this working
one.
Would someone provide me an example, please?
Thanks.
USE Northwind
GO
SELECT *
FROM dbo.Orders
CREATE PROC dbo.OverdueOrders
AS
SELECT *
FROM dbo.Orders
WHERE RequiredDate < GETDATE() AND ShippedDate IS Null
GO
"light_wt" <lightwt@.discussions.microsoft.com> wrote in message
news:8E891A71-BE7D-495A-B134-CC3C1D1E2367@.microsoft.com...
> This is an example of a working CREATE PROCEDURE.
> USE Northwind
> GO
> CREATE PROC dbo.OverdueOrders
> AS
> SELECT *
> FROM dbo.Orders
> WHERE RequiredDate < GETDATE() AND ShippedDate IS Null
> What does it mean that "a CREATE PROCEDURE statement cannot be combined
with
> other TSQL statements in a single batch?" I see a TSQL stmt in this
working
> one.
> Would someone provide me an example, please?
> Thanks.
|||Here you go:
USE Northwind
GO
SELECT * FROM Orders
CREATE PROC dbo.OverdueOrders
AS
SELECT *
FROM dbo.Orders
WHERE RequiredDate < GETDATE()
AND ShippedDate IS NULL
GO
Anith
|||A batch is a set of TSQL statements that are submitted together for
processing. You designate the end of a batch of commands in SQL Server
using the GO statement.
There are only two CREATE statements that can be combined in a single batch.
CREATE DATBASE and CREATE TABLE.
All of the other CREATE statements must be submitted as separate batches.
So:
CREATE DATABASE Frog (....)
CREATE TABLE LilyPad (...)
CREATE TABLE Swim(...)
GO
Would work, but
CREATE TABLE LilyPad(...)
CREATE PROC Croak ...
Would not.
You would have to submit them as:
CREATE TABLE LilyPad...
GO
CREATE PROC Croak...
GO
HTH
Rick Sawtell
MCT, MCSD, MCDBA
"light_wt" <lightwt@.discussions.microsoft.com> wrote in message
news:8E891A71-BE7D-495A-B134-CC3C1D1E2367@.microsoft.com...
> This is an example of a working CREATE PROCEDURE.
> USE Northwind
> GO
> CREATE PROC dbo.OverdueOrders
> AS
> SELECT *
> FROM dbo.Orders
> WHERE RequiredDate < GETDATE() AND ShippedDate IS Null
> What does it mean that "a CREATE PROCEDURE statement cannot be combined
with
> other TSQL statements in a single batch?" I see a TSQL stmt in this
working
> one.
> Would someone provide me an example, please?
> Thanks.
|||Thank you, all.
I appreciate your detailed and good explaination, Rick.
"Rick Sawtell" wrote:
<snip>

Monday, March 12, 2012

Need Advice/Help on querying a different db

I have 2 different database's on the same server. I'm trying to create a stored proc that resides in Reporting database but queries against the Call database. 4 part naming convention gives me an error of 'invalid object name' What am I forgetting here?My first guess would be that you forgot how to spell the object name. The next guess would be that you are doing something that doesn't make sense, like SELECT * FROM myStoredProcedure or the equivalent.

-PatP|||stored procedure lies in ABC4_Dev1_Reporting
Data resides in ABC_Dev1_Call1

From Reporting db in query analyzer I cannot get the following query to run

select * from dbo.ABC_Dev1_Call1.Call (Call is the table)

What am I missing?
Thanks in advance!|||Ah, a snippet of code is worth a thousand words of description! I'd use:SELECT *
FROM ABC_Dev1_Call1.dbo.Call-PatP|||Ah... very interesting... I'm claiming a bad case of the friday's on that one. I owe you one. Thanks a million. Have a good weekend.|||Listen...if Pat collected them all...he'd be hammered all year...

You threw me with the 4 part naming convention....

See what happens when I take a break and get a sandwich...

Wednesday, March 7, 2012

need a subsetsorted by languageid can somebody help with stored proc..............

Here is part of my stored procedure. I would like to get a subsetsorted back from my query where languageid = @.languageid but I am lost. Can somebody help me out, thanks Newbie

-- Issue query

DECLARE @.sqlnvarchar(4000)

SET @.sql='SELECT [KeywordID], [Keyword], [LanguageID]

FROM

(SELECT [KeywordID], [Keyword], [LanguageID], ROW_NUMBER() OVER(ORDER BY '+ @.sortExpression+') AS RowNum

FROM syl_Keywords) AS KeywordInfo

WHERE RowNum BETWEEN '+CONVERT(nvarchar(10), @.startRowIndex)+

' AND ('+CONVERT(nvarchar(10), @.startRowIndex)+' + '

+CONVERT(nvarchar(10), @.maximumRows)+') - 1 AND [LanguageID] = @.LanguageID'

-- Execute the SQL query

EXECsp_executesql @.sql

If this answers your question... please mark this as the "answer" :)

DECLARE

@.SQLVARCHAR(8000)

SELECT @.SQL='
WITH _temp AS
(SELECT
KeywordID,
Keyword,
LanguageID,
ROW_NUMBER() OVER(ORDER BY '+ @.sortExpression+' ) AS RowNumber
FROM
syl_Keywords
WHERE
LanguageID = '''+ @.LanguageID+''')

SELECT TOP '+CONVERT(VARCHAR, @.maximumRows)+' *
FROM _temp WHERE RowNumber > '+CONVERT(VARCHAR, @.startRowIndex)

EXECsp_executesql @.SQL

Peace,

|||

Hi Nullable, thank you for your reply. I can't get it to work with your example. Here is my original stored procedure that returns a subset sorted by sortexpression which works. What I would like to accomplish is to sort it by LanguageID as well.

setANSI_NULLSON

setQUOTED_IDENTIFIERON

GO

ALTER

PROCEDURE [dbo].[syl_KeywordGetSubsetSorted]

@.sortExpression

nvarchar(50),

@.startRowIndex

int,

@.maximumRows

int

AS

BEGIN

-- SET NOCOUNT ON added to prevent extra result sets from-- interfering with SELECT statements.SETNOCOUNTONBEGINTRYIFLEN(@.sortExpression)= 0SET @.sortExpression='KeywordID'-- Since @.startRowIndex is zero-based in the data Web control, but one-based w/ROW_NUMBER(), incrementSET @.startRowIndex= @.startRowIndex+ 1-- Issue queryDECLARE @.sqlnvarchar(4000)SET @.sql='SELECT [KeywordID], [Keyword], [LanguageID]

FROM

(SELECT [KeywordID], [Keyword], [LanguageID], ROW_NUMBER() OVER(ORDER BY '

+ @.sortExpression+') AS RowNum

FROM syl_Keywords) AS KeywordInfo

WHERE RowNum BETWEEN '

+CONVERT(nvarchar(10), @.startRowIndex)+' AND ('+CONVERT(nvarchar(10), @.startRowIndex)+' + '+CONVERT(nvarchar(10), @.maximumRows)+') - 1'

-- Execute the SQL queryEXECsp_executesql @.sqlRETURNENDTRY

BEGIN

CATCH--Execute LogError SPEXECUTE [dbo].[syl_LogError];--Being in a Catch Block indicates failure.--Force RETURN to -1 for consistency (other return values are generated, such as -6).RETURN-1ENDCATCH

END

|||

newbie06:

(SELECT [KeywordID], [Keyword], [LanguageID], ROW_NUMBER() OVER(ORDER BY '+ @.sortExpression+') AS RowNum

FROM syl_Keywords) AS KeywordInfo

Change that to:

(SELECT [KeywordID], [Keyword], [LanguageID], ROW_NUMBER() OVER(ORDER BY '+ @.sortExpression+', LanguageID) AS RowNum

FROM syl_Keywords) AS KeywordInfo

|||

Here is the working portion of the Stored Proc:

-- Issue query

DECLARE @.sqlnvarchar(4000)SET @.sql='SELECT [KeywordID], [Keyword], [LanguageID]

FROM

(SELECT [KeywordID], [Keyword], [LanguageID], ROW_NUMBER() OVER(ORDER BY '

+ @.sortExpression+') AS RowNum

FROM syl_Keywords

WHERE LanguageID = '

+CONVERT(nvarchar(10), @.LanguageID)+' )

AS KeywordInfo

WHERE RowNum BETWEEN '

+CONVERT(nvarchar(10), @.startRowIndex)+' AND ('+CONVERT(nvarchar(10), @.startRowIndex)+' + '+CONVERT(nvarchar(10), @.maximumRows)+') - 1'

Saturday, February 25, 2012

Need a "Replace" sp with rugular expressions

Hi all,
I need a more powerfull function (or stored proc) to make string replacement
(like the REPLACE SQL function) but with regular expressions (like the
wildcard characters used with the LIKE).
Who has this function ?
Thanks.
Lilian.Hi Lilian,
I have a tool that does that. You can dowload your free copy at:
http://www.nobhillsoft.com/EnterCus...prod_name=diana
"Lilian Pigallio" <lpigallio@.nospam.com> wrote in message
news:u62RFrXSEHA.240@.TK2MSFTNGP11.phx.gbl...
> Hi all,
> I need a more powerfull function (or stored proc) to make string
replacement
> (like the REPLACE SQL function) but with regular expressions (like the
> wildcard characters used with the LIKE).
> Who has this function ?
> Thanks.
> Lilian.
>|||Thanks, but finally I've found by myself (thanks google): a good and FREE
solution: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=27205
"Yoni Sion" <yoni@.nobhillsoft.com> wrote in message
news:O1D7E0XSEHA.972@.tk2msftngp13.phx.gbl...
> Hi Lilian,
> I have a tool that does that. You can dowload your free copy at:
>
http://www.nobhillsoft.com/EnterCus...prod_name=diana
>
> "Lilian Pigallio" <lpigallio@.nospam.com> wrote in message
> news:u62RFrXSEHA.240@.TK2MSFTNGP11.phx.gbl...
> replacement
>

Need a "Replace" sp with rugular expressions

Hi all,
I need a more powerfull function (or stored proc) to make string replacement
(like the REPLACE SQL function) but with regular expressions (like the
wildcard characters used with the LIKE).
Who has this function ?
Thanks.
Lilian.Hi Lilian,
I have a tool that does that. You can dowload your free copy at:
http://www.nobhillsoft.com/EnterCust_download.php?prod_id=1&prod_name=diana
"Lilian Pigallio" <lpigallio@.nospam.com> wrote in message
news:u62RFrXSEHA.240@.TK2MSFTNGP11.phx.gbl...
> Hi all,
> I need a more powerfull function (or stored proc) to make string
replacement
> (like the REPLACE SQL function) but with regular expressions (like the
> wildcard characters used with the LIKE).
> Who has this function ?
> Thanks.
> Lilian.
>|||Thanks, but finally I've found by myself (thanks google): a good and FREE
solution: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=27205
"Yoni Sion" <yoni@.nobhillsoft.com> wrote in message
news:O1D7E0XSEHA.972@.tk2msftngp13.phx.gbl...
> Hi Lilian,
> I have a tool that does that. You can dowload your free copy at:
>
http://www.nobhillsoft.com/EnterCust_download.php?prod_id=1&prod_name=diana
>
> "Lilian Pigallio" <lpigallio@.nospam.com> wrote in message
> news:u62RFrXSEHA.240@.TK2MSFTNGP11.phx.gbl...
> > Hi all,
> >
> > I need a more powerfull function (or stored proc) to make string
> replacement
> > (like the REPLACE SQL function) but with regular expressions (like the
> > wildcard characters used with the LIKE).
> >
> > Who has this function ?
> >
> > Thanks.
> >
> > Lilian.
> >
> >
>

Need a "Replace" sp with rugular expressions

Hi all,
I need a more powerfull function (or stored proc) to make string replacement
(like the REPLACE SQL function) but with regular expressions (like the
wildcard characters used with the LIKE).
Who has this function ?
Thanks.
Lilian.
Hi Lilian,
I have a tool that does that. You can dowload your free copy at:
http://www.nobhillsoft.com/EnterCust...rod_name=diana
"Lilian Pigallio" <lpigallio@.nospam.com> wrote in message
news:u62RFrXSEHA.240@.TK2MSFTNGP11.phx.gbl...
> Hi all,
> I need a more powerfull function (or stored proc) to make string
replacement
> (like the REPLACE SQL function) but with regular expressions (like the
> wildcard characters used with the LIKE).
> Who has this function ?
> Thanks.
> Lilian.
>
|||Thanks, but finally I've found by myself (thanks google): a good and FREE
solution: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=27205
"Yoni Sion" <yoni@.nobhillsoft.com> wrote in message
news:O1D7E0XSEHA.972@.tk2msftngp13.phx.gbl...
> Hi Lilian,
> I have a tool that does that. You can dowload your free copy at:
>
http://www.nobhillsoft.com/EnterCust...rod_name=diana
>
> "Lilian Pigallio" <lpigallio@.nospam.com> wrote in message
> news:u62RFrXSEHA.240@.TK2MSFTNGP11.phx.gbl...
> replacement
>