Showing posts with label procedure. Show all posts
Showing posts with label procedure. Show all posts

Thursday, March 22, 2012

Does SETROWCOUNT 10 apply to only the sp in which it used or outside it also?

I am using SETROWCOUNT 10 in my stored procedure. At end of thi sp I use SETROWCOUNT 0.

Will all other sp's that are executing at the same time as the above sp, get affected by the above SETROWCOUNT statement?

The option SET ROWCOUNT affects only the current connection session. It does not transfer from one connection to another in a connection pooling environment. Nor does the scope exceed stored procedure boundaries

ifobject_id('usp1')isnot nulldrop proc usp1gocreate proc usp1asbegin set rowcount 10select *from sys.objectsendgoexec usp1goselect *from sys.objectsgoifobject_id('usp1')isnot nulldrop proc usp1go

Does RS recognize CHAR(13)?

I am making a query for mailing labels that I will generate in Reporting
Services. I have a SQL Server stored procedure that returns the address using
SQL like this
SELECT Address + CHAR(13) + Address2 + CHAR(13) + City + ' ' + State + ' '
+ Zip AS FullAddress
FROM ...
Assume the data is:
Address: 123 Main Street
Address2: Suite 3
City: Bellevue
State: WA
Zip: 98111
I assign the FullAddress field to a textbox in Reporting Services. I resize
it to be several lines high. The result I get is something like this:
123 Main StreetSuite3Bellevue
WA 98111
I have tried using CHAR(10) + CHAR(13) instead of just CHAR(10), but I get
double spaces. Does RS handle CHAR() output? Do I need to use separate fields?I've done this before but in the actual field expression not in the query.
Use Fields!Address.Value + CHR(10) + Fields!Address.Value + ...
"Rick" wrote:
> I am making a query for mailing labels that I will generate in Reporting
> Services. I have a SQL Server stored procedure that returns the address using
> SQL like this
> SELECT Address + CHAR(13) + Address2 + CHAR(13) + City + ' ' + State + ' '
> + Zip AS FullAddress
> FROM ...
> Assume the data is:
> Address: 123 Main Street
> Address2: Suite 3
> City: Bellevue
> State: WA
> Zip: 98111
> I assign the FullAddress field to a textbox in Reporting Services. I resize
> it to be several lines high. The result I get is something like this:
> 123 Main StreetSuite3Bellevue
> WA 98111
> I have tried using CHAR(10) + CHAR(13) instead of just CHAR(10), but I get
> double spaces. Does RS handle CHAR() output? Do I need to use separate fields?|||Thanks. Your answer got me going in the right direction. I didn't get the
Chr(10) to work in the actual field expression, but chr(10) + chr(13) did.
For the benefit of future thread readers...I went a step further and created
a code block in the Report|Report Parameters command to make things a little
cleaner. It easily handles the common case where the second address line is
empty (Note: my query returns an empty string rather than a NULL if there is
no Address2). My code is this:
Function BuildAddress(ByVal A1 As String, ByVal A2 As String, ByVal C AS
String) As String
Dim strReturn As String
=Code.BuildAddress(Fields!Address.Value, Fields!Address2.Value,
Fields!CSZ.Value)
If A2.Length > 0 Then
strReturn += A2 + chr(10) + chr(13)
End If
strReturn += C
Return strReturn
End Function
And then I used the following expression in the textbox:
=Code.BuildAddress(
"David Bienstock" wrote:
> I've done this before but in the actual field expression not in the query.
> Use Fields!Address.Value + CHR(10) + Fields!Address.Value + ...
> "Rick" wrote:
> > I am making a query for mailing labels that I will generate in Reporting
> > Services. I have a SQL Server stored procedure that returns the address using
> > SQL like this
> >
> > SELECT Address + CHAR(13) + Address2 + CHAR(13) + City + ' ' + State + ' '
> > + Zip AS FullAddress
> > FROM ...
> >
> > Assume the data is:
> > Address: 123 Main Street
> > Address2: Suite 3
> > City: Bellevue
> > State: WA
> > Zip: 98111
> >
> > I assign the FullAddress field to a textbox in Reporting Services. I resize
> > it to be several lines high. The result I get is something like this:
> >
> > 123 Main StreetSuite3Bellevue
> > WA 98111
> >
> > I have tried using CHAR(10) + CHAR(13) instead of just CHAR(10), but I get
> > double spaces. Does RS handle CHAR() output? Do I need to use separate fields?

Wednesday, March 21, 2012

Does RAISERROR cause performance to go down slightly?

I was curious if using RAISERROR in the catch block of a stored procedure does actually causes some hit on performance? I think it would, as compared to simply returning an error code in this sp's output parameter.

It will cause some impact as RAISEERROR will inevitably require some extra resource, where as you rightly say an error code just requires a value to be set within an existing block of memory.

Monday, March 19, 2012

Does not have permission to run DBCC CHECKIDENT

I have created a stored procedure in which i have created a temproray table with 2 fields, one is IDENTITY column and i set the seed by using DBCC CHECKIDENT but it gave an error about permission.

Please give suggestion for resolving this issue.

DBCC CHECKIDENT permissions default to the table owner, members of the sysadmin fixed server role, and the db_owner and db_ddladmin fixed database role

Pls check the ONLINE Document for more details..

Wednesday, March 7, 2012

Does anyone know that where have the most mssql extended procedures for download?

I have a extended procedure for sending email by smtp already.

Are there anywheres can be downloaded the rest?
e.g. copy, move, detect, and delete some files and directories in harddisk
access Active directories
read and write .ini files
etc......I suggest you search 'Books Online', the help files for MS Sql Server.|||I just know C# & VB only, and i don't know C/C++.

those are useless.

Sunday, February 26, 2012

does anyone know about this err msg?

sql2k, nt5.
I have a stored procedure drop and re-create webtask... this is the msg i've
got when running it.
Msg 16805, Sev 11: SQL Web Assistant: Could not execute the SQL statement.
[SQLSTATE 42000]
does anyone know what it's about? thank you.
Steve,
You may find an explanation of this at:
http://support.microsoft.com/default...b;en-us;834116
Hope it helps,
Russell Fields
"Steve Lin" <lins@.nospam.portptld.com> wrote in message
news:On50IjJKEHA.2580@.TK2MSFTNGP12.phx.gbl...
> sql2k, nt5.
> I have a stored procedure drop and re-create webtask... this is the msg
i've
> got when running it.
> Msg 16805, Sev 11: SQL Web Assistant: Could not execute the SQL statement.
> [SQLSTATE 42000]
> does anyone know what it's about? thank you.
>
|||the job owner is sa.
I have read that article before and don't think it's related to my problem.
because the errors come and go and not related to a particular record in the
table either.
"Russell Fields" <RussellFields@.NoMailPlease.Com> wrote in message
news:OUX#goKKEHA.2888@.TK2MSFTNGP09.phx.gbl...[vbcol=seagreen]
> Steve,
> You may find an explanation of this at:
> http://support.microsoft.com/default...b;en-us;834116
> Hope it helps,
> Russell Fields
> "Steve Lin" <lins@.nospam.portptld.com> wrote in message
> news:On50IjJKEHA.2580@.TK2MSFTNGP12.phx.gbl...
> i've
statement.
>
|||Steve,
Sorry that I don't know a lot more than this. However, it is interesting
that you are running as 'sa', which I would interpret to mean you are using
Method 2 to try to work around the problem. Method 1 is to use a domain
account that has admin permissions on your server. (Interestingly, both
workarounds are "not recommended" by Microsoft.)
Anyway, have you tried the Method 1 workaround? Did it change things at
all?
You mention that the errors come and go. Do you have any idea of whether
something else in your security landscape is changing?
Russell Fields
"Steve Lin" <lins@.nospam.portptld.com> wrote in message
news:utbyTRMKEHA.2580@.TK2MSFTNGP12.phx.gbl...
> the job owner is sa.
> I have read that article before and don't think it's related to my
problem.
> because the errors come and go and not related to a particular record in
the[vbcol=seagreen]
> table either.
> "Russell Fields" <RussellFields@.NoMailPlease.Com> wrote in message
> news:OUX#goKKEHA.2888@.TK2MSFTNGP09.phx.gbl...
msg
> statement.
>

does anyone know about this err msg?

sql2k, nt5.
I have a stored procedure drop and re-create webtask... this is the msg i've
got when running it.
Msg 16805, Sev 11: SQL Web Assistant: Could not execute the SQL statement.
[SQLSTATE 42000]
does anyone know what it's about? thank you.Steve,
You may find an explanation of this at:
http://support.microsoft.com/default.aspx?scid=kb;en-us;834116
Hope it helps,
Russell Fields
"Steve Lin" <lins@.nospam.portptld.com> wrote in message
news:On50IjJKEHA.2580@.TK2MSFTNGP12.phx.gbl...
> sql2k, nt5.
> I have a stored procedure drop and re-create webtask... this is the msg
i've
> got when running it.
> Msg 16805, Sev 11: SQL Web Assistant: Could not execute the SQL statement.
> [SQLSTATE 42000]
> does anyone know what it's about? thank you.
>|||the job owner is sa.
I have read that article before and don't think it's related to my problem.
because the errors come and go and not related to a particular record in the
table either.
"Russell Fields" <RussellFields@.NoMailPlease.Com> wrote in message
news:OUX#goKKEHA.2888@.TK2MSFTNGP09.phx.gbl...
> Steve,
> You may find an explanation of this at:
> http://support.microsoft.com/default.aspx?scid=kb;en-us;834116
> Hope it helps,
> Russell Fields
> "Steve Lin" <lins@.nospam.portptld.com> wrote in message
> news:On50IjJKEHA.2580@.TK2MSFTNGP12.phx.gbl...
> >
> > sql2k, nt5.
> > I have a stored procedure drop and re-create webtask... this is the msg
> i've
> > got when running it.
> >
> > Msg 16805, Sev 11: SQL Web Assistant: Could not execute the SQL
statement.
> > [SQLSTATE 42000]
> >
> > does anyone know what it's about? thank you.
> >
> >
>|||Steve,
Sorry that I don't know a lot more than this. However, it is interesting
that you are running as 'sa', which I would interpret to mean you are using
Method 2 to try to work around the problem. Method 1 is to use a domain
account that has admin permissions on your server. (Interestingly, both
workarounds are "not recommended" by Microsoft.)
Anyway, have you tried the Method 1 workaround? Did it change things at
all?
You mention that the errors come and go. Do you have any idea of whether
something else in your security landscape is changing?
Russell Fields
"Steve Lin" <lins@.nospam.portptld.com> wrote in message
news:utbyTRMKEHA.2580@.TK2MSFTNGP12.phx.gbl...
> the job owner is sa.
> I have read that article before and don't think it's related to my
problem.
> because the errors come and go and not related to a particular record in
the
> table either.
> "Russell Fields" <RussellFields@.NoMailPlease.Com> wrote in message
> news:OUX#goKKEHA.2888@.TK2MSFTNGP09.phx.gbl...
> > Steve,
> >
> > You may find an explanation of this at:
> > http://support.microsoft.com/default.aspx?scid=kb;en-us;834116
> >
> > Hope it helps,
> > Russell Fields
> >
> > "Steve Lin" <lins@.nospam.portptld.com> wrote in message
> > news:On50IjJKEHA.2580@.TK2MSFTNGP12.phx.gbl...
> > >
> > > sql2k, nt5.
> > > I have a stored procedure drop and re-create webtask... this is the
msg
> > i've
> > > got when running it.
> > >
> > > Msg 16805, Sev 11: SQL Web Assistant: Could not execute the SQL
> statement.
> > > [SQLSTATE 42000]
> > >
> > > does anyone know what it's about? thank you.
> > >
> > >
> >
> >
>

does anyone know about this err msg?

sql2k, nt5.
I have a stored procedure drop and re-create webtask... this is the msg i've
got when running it.
Msg 16805, Sev 11: SQL Web Assistant: Could not execute the SQL statement.
[SQLSTATE 42000]
does anyone know what it's about? thank you.Steve,
You may find an explanation of this at:
http://support.microsoft.com/defaul...kb;en-us;834116
Hope it helps,
Russell Fields
"Steve Lin" <lins@.nospam.portptld.com> wrote in message
news:On50IjJKEHA.2580@.TK2MSFTNGP12.phx.gbl...
> sql2k, nt5.
> I have a stored procedure drop and re-create webtask... this is the msg
i've
> got when running it.
> Msg 16805, Sev 11: SQL Web Assistant: Could not execute the SQL statement.
> [SQLSTATE 42000]
> does anyone know what it's about? thank you.
>|||the job owner is sa.
I have read that article before and don't think it's related to my problem.
because the errors come and go and not related to a particular record in the
table either.
"Russell Fields" <RussellFields@.NoMailPlease.Com> wrote in message
news:OUX#goKKEHA.2888@.TK2MSFTNGP09.phx.gbl...
> Steve,
> You may find an explanation of this at:
> http://support.microsoft.com/defaul...kb;en-us;834116
> Hope it helps,
> Russell Fields
> "Steve Lin" <lins@.nospam.portptld.com> wrote in message
> news:On50IjJKEHA.2580@.TK2MSFTNGP12.phx.gbl...
> i've
statement.[vbcol=seagreen]
>|||Steve,
Sorry that I don't know a lot more than this. However, it is interesting
that you are running as 'sa', which I would interpret to mean you are using
Method 2 to try to work around the problem. Method 1 is to use a domain
account that has admin permissions on your server. (Interestingly, both
workarounds are "not recommended" by Microsoft.)
Anyway, have you tried the Method 1 workaround? Did it change things at
all?
You mention that the errors come and go. Do you have any idea of whether
something else in your security landscape is changing?
Russell Fields
"Steve Lin" <lins@.nospam.portptld.com> wrote in message
news:utbyTRMKEHA.2580@.TK2MSFTNGP12.phx.gbl...
> the job owner is sa.
> I have read that article before and don't think it's related to my
problem.
> because the errors come and go and not related to a particular record in
the
> table either.
> "Russell Fields" <RussellFields@.NoMailPlease.Com> wrote in message
> news:OUX#goKKEHA.2888@.TK2MSFTNGP09.phx.gbl...
msg[vbcol=seagreen]
> statement.
>

Does anyone have an ForEachColumn Procedure?

Hi

Does anyone have an ForEachColumn Procedure?
(a bit like the MSforeachdb and MSforeachtable sps)

This should be quite generic for anyone working with real life data coming in from other systems.

I need to fill out the rows with missing values in historic records from the previous current record.
(sometimes even from a previous historic record)
And sometimes the current record doesn't have data in the field, so I shouldn't get the data from current -1.

Can solve most of the complexities of the filling out part.

But it needs to be applied for (most of) my 57 columns,and then there is even some differently formatted data just beyond the horizon, so maybe I should try to get a more generic applicable solution.

Did anyone try a ForEachColumnExcept procedure

CREATE PROCEDURE ForEachColumnExcept
@.TableName varchar(200)
, @.ExceptionList varchar(8000) = '' -- the few ones to exclude
, @.DelimterInExceptionlist varchar(10) = ','
AS
...
END

the difficulty here is getting the columns from the databse's data-dictionary
)haven't done that before, but I think I'll find that out.

