Showing posts with label multiple. Show all posts
Showing posts with label multiple. Show all posts

Thursday, March 29, 2012

Attach DB Without Transaction Logs

Hi, there,

I have multiple transaction log files. I don't need the transaction logs and intended to remove them. I have tried detaching the database, rename the logs and trying to re-attach the database without the logs but to no avail. The error message mentioned something like file activation failed and SQL couldn't rebuild the transaction logs.

Is there a way to get rid of the transaction log files?

Thank you.

Regards,

Yong Hwee

Hi,

you can use sp_attach_single_file_db but it works only on databases that have a single log file.

When sp_attach_single_file_db attaches the database to the server, it builds a new log file. If the database is read-only, the log file is built in its previous location.

...

OR by reading this thread attaching DB without .ldf file ?

CU

tosc

|||

Hi, Tosc,

Thank you for your immediate reply. It seems like there is no workaround for database with multiple log files.

Regards,

Yong Hwee

|||

There are lot of limitation with sp_attach_single_file_db. The database should not have morethan one LOG and Datafile and the database should be properly detached. So in your case this process will not do. You requirement is to remove the Secondary LOG File, if am correct. What you can do is, Remove the secondary log file first using

DBCC SHRINKFILE (,EMPTYFILE)
alter database test remove file .

Then you can trucate the primary log file to any size you want. Please take backup of the database before starting anything

Madhu

Refer : http://madhuottapalam.blogspot.com/search?q=Transaction+Log

Madhu

|||

In SQL Server 2005 you can you use CREATE DATABASE syntax to rebuild the log. The ATTACH_REBUILD_LOG syntax should work even if there are multiple log files.

|||

Hi, there,

Thank you for your reply. I managed to delete the log by first backup with option to truncate log after which I change the database to simple recovery. I can delete the logs this way.

Thank you.

Regards,

Yong Hwee

Sunday, March 25, 2012

Attach a Database from multiple computers? (SQL Server Express 2005)

Can multiple computers,running SQL Server Express 2005, simultaneously
attach to a single database file, hosted on a networked drive? Eg
does one instance of Express lock the database when it is attached?
I am replacing Access db calls in a program and it access a db on a
shared location. I would rather not try to get the client to set up a
network enabled Express server!
"David" <dm_fw@.sbcglobal.net> wrote in message
news:6uo2i2528b3ju7vp1bqbm7hi8d8ft3fe7r@.4ax.com...
> Can multiple computers,running SQL Server Express 2005, simultaneously
> attach to a single database file, hosted on a networked drive?
No. A SQL Server instance requires exclusive access to its database files.
And moreover attaching database files on a network is not supported.

>Eg
> does one instance of Express lock the database when it is attached?
> I am replacing Access db calls in a program and it access a db on a
> shared location. I would rather not try to get the client to set up a
> network enabled Express server!
Well, that's just the way SQL Server works.
David
|||"David" <dm_fw@.sbcglobal.net> wrote in message
news:6uo2i2528b3ju7vp1bqbm7hi8d8ft3fe7r@.4ax.com...
> I am replacing Access db calls in a program and it access a db on a
> shared location. I would rather not try to get the client to set up a
> network enabled Express server!
Then you are using the wrong product. What on earth would be the point of
replacing Jet with just another file sharing program?
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx

Attach a Database from multiple computers? (SQL Server Express 2005)

Can multiple computers,running SQL Server Express 2005, simultaneously
attach to a single database file, hosted on a networked drive? Eg
does one instance of Express lock the database when it is attached?
I am replacing Access db calls in a program and it access a db on a
shared location. I would rather not try to get the client to set up a
network enabled Express server!"David" <dm_fw@.sbcglobal.net> wrote in message
news:6uo2i2528b3ju7vp1bqbm7hi8d8ft3fe7r@.4ax.com...
> Can multiple computers,running SQL Server Express 2005, simultaneously
> attach to a single database file, hosted on a networked drive?
No. A SQL Server instance requires exclusive access to its database files.
And moreover attaching database files on a network is not supported.
>Eg
> does one instance of Express lock the database when it is attached?
> I am replacing Access db calls in a program and it access a db on a
> shared location. I would rather not try to get the client to set up a
> network enabled Express server!
Well, that's just the way SQL Server works.
David|||"David" <dm_fw@.sbcglobal.net> wrote in message
news:6uo2i2528b3ju7vp1bqbm7hi8d8ft3fe7r@.4ax.com...
> I am replacing Access db calls in a program and it access a db on a
> shared location. I would rather not try to get the client to set up a
> network enabled Express server!
Then you are using the wrong product. What on earth would be the point of
replacing Jet with just another file sharing program?
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--

Attach a Database from multiple computers? (SQL Server Express 2005)

Can multiple computers,running SQL Server Express 2005, simultaneously
attach to a single database file, hosted on a networked drive? Eg
does one instance of Express lock the database when it is attached?
I am replacing Access db calls in a program and it access a db on a
shared location. I would rather not try to get the client to set up a
network enabled Express server!"David" <dm_fw@.sbcglobal.net> wrote in message
news:6uo2i2528b3ju7vp1bqbm7hi8d8ft3fe7r@.
4ax.com...
> Can multiple computers,running SQL Server Express 2005, simultaneously
> attach to a single database file, hosted on a networked drive?
No. A SQL Server instance requires exclusive access to its database files.
And moreover attaching database files on a network is not supported.