Or even:

CREATE PROCEDURE ForEachColumnInList
@.TableName varchar(200)
, @.ColumnList varchar(8000) -- all the ones to include
, @.DelimterInColumnList varchar(10) = ','
AS
...
END

Cheers

Drionot sure what u finally want to do with the column list, this will however generate a column list & data type based on params u declared

set @.ExceptionList = ','+ @.ExceptionList + ','
select Column_name,Data_Type from information_schema.columns
where table_name=@.TableName and column_name not in (case when charindex(','+column_name+',',@.ExceptionList) > 0 then column_name else '' end)

does anybody knows....

does anyone knows how to get all the stored procedure by using C#
You can query the INFORMATION_SCHEMA.PROCEDURES view to retrieve the names of the stored procedures.
Check out Dave Penton'sINFORMATION_SCHEMA View Examples web page for some code on how to do this in C#.
|||

Hi,
If you run the below statement you wil get the list of stored procedures in that database.

SELECT * FROM SYSOBJECTS WHERE xtype = 'P'

Eralper
http://www.kodyaz.com

|||

eralper wrote:

If you run the below statement you wil get the list of stored procedures in that database.
SELECT * FROM SYSOBJECTS WHERE xtype = 'P'


Directly querying the sys* tables is discouraged by Microsoft as they are not guaranteed to be backwards-compatible. The INFORMATION_SCHEMA views are the recommended approach. See this discussion among a few SQL Server MVPs (including Adam Machanic) on this issue:Use the sys tables or INFORMATION_SCHEMA tables?.

Does a user have EXEC permission for a stored procedure?

Given a user name and a stored procedure name, can someone provide me with
the TSQL code to set a boolean indicating whether that user has EXEC
permission to that proc?
The specific proc I'm interested in is xp_loginconfig.
Thanks in advance for your help,
Hal Heinrich
VP Technology
Aralan Solutions Inc.SQL Server Books Online states that the execute permissions for
xp_loginconfig default to members of the db_owner fixed database role in the
master database and members of the symin fixed server role, but can be
granted to other database users. So if the user is not a member of the dbo
role in master, you can use a simple GRANT statement like:
GRANT EXECUTE ON xp_loginconfig TO <youruser> ;
Anith|||Assuming a proc named 'myproc' and a user 'Jones', here's a snippet that
will check for exec priv.
declare @.name sysname, @.myboolean bit
set @.name = 'Jones'
if exists (select *
from sysprotects
where id = object_id('myproc')
and uid = (select uid from sysusers where name = @.name)
and action = 224
and protecttype <> 206)
set @.myboolean = 1
else
set @.myboolean = 0
select @.myboolean
"Hal Heinrich" <HalHeinrich@.discussions.microsoft.com> wrote in message
news:ADE5D31A-7F11-4782-A560-EDEA7E89D3CA@.microsoft.com...
> Given a user name and a stored procedure name, can someone provide me with
> the TSQL code to set a boolean indicating whether that user has EXEC
> permission to that proc?
> The specific proc I'm interested in is xp_loginconfig.
> Thanks in advance for your help,
> Hal Heinrich
> VP Technology
> Aralan Solutions Inc.|||Hi Armando,
Thanks for your reply - it certainly gave me some things to try.
First off, if I run:
SELECT COUNT(*) FROM dbo.sysprotects WHERE (id = OBJECT_ID('xp_loginconfig')
)
I get zero back. Also
SELECT COUNT(*) FROM dbo.sysobjects WHERE (id = OBJECT_ID('xp_loginconfig'))
returns zero. So this looks like a dead end.
Now if I run:
SELECT COUNT(*) FROM dbo.sysprotects WHERE (id = OBJECT_ID('myproc'))
I get one back. So far so good. Next I run:
SELECT dbo.sysusers.name FROM dbo.sysprotects INNER JOIN
dbo.sysusers ON dbo.sysprotects.uid = dbo.sysusers.uid
WHERE (dbo.sysprotects.id = OBJECT_ID('myproc'))
which returns a single name, but not 'Jones' - who does have execute
permission.
So this also looks like a dead end.
Any thoughts or suggestions?
Thanks, Hal
"Armando Prato" wrote:

> Assuming a proc named 'myproc' and a user 'Jones', here's a snippet that
> will check for exec priv.
> declare @.name sysname, @.myboolean bit
> set @.name = 'Jones'
> if exists (select *
> from sysprotects
> where id = object_id('myproc')
> and uid = (select uid from sysusers where name = @.name)
> and action = 224
> and protecttype <> 206)
> set @.myboolean = 1
> else
> set @.myboolean = 0
> select @.myboolean
>
> "Hal Heinrich" <HalHeinrich@.discussions.microsoft.com> wrote in message
> news:ADE5D31A-7F11-4782-A560-EDEA7E89D3CA@.microsoft.com...
>
>|||Anith,
Thank you for replying. However, my question is not "how do you grant?",
rather it is "how can you tell?"
Hal
"Anith Sen" wrote:

> SQL Server Books Online states that the execute permissions for
> xp_loginconfig default to members of the db_owner fixed database role in t
he
> master database and members of the symin fixed server role, but can be
> granted to other database users. So if the user is not a member of the dbo
> role in master, you can use a simple GRANT statement like:
> GRANT EXECUTE ON xp_loginconfig TO <youruser> ;
> --
> Anith
>
>|||Couple of things come to mind
Did you run against the master database? Extended stored procs live
in master and are not found in newly created databases. Also, did you
explicitly
grant execute to the user(s) in question?
The query...
SELECT dbo.sysusers.name
FROM dbo.sysprotects
JOIN dbo.sysusers ON (dbo.sysprotects.uid = dbo.sysusers.uid)
WHERE (dbo.sysprotects.id = OBJECT_ID('xp_loginconfig'))
...looks ok. It just sounds like you need to explicitly grant execute
to all users you expect will have this permission outside of the dbo.
Here is the BOL snippet on this xp:
Execute permissions for xp_loginconfig default to members of the db_owner
fixed database role in the master database and members of the symin fixed
server role, but can be granted to other users.
"Hal Heinrich" <HalHeinrich@.discussions.microsoft.com> wrote in message
news:81ED433C-8190-45F1-8FC5-07ED38DDCFD4@.microsoft.com...
> Hi Armando,
> Thanks for your reply - it certainly gave me some things to try.
> First off, if I run:
> SELECT COUNT(*) FROM dbo.sysprotects WHERE (id =
OBJECT_ID('xp_loginconfig'))ed">
> I get zero back. Also
> SELECT COUNT(*) FROM dbo.sysobjects WHERE (id =
OBJECT_ID('xp_loginconfig'))[color=darkr
ed]
> returns zero. So this looks like a dead end.
> Now if I run:
> SELECT COUNT(*) FROM dbo.sysprotects WHERE (id = OBJECT_ID('myproc'))
> I get one back. So far so good. Next I run:
> SELECT dbo.sysusers.name FROM dbo.sysprotects INNER JOIN
> dbo.sysusers ON dbo.sysprotects.uid = dbo.sysusers.uid
> WHERE (dbo.sysprotects.id = OBJECT_ID('myproc'))
> which returns a single name, but not 'Jones' - who does have execute
> permission.
> So this also looks like a dead end.
> Any thoughts or suggestions?
> Thanks, Hal
> "Armando Prato" wrote:
>
that
with|||>> However, my question is not "how do you grant?", rather it is "how can
Have you looked in to the PERMISSIONS() function?
Anith