>Eg
> does one instance of Express lock the database when it is attached?
> I am replacing Access db calls in a program and it access a db on a
> shared location. I would rather not try to get the client to set up a
> network enabled Express server!
Well, that's just the way SQL Server works.
David|||"David" <dm_fw@.sbcglobal.net> wrote in message
news:6uo2i2528b3ju7vp1bqbm7hi8d8ft3fe7r@.
4ax.com...
> I am replacing Access db calls in a program and it access a db on a
> shared location. I would rather not try to get the client to set up a
> network enabled Express server!
Then you are using the wrong product. What on earth would be the point of
replacing Jet with just another file sharing program?
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--

Attach & Detach Multiple Databases

SQL Server 2000 Standard
I need to move multiple databases (about 20) from the C partition to the E
partition. I'm familiar with sp_detach_db and sp_attach_db scripts and is OK
for a handful of databases but tedious with 10 or more databases. My manager
suggested "looping" or something like that. In other words he wants a method
to move these databases in an efficient script. I looked into using SSEUTIL
but that gives me a "mssql$sqlexpress is not installed" error message,
looking for SQL Server Express 2005. I'm sure what I'm asking isn't something
new.check out master.dbo.sysaltfiles for file paths. then you can dynamically
create the detach/attach scripts using sysdatabases and sysaltfiles.
think like this:
select 'sp_detach ... ' + name + '
go'
from sysdatabases
I use such constructs all the time to create scripts to execute.
--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net
"JosephV" <JosephV@.discussions.microsoft.com> wrote in message
news:AEF01BE7-44DF-4DEC-90B1-285AEDA95069@.microsoft.com...
> SQL Server 2000 Standard
> I need to move multiple databases (about 20) from the C partition to the E
> partition. I'm familiar with sp_detach_db and sp_attach_db scripts and is
> OK
> for a handful of databases but tedious with 10 or more databases. My
> manager
> suggested "looping" or something like that. In other words he wants a
> method
> to move these databases in an efficient script. I looked into using
> SSEUTIL
> but that gives me a "mssql$sqlexpress is not installed" error message,
> looking for SQL Server Express 2005. I'm sure what I'm asking isn't
> something
> new.|||Thanks. I'll research your suggestion.
"TheSQLGuru" wrote:
> check out master.dbo.sysaltfiles for file paths. then you can dynamically
> create the detach/attach scripts using sysdatabases and sysaltfiles.
> think like this:
> select 'sp_detach ... ' + name + '
> go'
> from sysdatabases
> I use such constructs all the time to create scripts to execute.
> --
> Kevin G. Boles
> Indicium Resources, Inc.
> SQL Server MVP
> kgboles a earthlink dt net
>
> "JosephV" <JosephV@.discussions.microsoft.com> wrote in message
> news:AEF01BE7-44DF-4DEC-90B1-285AEDA95069@.microsoft.com...
> > SQL Server 2000 Standard
> >
> > I need to move multiple databases (about 20) from the C partition to the E
> > partition. I'm familiar with sp_detach_db and sp_attach_db scripts and is
> > OK
> > for a handful of databases but tedious with 10 or more databases. My
> > manager
> > suggested "looping" or something like that. In other words he wants a
> > method
> > to move these databases in an efficient script. I looked into using
> > SSEUTIL
> > but that gives me a "mssql$sqlexpress is not installed" error message,
> > looking for SQL Server Express 2005. I'm sure what I'm asking isn't
> > something
> > new.
>
>|||Hi
http://dimantdatabasesolutions.blogspot.com/2007/03/detaching-and-attaching-database.html
"JosephV" <JosephV@.discussions.microsoft.com> wrote in message
news:A173C0D1-AB94-4BEA-AC8A-F81E88744A6F@.microsoft.com...
> Thanks. I'll research your suggestion.
> "TheSQLGuru" wrote:
>> check out master.dbo.sysaltfiles for file paths. then you can
>> dynamically
>> create the detach/attach scripts using sysdatabases and sysaltfiles.
>> think like this:
>> select 'sp_detach ... ' + name + '
>> go'
>> from sysdatabases
>> I use such constructs all the time to create scripts to execute.
>> --
>> Kevin G. Boles
>> Indicium Resources, Inc.
>> SQL Server MVP
>> kgboles a earthlink dt net
>>
>> "JosephV" <JosephV@.discussions.microsoft.com> wrote in message
>> news:AEF01BE7-44DF-4DEC-90B1-285AEDA95069@.microsoft.com...
>> > SQL Server 2000 Standard
>> >
>> > I need to move multiple databases (about 20) from the C partition to
>> > the E
>> > partition. I'm familiar with sp_detach_db and sp_attach_db scripts and
>> > is
>> > OK
>> > for a handful of databases but tedious with 10 or more databases. My
>> > manager
>> > suggested "looping" or something like that. In other words he wants a
>> > method
>> > to move these databases in an efficient script. I looked into using
>> > SSEUTIL
>> > but that gives me a "mssql$sqlexpress is not installed" error message,
>> > looking for SQL Server Express 2005. I'm sure what I'm asking isn't
>> > something
>> > new.
>>

Attach & Detach Multiple Databases

SQL Server 2000 Standard
I need to move multiple databases (about 20) from the C partition to the E
partition. I'm familiar with sp_detach_db and sp_attach_db scripts and is OK
for a handful of databases but tedious with 10 or more databases. My manager
suggested "looping" or something like that. In other words he wants a method
to move these databases in an efficient script. I looked into using SSEUTIL
but that gives me a "mssql$sqlexpress is not installed" error message,
looking for SQL Server Express 2005. I'm sure what I'm asking isn't something
new.
check out master.dbo.sysaltfiles for file paths. then you can dynamically
create the detach/attach scripts using sysdatabases and sysaltfiles.
think like this:
select 'sp_detach ... ' + name + '
go'
from sysdatabases
I use such constructs all the time to create scripts to execute.
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net
"JosephV" <JosephV@.discussions.microsoft.com> wrote in message
news:AEF01BE7-44DF-4DEC-90B1-285AEDA95069@.microsoft.com...
> SQL Server 2000 Standard
> I need to move multiple databases (about 20) from the C partition to the E
> partition. I'm familiar with sp_detach_db and sp_attach_db scripts and is
> OK
> for a handful of databases but tedious with 10 or more databases. My
> manager
> suggested "looping" or something like that. In other words he wants a
> method
> to move these databases in an efficient script. I looked into using
> SSEUTIL
> but that gives me a "mssql$sqlexpress is not installed" error message,
> looking for SQL Server Express 2005. I'm sure what I'm asking isn't
> something
> new.
|||Thanks. I'll research your suggestion.
"TheSQLGuru" wrote:

> check out master.dbo.sysaltfiles for file paths. then you can dynamically
> create the detach/attach scripts using sysdatabases and sysaltfiles.
> think like this:
> select 'sp_detach ... ' + name + '
> go'
> from sysdatabases
> I use such constructs all the time to create scripts to execute.
> --
> Kevin G. Boles
> Indicium Resources, Inc.
> SQL Server MVP
> kgboles a earthlink dt net
>
> "JosephV" <JosephV@.discussions.microsoft.com> wrote in message
> news:AEF01BE7-44DF-4DEC-90B1-285AEDA95069@.microsoft.com...
>
>
|||Hi
http://dimantdatabasesolutions.blogspot.com/2007/03/detaching-and-attaching-database.html
"JosephV" <JosephV@.discussions.microsoft.com> wrote in message
news:A173C0D1-AB94-4BEA-AC8A-F81E88744A6F@.microsoft.com...[vbcol=seagreen]
> Thanks. I'll research your suggestion.
> "TheSQLGuru" wrote:
sql

Tuesday, March 20, 2012

asssigning values to multiple vars in a SP in one go (without temp table)

I have to select several field values from a table and need to assign them to different variables in my SP.

Here's what I do now:

declare

@.ReceiverEmailnvarchar(50)

SET

@.ReceiverEmail=(SELECT EmailFROM UsersWHERE UserCode=@.UserCodeOwner)

declare

@.UsernameSendernvarchar(50)

SET

@.UsernameSender=(SELECT UsernameFROM UsersWHERE UserCode=@.UserCodeOwner)
As you can see I have to search the Users table twice: once for the Email and a second time for the Username...and all that based on the SAME usercode...:S
So, is there an option where I only have to search the table once and return the Email and UserName fields and assign them to my variables (without using a temp table...)?

Peter,

i dont know off the top of my head a way to get around the 2X search without the temptable, unless you use a table variable instead which in principle is still the same thing as your temp table. if the result set of email and usernames is not that big, then the table variable may save you a bit since it is being run in memory. I know this is not the answer your probably looking for, but its all i have...good luck!

|||the reason I dont want to use a temp table is because i've read that it might cause concurrency conflicts amongst others...
Is that still true in SQL Server 2005?
Otherwise I might as well go with the temp table..|||

Hi there,

try with this code it works

DECLARE @.RECEIVEREMAILNVARCHAR(50)DECLARE @.USERNAMESENDERNVARCHAR(50)
SELECT
@.RECEIVEREMAIL = EMAIL,
@.USERNAMESENDER = USERNAME
FROM USERS
WHERE USERCODE = @.USERCODEOWNER


Regards,

Fernando

|||

It sude did!
Thanks!

Monday, March 19, 2012

associate each product with multiple bikes (was "How should i.....")

Hello, im brand new to these forums, scrolled through a bit of the forum(mainly trying to figure out how to go about what im about to ask) and it seems like a good forum...anyways onto my question.

i am in need of ideas/know-how on how to structure a database like such:

its an online motorcycle accessories website, and this is the information i need to store in the db(basically these will be my tables in the db)

bike manufacturer
bike name
products

now my main question is how would i structure those tables so i can get this effect.

each product in the product table needs to have a bike associated to it, 99% of the time it will be more than one bike associated to it, so how would i go about doing that?

originally i had set it up with the bikes name being different columns in the products table with a bit type set to 1 if that product was available for that bike and 0 if it wasnt available. however as you are probably already thinking that isnt the best way to do that.

so what is the best way?

any info at all would be greatly appreciated.

thanks in advanceif the products table has product_id as its PK, and if the bikes table has bike_id as its PK, then you need

create table bikeproducts
( product_id integer not null references products(product_id)
, bike_id integer not null references bikes(bike_id)
, primary key(product_id,bike_id)
)