Sunday, February 19, 2012

Documenting Permissions on SQL Server 7.0 and 2000

http://support.microsoft.com/default.aspx?scid=kb;en-us;179158&Product=sq
I found the above article which shows a stored procedure for SQL Server 6.5 which documents all permissions for a particular Database
Is there a way to document permissions on SQL Server 7 and 2000 instances?
Thank you in advancewhat is wrong with exec sp_helprotect (sql 2000).
--
Niall Litchfield
Oracle DBA
Audit Commission UK
"Janice Potucek" <janice.potucek@.nextiraone.com> wrote in message
news:89BABFBC-3EC8-4D17-BB3D-51DF05A7820E@.microsoft.com...
> http://support.microsoft.com/default.aspx?scid=kb;en-us;179158&Product=sql
> I found the above article which shows a stored procedure for SQL Server
6.5 which documents all permissions for a particular Database.
> Is there a way to document permissions on SQL Server 7 and 2000
instances?
> Thank you in advance|||Thank you. That was what I was looking for!!!!
I have been trying different combinations of parameters ... what I
would like to see is only the default database, Server Roles and
Database access permissions for a particular user. Is there a way to
get only that information? It is very tedious documenting this
manually.
Thank you in advance,
J Potucek
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Tuesday, February 14, 2012

doc on xp_availablemedia

I tried to find the document on xp_availablemedia extended procedure but
couldn't find it on online help or support microsoft website. Can you please
tell me what it is doing? Thanks.
Hi,
The xp_availablemedia extended stored procedure is used to return a list of
available storage
devices that can be written to. It doesn't require any special signature
definitions,
because all you have to do to use it is call it directly, with no parameters
Thanks
Hari
MCDBA
"Eric Clapton" <no_spam@.bk.com> wrote in message
news:uwcqVr7OEHA.3596@.tk2msftngp13.phx.gbl...
> I tried to find the document on xp_availablemedia extended procedure but
> couldn't find it on online help or support microsoft website. Can you
please
> tell me what it is doing? Thanks.
>
>
|||Dear Try this ,
http://www.remainsecure.com/whitepap...l/sqlcheck.htm
Regards
Faheem Latif
Network Solutions

doc on xp_availablemedia

I tried to find the document on xp_availablemedia extended procedure but
couldn't find it on online help or support microsoft website. Can you please
tell me what it is doing? Thanks.
>
> I tried to find the document on xp_availablemedia extended procedure but
> couldn't find it on online help or support microsoft website. Can you
please
> tell me what it is doing? Thanks.
The system stored procedure xp_availablemedia is UNDOCUMENTED. The behavior
of xp_availablemedia may change across service packs and SQL Server
versions.
This system stored procedure is used when backing up and restoring from SQL
Server Enterprise Manager.
This system stored procedure is mentioned in this article:
PRB: "Error 229: Execute Permission Denied on Object 'xp_availablemedia'
Owner 'dbo'"
http://support.microsoft.com/?id=323249
Why do you want to know? Do you have a specific issue that you need to
address? Perhaps we can help in that area.
Cheers,
Eric Crdenas
Senior support professional
This posting is provided "AS IS" with no warranties, and confers no rights.

doc on xp_availablemedia

I tried to find the document on xp_availablemedia extended procedure but
couldn't find it on online help or support microsoft website. Can you please
tell me what it is doing? Thanks.Hi,
The xp_availablemedia extended stored procedure is used to return a list of
available storage
devices that can be written to. It doesn't require any special signature
definitions,
because all you have to do to use it is call it directly, with no parameters
Thanks
Hari
MCDBA
"Eric Clapton" <no_spam@.bk.com> wrote in message
news:uwcqVr7OEHA.3596@.tk2msftngp13.phx.gbl...
> I tried to find the document on xp_availablemedia extended procedure but
> couldn't find it on online help or support microsoft website. Can you
please
> tell me what it is doing? Thanks.
>
>|||Dear Try this ,
http://www.remainsecure.com/whitepa...ql/sqlcheck.htm
Regards
Faheem Latif
Network Solutions

doc on xp_availablemedia

I tried to find the document on xp_availablemedia extended procedure but
couldn't find it on online help or support microsoft website. Can you please
tell me what it is doing? Thanks.>
> I tried to find the document on xp_availablemedia extended procedure but
> couldn't find it on online help or support microsoft website. Can you
please
> tell me what it is doing? Thanks.
--
The system stored procedure xp_availablemedia is UNDOCUMENTED. The behavior
of xp_availablemedia may change across service packs and SQL Server
versions.
This system stored procedure is used when backing up and restoring from SQL
Server Enterprise Manager.
This system stored procedure is mentioned in this article:
PRB: "Error 229: Execute Permission Denied on Object 'xp_availablemedia'
Owner 'dbo'"
http://support.microsoft.com/?id=323249
Why do you want to know? Do you have a specific issue that you need to
address? Perhaps we can help in that area.
Cheers,
Eric Crdenas
Senior support professional
This posting is provided "AS IS" with no warranties, and confers no rights.

doc on xp_availablemedia