this "relationship" or "linking" or "many-to-many" table allows you to add a row for each occurrence of a relationship -- one bike, multiple products, and one product, multiple bikes|||Thank you very much, that makes alotta sense, and i understand what i have to do, thanks again

Assistance with Stored Procedure

I am running SQL Server 7.0 and using a web interface. I would like
for a user to be able to input multiple values into a single field
with some sort of delimiter (such as a comma). I want to pass this
field into a Stored Procedure and have the stored procedure use the
data to generate the resutls.

Example:

Web page would ask for ID number into a field called IDNum. User
could input one or many ID numbers separated by a comma or some other
delemiter - could even be just a space (113, 114, 145).

SQL statement in Stored Procedure is something like this:

Select * from tblEmployess where IDNumber = @.IDNum

I need the SQL statement to somehow use an "or" or a "loop" to get all
of the numbers passed and use the delimiter to distinguish when the
"loop" stops.

I obtained a module from a friend that allows me to do this in access,
but have recently converted everything to SQL server and web
interface. Now, everyone in the office expects to be able to
accomplish the same results via the web.

Any help is appreciated. If you need any additional information to
provide me some assistance, please email me at
tod.thames@.nc.ngb.army.mil.

Thanks in advance.

TodTake a look at http://www.algonet.se/~sommar/arrays-in-sql.html.

--
Hope this helps.

Dan Guzman
SQL Server MVP

--------
SQL FAQ links (courtesy Neil Pike):

http://www.ntfaq.com/Articles/Index...epartmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
--------

"Tod Thames" <tod.thames@.nc.ngb.army.mil> wrote in message
news:5ed144f0.0310050454.369f4994@.posting.google.c om...
> I am running SQL Server 7.0 and using a web interface. I would like
> for a user to be able to input multiple values into a single field
> with some sort of delimiter (such as a comma). I want to pass this
> field into a Stored Procedure and have the stored procedure use the
> data to generate the resutls.
> Example:
> Web page would ask for ID number into a field called IDNum. User
> could input one or many ID numbers separated by a comma or some other
> delemiter - could even be just a space (113, 114, 145).
> SQL statement in Stored Procedure is something like this:
> Select * from tblEmployess where IDNumber = @.IDNum
>
> I need the SQL statement to somehow use an "or" or a "loop" to get all
> of the numbers passed and use the delimiter to distinguish when the
> "loop" stops.
> I obtained a module from a friend that allows me to do this in access,
> but have recently converted everything to SQL server and web
> interface. Now, everyone in the office expects to be able to
> accomplish the same results via the web.
> Any help is appreciated. If you need any additional information to
> provide me some assistance, please email me at
> tod.thames@.nc.ngb.army.mil.
> Thanks in advance.
> Tod|||Everytime I try to get to the website you refrenced, I get TCP_ERROR.
Some sort of communication problem. Is there any other sites that have
the same sort of information?

Thanks for the response,

Tod

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!|||I don't know if the content is mirrored elsewhere. The author, Erland
Sommarskog, frequents this newsgroup so maybe he'll jump in.

BTW, I don't have any problems accessing the site.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Tod Thames" <tod.thames@.nc.ngb.army.mil> wrote in message
news:3f803253$0$195$75868355@.news.frii.net...
> Everytime I try to get to the website you refrenced, I get TCP_ERROR.
> Some sort of communication problem. Is there any other sites that
have
> the same sort of information?
> Thanks for the response,
> Tod
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!|||[posted and mailed]

Tod Thames (tod.thames@.nc.ngb.army.mil) writes:
> Everytime I try to get to the website you refrenced, I get TCP_ERROR.
> Some sort of communication problem. Is there any other sites that have
> the same sort of information?

Too bad. If you have the complete error message, I'm interested. I'm
inclined to suspect that this might be some firewall problem at your
side, but I might get carried away of the .mil in your address.

Anyway, here is an excerpt of the part which is most relevant to
you. If you want to read the entire article, just drop me a line.

An Extravagant List-of-integers Procedure

The technique in the previous section can of course be applied to a list
of integers as well, so what comes here is not a true port of the
iter_intlist_to_table function, but a version that goes head over heels
to validate that the list items are valid numbers to avoid a conversion
error. And to be extra ambitious, the procedure permits for signed
numbers such as +98 or -83. If a list item is not a legal number, the
procedure produces a warning. The procedure fills in a temp table that
has a listpos column; this column will show a gap if there is an illegal
item in the input.

CREATE PROCEDURE intlist_to_table_sp @.list ntext AS

DECLARE @.pos int,
@.textpos int,
@.listpos int,
@.chunklen smallint,
@.str nvarchar(4000),
@.tmpstr nvarchar(4000),
@.leftover nvarchar(4000)

SET NOCOUNT ON

SELECT @.textpos = 1, @.listpos = 1, @.leftover = ''
WHILE @.textpos <= datalength(@.list) / 2
BEGIN
SELECT @.chunklen = 4000 - datalength(@.leftover) / 2
SELECT @.tmpstr = ltrim(@.leftover + substring(@.list, @.textpos, @.chunklen))
SELECT @.textpos = @.textpos + @.chunklen