I tried to find the document on xp_availablemedia extended procedure but
couldn't find it on online help or support microsoft website. Can you please
tell me what it is doing? Thanks.>
> I tried to find the document on xp_availablemedia extended procedure but
> couldn't find it on online help or support microsoft website. Can you
please
> tell me what it is doing? Thanks.
--
The system stored procedure xp_availablemedia is UNDOCUMENTED. The behavior
of xp_availablemedia may change across service packs and SQL Server
versions.
This system stored procedure is used when backing up and restoring from SQL
Server Enterprise Manager.
This system stored procedure is mentioned in this article:
PRB: "Error 229: Execute Permission Denied on Object 'xp_availablemedia'
Owner 'dbo'"
http://support.microsoft.com/?id=323249
Why do you want to know? Do you have a specific issue that you need to
address? Perhaps we can help in that area.
Cheers,
--
Eric Cárdenas
Senior support professional
This posting is provided "AS IS" with no warranties, and confers no rights.

doc on xp_availablemedia

I tried to find the document on xp_availablemedia extended procedure but
couldn't find it on online help or support microsoft website. Can you please
tell me what it is doing? Thanks.Hi,
The xp_availablemedia extended stored procedure is used to return a list of
available storage
devices that can be written to. It doesn't require any special signature
definitions,
because all you have to do to use it is call it directly, with no parameters
Thanks
Hari
MCDBA
"Eric Clapton" <no_spam@.bk.com> wrote in message
news:uwcqVr7OEHA.3596@.tk2msftngp13.phx.gbl...
> I tried to find the document on xp_availablemedia extended procedure but
> couldn't find it on online help or support microsoft website. Can you
please
> tell me what it is doing? Thanks.
>
>|||Dear Try this
http://www.remainsecure.com/whitepapers/database/mssql/sqlcheck.ht
Regards
Faheem Latif
Network Solutions

Do you understand this Error msg (ERROR Msg 512, Level 16, State 1, Line 33)

I have created a procedure which start by fecthing data from DB-X and put in into the temporary memory. what im trying to do now is to take data from temporary memory insert/update DB-Y.

But now I get this ERROR Msg 512, Level 16, State 1, Line 33
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

HERE IS MY PROCEDURE

DECLARE @.MineID int,
@.MineName varchar(80),
@.MineDescription [varchar](80) ,
@.MineLocation varchar(80),
@.Country varchar(80),
@.Northing float,
@.Easting float,
@.Elevation float,
@.Latitude float ,
@.Longitude float,
@.MineLogo varbinary(max)

DECLARE MYCURSOR CURSOR
FOR SELECT * FROM [TLC].[DBO].[MINE]
OPEN MYCURSOR
FETCH NEXT FROM MYCURSOR INTO
@.MineID,
@.MineName ,
@.MineDescription ,
@.MineLocation ,
@.Country ,
@.Northing ,
@.Easting ,
@.Elevation ,
@.Latitude,
@.Longitude,
@.MineLogo
WHILE @.@.FETCH_STATUS = 0

BEGIN

IF @.MineID =(select MineID from [TEST].[dbo].[MINE1])
SET IDENTITY_INSERT [TEST].[dbo].[MINE1] ON
BEGIN UPDATE [TEST].[dbo].[MINE1]
SET MineName = @.MineName
,MineDescription = @.MineDescription
,MineLocation = @.MineLocation
,Country =@.Country
,Northing = @.Northing
,Easting = @.Easting
,Elevation = @.Elevation
,Latitude = @.Latitude
,Longitude = @.Longitude
,MineLogo =@.MineLogo
where MineId = @.MineID

END
IF @.MineID <> (select MineID from [TEST].[dbo].[MINE1])
SET IDENTITY_INSERT [TEST].[dbo].[MINE1] ON
INSERT INTO [TEST].[dbo].[MINE1]
(MineID
,MineName
,MineDescription
,MineLocation
,Country
,Northing
,Easting
,Elevation
,Latitude
,Longitude
,MineLogo )
VALUES (
@.MineID
,@.MineName
,@.MineDescription
,@.MineLocation
,@.Country
,@.Northing
,@.Easting
,@.Elevation
,@.Latitude
,@.Longitude
,@.MineLogo)

FETCH NEXT FROM MYCURSOR INTO

@.MineID,
@.MineName ,
@.MineDescription ,
@.MineLocation ,
@.Country ,
@.Northing ,
@.Easting ,
@.Elevation ,
@.Latitude,
@.Longitude,
@.MineLogo

END
SET IDENTITY_INSERT [TEST].[dbo].[MINE1] OFF
SET IDENTITY_INSERT [TEST].[dbo].[MINE1] OFF
CLOSE MYCURSOR
DEALLOCATE MYCURSORYou don't need cursors for this purpose. Please look at following sample that demonstrates how you should synchronize your data:

create database temp
create database temp1
go
create table temp.dbo.mine(id int identity, name nvarchar(max))
create table temp1.dbo.mine(id int identity, name nvarchar(max))