SELECT @.pos = charindex(' ', @.tmpstr)
WHILE @.pos > 0
BEGIN
SELECT @.str = rtrim(ltrim(substring(@.tmpstr, 1, @.pos - 1)))
EXEC insert_str_to_number @.str, @.listpos
SELECT @.listpos = @.listpos + 1
SELECT @.tmpstr = ltrim(substring(@.tmpstr, @.pos + 1, len(@.tmpstr)))
SELECT @.pos = charindex(' ', @.tmpstr)
END

SELECT @.leftover = @.tmpstr
END

IF ltrim(rtrim(@.leftover)) <> ''
EXEC insert_str_to_number @.leftover, @.listpos
go

-- This is a sub-procedure to intlist_to_table_sp
CREATE PROCEDURE insert_str_to_number @.str nvarchar(200),
@.listpos int AS

DECLARE @.number int,
@.orgstr nvarchar(200),
@.sign smallint,
@.decimal decimal(10, 0)

SELECT @.orgstr = @.str

IF substring(@.str, 1, 1) IN ('-', '+')
BEGIN
SELECT @.sign = CASE substring(@.str, 1, 1)
WHEN '-' THEN -1
WHEN '+' THEN 1
END
SELECT @.str = substring(@.str, 2, len(@.str))
END
ELSE
SELECT @.sign = 1

IF @.str LIKE '%[0-9]%' AND @.str NOT LIKE '%[^0-9]%'
BEGIN
IF len(@.str) <= 9
SELECT @.number = convert(int, @.str)
ELSE IF len(@.str) = 10
BEGIN
SELECT @.decimal = convert(decimal(10, 0), @.str)
IF @.decimal <= convert(int, 0x7FFFFFFF)
SELECT @.number = @.decimal
END
END

IF @.number IS NOT NULL
INSERT #numbers (listpos, number) VALUES (@.listpos, @.sign * @.number)
ELSE
RAISERROR('Warning: at position %d, the string "%s" is not an legal integer',
10, -1, @.listpos, @.orgstr)
go

Here is how you would use it:

CREATE PROCEDURE get_product_names_iterproc @.ids varchar(50) AS
CREATE TABLE #numbers (listpos int NOT NULL,
number int NOT NULL)
EXEC intlist_to_table_sp @.ids
SELECT P.ProductID, P.ProductName
FROM Northwind..Products P
JOIN #numbers n ON P.ProductID = n.number
go
EXEC get_product_names_iterproc '9 12 27 37'

The validation of the list item is in the sub-procedure
insert_str_to_number. For many purposes it would be sufficient to have
the test

@.str NOT LIKE '%[^0-9]%' AND len(@.str) BETWEEN 1 AND 9

which checks that @.str only contain digits and is at most nine digits
long (that is, you disapprove ten-digit numbers as well as signed
numbers).

You might guess that there is a performance cost for this extravaganza,
and indeed the procedure needs about 50% more time than the corresponding
function. Still, for many situations, the execution time is acceptable.

One note about the warning produced with RAISERROR: with ADO, this
warning may be difficult or impossible to detect on client level. If you
change the severity from 10 to 11, it will be an error, and raise an
error in your client code.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||
Thanks for the response - it's a little above my abilities, but I plan
on studying it and trying to make it work for me project.

Tod

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!|||See if the following link helps..
http://tinyurl.com/6iil

--
-- Anith|||Tod,

Try this:

create procedure ListEmployees
@.IDNum char(1024)
as begin
set @.IDNum = ' ' + replace(@.IDNum, ',', ' ') + ' '
select *
from tblEmployess
where @.IDNum like ('% ' + ltrim(str(IDNumber)) + ' %')
end

Shervin

"Tod Thames" <tod.thames@.nc.ngb.army.mil> wrote in message
news:5ed144f0.0310050454.369f4994@.posting.google.c om...
> I am running SQL Server 7.0 and using a web interface. I would like
> for a user to be able to input multiple values into a single field
> with some sort of delimiter (such as a comma). I want to pass this
> field into a Stored Procedure and have the stored procedure use the
> data to generate the resutls.
> Example:
> Web page would ask for ID number into a field called IDNum. User
> could input one or many ID numbers separated by a comma or some other
> delemiter - could even be just a space (113, 114, 145).
> SQL statement in Stored Procedure is something like this:
> Select * from tblEmployess where IDNumber = @.IDNum
>
> I need the SQL statement to somehow use an "or" or a "loop" to get all
> of the numbers passed and use the delimiter to distinguish when the
> "loop" stops.
> I obtained a module from a friend that allows me to do this in access,
> but have recently converted everything to SQL server and web
> interface. Now, everyone in the office expects to be able to
> accomplish the same results via the web.
> Any help is appreciated. If you need any additional information to
> provide me some assistance, please email me at
> tod.thames@.nc.ngb.army.mil.
> Thanks in advance.
> Tod

assistance configuring multi-cpus

Anyone have any best practices for configuring SQL to make use of multiple
CPUs in a dedicated SQL server?
ThanksBy default you don't have to do anything. SQL Server will detect the CPU's
and use them as it see's fit according to the limitations of the edition of
SQL Server you are using.
--
Andrew J. Kelly SQL MVP
"Mike" <mike528@.wideopenwest.com> wrote in message
news:%23NDVGnA0FHA.3712@.TK2MSFTNGP10.phx.gbl...
> Anyone have any best practices for configuring SQL to make use of multiple
> CPUs in a dedicated SQL server?
> Thanks
>

Assigning values to multiple variables (via subqueries) for use in an update

Hi, figured out where I was going wrong in my post just prior, but is
there ANY way I can assign several variables to then use them in an
Update statement, for example (this does not work):

ALTER PROCEDURE dbo.UpdateXmlWF
(
@.varWO varchar(50)
)
AS
DECLARE @.varCust VARCHAR(50)
SELECT @.varCust = (SELECT Customer FROM tblWorkOrders
WHERE WorkOrder=@.varWO)

DECLARE @.varAssy VARCHAR(50)
SELECT @.varAssy=(SELECT Assy FROM tblWorkOrders
WHERE WorkOrder=@.varWO)

UPDATE statement here using declared variables...

I can set one @.variable but not multiple. Any clues? kinda new to
this.

Thanks,
KathyKathy,

See my response to your previous post.

I think you want to try this instead:

DECLARE @.varCust varchar(50), varAssy varchar(50)
SELECT @.varCust = Customer,
@.varAssy = Assy
FROM tblWorkOrders
WHERE WorkOrder = @.varWO

UPDATE table
SET field = @.varCust,
field2 = @.varAssy
where somefield = somevalue

In fact, you could condense this to the following:

UPDATE table
SET field = tblWorkOrders.Customer,
field2 = tblWorkOrders.Assy
FROM tblWorkOrders
JOIN table ON tblWorkOrders.PK = table.FK
WHERE tblWorkOrders.WorkOrder = @.varWO
AND otherconditions...

Hope this helps.

--
-Chuck Urwiler, MCSD, MCDBA
http://www.eps-software.com|||Kathy,

You don't need two separate SELECT statements to assign values to your
variables. You can do it like this:

DECLARE @.varCust VARCHAR(50),
@.varAssy VARCHAR(50)

SELECT @.varCust = Customer,
@.varAssy = Assy
FROM tblWorkOrders
WHERE WorkOrder = @.varWO

But I don't understand your problem with inserting. You can modify as many
columns as you want in UPDATE statement. What's your problem here?
By the way, if these variables have been declared just to use in your UPDATE
statement, then you don't really need them. You can join tblWorkOrders table
with whatever table you want update and fetch values from tblWorkOrders
directly into your destination table.

Shervin

"KathyB" <KathyBurke40@.attbi.com> wrote in message
news:75e8d381.0310030718.82cad7f@.posting.google.co m...
> Hi, figured out where I was going wrong in my post just prior, but is
> there ANY way I can assign several variables to then use them in an
> Update statement, for example (this does not work):
> ALTER PROCEDURE dbo.UpdateXmlWF
> (
> @.varWO varchar(50)
> )
> AS
> DECLARE @.varCust VARCHAR(50)
> SELECT @.varCust = (SELECT Customer FROM tblWorkOrders
> WHERE WorkOrder=@.varWO)
> DECLARE @.varAssy VARCHAR(50)
> SELECT @.varAssy=(SELECT Assy FROM tblWorkOrders
> WHERE WorkOrder=@.varWO)
> UPDATE statement here using declared variables...
> I can set one @.variable but not multiple. Any clues? kinda new to
> this.
> Thanks,
> Kathy

Sunday, March 11, 2012

assigning process priority to transactions?

I am using ADO 2.8 and SQL server 2000.
Is there any way to assign process priorities to multiple DB connections?
For example, consider that there is a long-time taking transaction and many
short-time transactions running on a server machine. I want to assign low
priority to the long-time transaction to prevent from starvation of
short-time transactions. Of couse, let's assume that there is no locking
influence between them.
Please reply. Thanks in advance.
Regards,
Hyun-jik BaeHi
I am affraid you cannot do that. Perhaps you want to look at SET
LOCK_TIMEOUT command.
"Bae,Hyun-jik" <imays@.NOSPAM.paran.com> wrote in message
news:upjA1nJbFHA.228@.TK2MSFTNGP12.phx.gbl...
> I am using ADO 2.8 and SQL server 2000.
> Is there any way to assign process priorities to multiple DB connections?
> For example, consider that there is a long-time taking transaction and
many
> short-time transactions running on a server machine. I want to assign low
> priority to the long-time transaction to prevent from starvation of
> short-time transactions. Of couse, let's assume that there is no locking
> influence between them.
> Please reply. Thanks in advance.
> Regards,
> Hyun-jik Bae
>

Assigning multiple values to a parameter in stored procedure

Hi:
How do you write a SQL statement in a stored procedure so
that it will allow you to assign multiple values to a
parameter?
For instance in this example below, depending on what the
users select on the front-end application, the values
assign can be one customer id value or multiple customer
id values:
Create procedure dbo.SP_Test
As @.CustID varchar(3)
Select * from tblCust where customerid = @.CustID
Please help!This is probably not the best solution but it should work
create procedure sp_test
@.cust_id varchar(50)
as
set nocount on
exec ('select * from tblcust where customerid in (' + @.cust_id +')')
go
This procedure would be called as sp_test '50' for one cust_id or sp_test
'50, 55, 100' for several cust_id's

Thursday, March 8, 2012

AssignExpression In For Loop Container