insert temp.dbo.mine(name) values('UpdatedValue1')
insert temp.dbo.mine(name) values('UpdatedValue2')
insert temp.dbo.mine(name) values('UpdatedValue3')
insert temp.dbo.mine(name) values('UpdatedValue4')
insert temp.dbo.mine(name) values('UpdatedValue5')
insert temp.dbo.mine(name) values('NewValue6')
insert temp1.dbo.mine(name) values('OldValue1')
insert temp1.dbo.mine(name) values('OldValue2')
insert temp1.dbo.mine(name) values('OldValue3')
insert temp1.dbo.mine(name) values('OldValue4')
insert temp1.dbo.mine(name) values('OldValue5')
select * from temp.dbo.mine
select * from temp1.dbo.mine

update temp1.dbo.mine
set
name = Source.name
from temp.dbo.mine Source
where mine.id = Source.id

set identity_insert temp1.dbo.mine on
insert temp1.dbo.mine(id, name)
select id, name
from temp.dbo.mine
where id not in (select id from temp1.dbo.mine)
set identity_insert temp1.dbo.mine off

select * from temp.dbo.mine
select * from temp1.dbo.mine

drop database temp
drop database temp1
|||Thank you for your response, But my problem is not resolved yet, What im actually trying to do is to take data from Another DB-TLC to DB-Test. And these two database they are not integrated and we can't intergrate them.So what will happen is: if the data exist it can update else insert a new record. I'm not creating database from scratch.

this error is trigged by these statemement

IF @.BlasterID <> (select BlasterID from Blasters )
INSERT INTO [TEST].[dbo].[Blasters]

BELOW IS THE ERROR
{Msg 512, Level 16, State 1, Line 33
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.}

It seems like SQL doesn't want that , I have also tried the IF NOT EXIST clause but still it doesn't help. Please if you have any ideas agains on how to handle this with SQL please help|||

Quote:

Originally Posted by Sally1053

Thank you for your response, But my problem is not resolved yet, What im actually trying to do is to take data from Another DB-TLC to DB-Test

Have you looked at sample I provided? It demonstrates how to synchronize data from two different databases in more efficient way than you do.
--
Concerning your particular problem with
IF @.BlasterID <> (select BlasterID from Blasters ):
You can compare a variable (@.BlasterID) with resultset (select BlasterID from Blasters) only when resultset contains a single row with single column. In your case resultset contains all rows from Blasters table, not one. Correct solution is:
IF NOT EXISTS (select * from Blasters WHERE BlasterID = @.BlasterID)

Do While in SQL !

Hi Everybody,

I wanna know how to do a "Do While" inner SQL Query Analyser or in a Stored Procedure.
Usually I have to make some programs in VB to go until End of File and in each row depending of course of a condition I make a INSERT/UPDATE/DELETE.

The VB Code is such as:

strSQL = "SELECT id FROM table ORDER BY id"
Set objRs = Conn.Execute(strSQL)
If not objRs.EOF Then
Do Until objRs.EOF
strSQL = "UPDATE Table SET field = 'x' WHERE id = '"& objRs(0) &"'"
Conn.Execute(strSQL)
objRs.MoveNext
Loop
End If

How it Works in SQL? Using While?

Tanks,Using CURSOR allows you to loop, just like an ADO.Recordset. Each FETCH sets a global variable called @.@.fetch_status, which is your test condition (EOF).

If the table you are updating is the table that the cursor is on look at using the option WHERE CURRENT OF under UPDATE on Books On Line

declare @.id int

declare tb_cur cursor
for
select id
from table
order by id

open tb_cur

fetch next from tb_cur into @.id

while @.@.fetch_status = 0 begin
UPDATE Table SET field = 'x'
WHERE id = @.id

fetch next from tb_cur into @.id
end

close tb_cur
deallocate tb_cur|||You are dealing with a relational database and sql. Trying to use procedural code will get you into trouble as well as giving extremely poor performance. Use of cursors usully indicates a poor design or lack of sql knowledge - you will find that they are never needed on sql server.

In your case here

strSQL = "SELECT id FROM table ORDER BY id"
Set objRs = Conn.Execute(strSQL)
If not objRs.EOF Then
Do Until objRs.EOF
strSQL = "UPDATE Table SET field = 'x' WHERE id = '"& objRs(0) &"'"
Conn.Execute(strSQL)
objRs.MoveNext
Loop
End If

update tbl
set field = 'x'

look at the case statement and where clause for a conditional update

if you want to loop through each row

declare @.id int, @.maxis int
select @.id = 0, @.maxid = max(id) from table
while @.id < @.maxid
begin
select @.id = min(id) from table where id > @.id
update table set field = 'x' where id = @.id
end

as I say don't try to use this on large tables or those which are multiuser.