What I'm trying to do is take multiple "snapshots" of a membership for many months. I was trying to do this in a For Loop Container in which I added one to the month variable and subtracted one from an iteration variable each loop, unless the month variable = 13...then I would add one to the year variable, set the month variable to 1 and subtract one from the iteration variable. This, I was hoping, would allow me to initialize 24 to the iteration variable, 1 to the month variable and 2004 to the year variable, kick off the package, and get 2 years worth of "snapshots" in seperate files (one for each month). Here is the AssignExpression I thought would work:

@.Member_Month == 13 ? @.Member_Month = 1 && @.Member_Year= @.Member_Year + 1 && @.Member_Iteration = @.Member_Iteration - 1 : @.Member_Month = @.Member_Month + 1 && @.Member_Iteration = @.Member_Iteration - 1

The package states that the single "=" should be double, but I don't think that that is what I want to do (I tried doing this just to check, and it didn't like this either). I think that it is having problems with doing multiple things on both sides of the ":". What am I doing wrong?

Thanks,

Brian Layden

The AssignExpression supports only a single assignment. Can you put the logic of updating Month and Year inside the loop in a script, perhaps?

Assign permissions to multiple objects

I know I should know the answer to this question, but unfortunately I
do not.
We have a SQL Server 7.0 production database (will be upgraded soon).
I am attempting to restore this database in my development environment
which is running SQL Server 2005 developer edition. The restore
appeared to succeed without problem, but one of the logins ended up not
getting any of the correct permissions assigned to any objects for some
reason. Is there any way to easily assign permissions to multiple
objects for a single login? If I have to do it manually and
individually it will take hours.
Thanks in advance for any advice.Yes
1. Simply add user to a group with enough perms to do it.
or
2. use sp_MSForeachtable or a cursor and loop through the objects assigning
perms as appriopriate by generating dynamic sql.
or
3. Script out perms from prod and apply to dev for login in question.
"rsbaier@.gmail.com" wrote:
> I know I should know the answer to this question, but unfortunately I
> do not.
> We have a SQL Server 7.0 production database (will be upgraded soon).
> I am attempting to restore this database in my development environment
> which is running SQL Server 2005 developer edition. The restore
> appeared to succeed without problem, but one of the logins ended up not
> getting any of the correct permissions assigned to any objects for some
> reason. Is there any way to easily assign permissions to multiple
> objects for a single login? If I have to do it manually and
> individually it will take hours.
> Thanks in advance for any advice.
>

Wednesday, March 7, 2012

Assign permissions to multiple objects

Yes
1. Simply add user to a group with enough perms to do it.
or
2. use sp_MSForeachtable or a cursor and loop through the objects assigning
perms as appriopriate by generating dynamic sql.
or
3. Script out perms from prod and apply to dev for login in question.
"rsbaier@.gmail.com" wrote:

> I know I should know the answer to this question, but unfortunately I
> do not.
> We have a SQL Server 7.0 production database (will be upgraded soon).
> I am attempting to restore this database in my development environment
> which is running SQL Server 2005 developer edition. The restore
> appeared to succeed without problem, but one of the logins ended up not
> getting any of the correct permissions assigned to any objects for some
> reason. Is there any way to easily assign permissions to multiple
> objects for a single login? If I have to do it manually and
> individually it will take hours.
> Thanks in advance for any advice.
>I know I should know the answer to this question, but unfortunately I
do not.
We have a SQL Server 7.0 production database (will be upgraded soon).
I am attempting to restore this database in my development environment
which is running SQL Server 2005 developer edition. The restore
appeared to succeed without problem, but one of the logins ended up not
getting any of the correct permissions assigned to any objects for some
reason. Is there any way to easily assign permissions to multiple
objects for a single login? If I have to do it manually and
individually it will take hours.
Thanks in advance for any advice.|||Yes
1. Simply add user to a group with enough perms to do it.
or
2. use sp_MSForeachtable or a cursor and loop through the objects assigning
perms as appriopriate by generating dynamic sql.
or
3. Script out perms from prod and apply to dev for login in question.
"rsbaier@.gmail.com" wrote:

> I know I should know the answer to this question, but unfortunately I
> do not.
> We have a SQL Server 7.0 production database (will be upgraded soon).
> I am attempting to restore this database in my development environment
> which is running SQL Server 2005 developer edition. The restore
> appeared to succeed without problem, but one of the logins ended up not
> getting any of the correct permissions assigned to any objects for some
> reason. Is there any way to easily assign permissions to multiple
> objects for a single login? If I have to do it manually and
> individually it will take hours.
> Thanks in advance for any advice.
>

Assign multiple values using CASE in a Select Statement

Hello All,
I have a need to assign the values of the three variables in one select
statement. Currently, this is done using three
different Select statements :
Select @.Male = SMnemonic from sex where SName = 'Male'
Select @.Female = SMnemonic from sex where SName = 'Female'
Select @.Unknown = SMnemonic from sex where SName = 'Unknown'
I would like to replace with just one Select statement. I thought that this
is simple, however, I'm getting vague results :
NULL
(1 row(s) affected)
NULL
(1 row(s) affected)
Unknown Mnemonic is : U
(1 row(s) affected)
Thanks,
Gopi
CREATE TABLE [dbo].[Sex] (
[SCode] [char] (10) ,
[SName] [varchar] (50),
[SMnemonic] [char] (10)
)
GO
Select * from Sex order by SCode
SCode SName SMnemonic
-- ---- --
1 Male
M
2 Female
F
3 Unknown
U
4 Not Known
NK
Select SMnemonic from sex where SName = 'Male'
Select SMnemonic from sex where SName = 'Female'
Select SMnemonic from sex where SName = 'Unknown'
Declare @.Male char(10)
Declare @.Female char(10)
Declare @.Unknown char(10)
Set @.Male = 'Junk'
Set @.Female = 'Junk'
Set @.Unknown = 'Junk'
Select @.Male = CASE SName
WHEN 'Male' THEN SMnemonic
END ,
@.Unknown = CASE SName
WHEN 'Unknown' THEN SMnemonic
END ,
@.Female = CASE SName
WHEN 'Female' THEN SMnemonic
END
from Sex
WHERE SName IN ('Male','Female','Unknown')
Select 'Female Mnemonic is : ' + @.Female
Select 'Male Mnemonic is : ' + @.Male
Select 'Unknown Mnemonic is : ' + @.UnknownTry,
Select
@.Male = case when SName = 'Male' then SMnemonic else @.Male end,
@.Female = case when SName = 'Female' then SMnemonic else @.Female end,
@.Unknown = case when SName = 'Unknown' then SMnemonic else @.Unknown end
from
sex;
AMB
"rgn" wrote:

> Hello All,
> I have a need to assign the values of the three variables in one select
> statement. Currently, this is done using three
> different Select statements :
> Select @.Male = SMnemonic from sex where SName = 'Male'
> Select @.Female = SMnemonic from sex where SName = 'Female'
> Select @.Unknown = SMnemonic from sex where SName = 'Unknown'
> I would like to replace with just one Select statement. I thought that thi
s
> is simple, however, I'm getting vague results :
> --
> NULL
> (1 row(s) affected)
> --
> NULL
> (1 row(s) affected)
> --
> Unknown Mnemonic is : U
> (1 row(s) affected)
>
> Thanks,
> Gopi
> CREATE TABLE [dbo].[Sex] (
> [SCode] [char] (10) ,
> [SName] [varchar] (50),
> [SMnemonic] [char] (10)
> )
> GO
> Select * from Sex order by SCode
> SCode SName SMnemonic
> -- ---- --
> 1 Male
> M
> 2 Female
> F
> 3 Unknown
> U
> 4 Not Known
> NK
>
> Select SMnemonic from sex where SName = 'Male'
> Select SMnemonic from sex where SName = 'Female'
> Select SMnemonic from sex where SName = 'Unknown'
>
> Declare @.Male char(10)
> Declare @.Female char(10)
> Declare @.Unknown char(10)
> Set @.Male = 'Junk'
> Set @.Female = 'Junk'
> Set @.Unknown = 'Junk'
>
> Select @.Male = CASE SName
> WHEN 'Male' THEN SMnemonic
> END ,
> @.Unknown = CASE SName
> WHEN 'Unknown' THEN SMnemonic
> END ,
> @.Female = CASE SName
> WHEN 'Female' THEN SMnemonic
> END
> from Sex
> WHERE SName IN ('Male','Female','Unknown')
> Select 'Female Mnemonic is : ' + @.Female
> Select 'Male Mnemonic is : ' + @.Male
> Select 'Unknown Mnemonic is : ' + @.Unknown
>
>|||Alejadro,
Thanks a Million. I see the problem. Since ELSE part is missing it is
assigning NULLs and the reason why the last
variable, in this case Unknown, retains the value.
Gopi
"Alejandro Mesa" <AlejandroMesa@.discussions.microsoft.com> wrote in message
news:BB446702-10C6-47D3-91F7-3C6E9FD1D4FC@.microsoft.com...
> Try,
> Select
> @.Male = case when SName = 'Male' then SMnemonic else @.Male end,
> @.Female = case when SName = 'Female' then SMnemonic else @.Female end,
> @.Unknown = case when SName = 'Unknown' then SMnemonic else @.Unknown end
> from
> sex;
>
> AMB
> "rgn" wrote:
>

Assign multiple groups to role(s)

I have not seen this question pose anywhere.
Currently we can only assign 1 group at a time to role(s).
Has anyone found a way to assign more than 1 group at a time to role(s)?
I have about 70+ groups to assign role(s) to and doing this one by one is
just not going to work.
I'm using Custom Authentication. Although it has nothing to do with this.
I'm just curious as to what Microsoft plans on doing about this. In the mean
time how is everyone dealing with this issue? How anyone found a way to do it?
Thanks.I do the following. I have a local group. I then assign all my domain groups
to that local group. I only assign a single group to the role(the one local
group). Any changes to membership (for instance adding a particular user or
adding another group) is all done in Windows, nothing changes with RS.
--
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Jon-Slem" <JonSlem@.discussions.microsoft.com> wrote in message
news:09714ACE-C939-4903-8981-ABAF7EB0A681@.microsoft.com...
> I have not seen this question pose anywhere.
> Currently we can only assign 1 group at a time to role(s).
> Has anyone found a way to assign more than 1 group at a time to role(s)?
> I have about 70+ groups to assign role(s) to and doing this one by one is
> just not going to work.
> I'm using Custom Authentication. Although it has nothing to do with this.
> I'm just curious as to what Microsoft plans on doing about this. In the
mean
> time how is everyone dealing with this issue? How anyone found a way to do
it?
> Thanks.