Showing posts with label user. Show all posts
Showing posts with label user. Show all posts

Thursday, March 29, 2012

Correct syntax for an update stored procedure

This is probably a very simple question but i would appreciate some helpwith the correct syntax for andupdate stored procedure

I have created user form that allows the user toupdate thenameandaddress fields in adatatable called customers based on the input valuecustomer ID = ( datatable/Customers)customerID
I have got this far and then got lost:
Create SP_UpdateCustomer
(@.customerID, @.name, @.address)
As
Update customers ( name, address)
Where customerID = @.customerID

GO
Could anyone tell me what the correct sntax should be.
many thanks
MartinHi Martin,
You'll need to specify the data types in the create clause, and add a set clause to change the fields you want to update:
create proc sp_updatecustomer (@.customerid varchar(50), @.name varchar(50), @.address varchar(50))
as
update customers
setname=@.name,address=@.address
where customerID= @.customerID
Note - this might be a bit dangerous from a security standpoint, and you might also want to introduce some validation on the Customer ID field, to avoid anyone maliciously changing all the records by entering a customer ID of "a or 1=1"
|||

rJonas
Many thanks for your reply
I note the securtiy points you made
Thank you
martin

|||

rjonas wrote:


Note - this might be a bit dangerous from asecurity standpoint, and you might also want to introduce somevalidation on the Customer ID field, to avoid anyone maliciouslychanging all the records by entering a customer ID of "a or 1=1"


?? That is not physcially possible with the stored procedure the posteris using. The stored procedure is corerctly parameterized and thedanger you pointed out does not exist here.
Here are some articles on SQL injection and parameterized queries:
Please, please, please, learn about injection attacks!
How To: Protect From SQL Injection in ASP.NET
Using Parameterized Query in ASP.NET, Part 1
Using Parameterized Query in ASP.NET, Part 2
Using Parameterized Queries in ASP.Net

Tuesday, March 27, 2012

Copying Views from one db to other

Hi,
How to copy view from one db to other one...It should be
done via script...Is it possible to user SQL-DMO.
Regards
SridharYes, you can use SQL DMO t script objects. You can se DTS as well. Here is a
short examle of DMO:
Dim oSS As SQLDMO.SQLServer
Dim oDb As SQLDMO.Database
Dim oT As SQLDMO.Transfer
Dim sS As String
Sub Script()
Set oSS = New SQLDMO.SQLServer
Set oT = New SQLDMO.Transfer
oSS.LoginSecure = True
oSS.Connect
Set oDb = oSS.Databases("pubs")
oT.CopyAllTables = True
oDb.ScriptTransfer oT, SQLDMOXfrFile_SingleFile, "C:\pubs.sql"
End Sub
Dejan Sarka, SQL Server MVP
Associate Mentor
Solid Quality Learning
More than just Training
www.SolidQualityLearning.com
<anonymous@.discussions.microsoft.com> wrote in message
news:8a2a01c485af$9b128630$a501280a@.phx.gbl...
> Hi,
> How to copy view from one db to other one...It should be
> done via script...Is it possible to user SQL-DMO.
>
> Regards
> Sridhar

Copying Views from one db to other

Hi,
How to copy view from one db to other one...It should be
done via script...Is it possible to user SQL-DMO.
Regards
Sridhar
Yes, you can use SQL DMO t script objects. You can se DTS as well. Here is a
short examle of DMO:
Dim oSS As SQLDMO.SQLServer
Dim oDb As SQLDMO.Database
Dim oT As SQLDMO.Transfer
Dim sS As String
Sub Script()
Set oSS = New SQLDMO.SQLServer
Set oT = New SQLDMO.Transfer
oSS.LoginSecure = True
oSS.Connect
Set oDb = oSS.Databases("pubs")
oT.CopyAllTables = True
oDb.ScriptTransfer oT, SQLDMOXfrFile_SingleFile, "C:\pubs.sql"
End Sub
Dejan Sarka, SQL Server MVP
Associate Mentor
Solid Quality Learning
More than just Training
www.SolidQualityLearning.com
<anonymous@.discussions.microsoft.com> wrote in message
news:8a2a01c485af$9b128630$a501280a@.phx.gbl...
> Hi,
> How to copy view from one db to other one...It should be
> done via script...Is it possible to user SQL-DMO.
>
> Regards
> Sridhar

Copying Views from one db to other

Hi,
How to copy view from one db to other one...It should be
done via script...Is it possible to user SQL-DMO.
Regards
SridharYes, you can use SQL DMO t script objects. You can se DTS as well. Here is a
short examle of DMO:
Dim oSS As SQLDMO.SQLServer
Dim oDb As SQLDMO.Database
Dim oT As SQLDMO.Transfer
Dim sS As String
Sub Script()
Set oSS = New SQLDMO.SQLServer
Set oT = New SQLDMO.Transfer
oSS.LoginSecure = True
oSS.Connect
Set oDb = oSS.Databases("pubs")
oT.CopyAllTables = True
oDb.ScriptTransfer oT, SQLDMOXfrFile_SingleFile, "C:\pubs.sql"
End Sub
--
Dejan Sarka, SQL Server MVP
Associate Mentor
Solid Quality Learning
More than just Training
www.SolidQualityLearning.com
<anonymous@.discussions.microsoft.com> wrote in message
news:8a2a01c485af$9b128630$a501280a@.phx.gbl...
> Hi,
> How to copy view from one db to other one...It should be
> done via script...Is it possible to user SQL-DMO.
>
> Regards
> Sridharsql

Sunday, March 25, 2012

Copying tables between database

Hi
I have 2 user created databases in MS SQL Server 2000. Now I want to copy tables from one of this database to the other. The structure, relationships etc of these tables between these 2 databases are very similar. I searched high and low in BOL but could not find any info
Can some one help me in this please ...
Thanks
Harish MohanbabuHarish, you have many different solutions:
- SELECT col_list INTO db2.dbo.newtable FROM db1.dbo.oldtable - check
SELECT statement in Books OnLine
- Use Data Transformation Services (you can do it with the DTS Import/Export
Wizard) - check "DTS Import/Export Wizard" topic
- Create scripts, if you need metadata only, and implement scripts in the
new database - check "How to generate a script (Enterprise Manager)"
- ...
Dejan Sarka, SQL Server MVP
Associate Mentor
Solid Quality Learning
More than just Training
www.SolidQualityLearning.com
"Harish Mohanbabu" <anonymous@.discussions.microsoft.com> wrote in message
news:CFDD7D65-54E0-436D-8B40-51DBE7CA6E90@.microsoft.com...
> Hi,
> I have 2 user created databases in MS SQL Server 2000. Now I want to copy
tables from one of this database to the other. The structure, relationships
etc of these tables between these 2 databases are very similar. I searched
high and low in BOL but could not find any info.
> Can some one help me in this please ...
> Thanks,
> Harish Mohanbabu|||Hi,
Since you have the schema in both the databases, Probably you need to copy
the data from database to another in same server, then you can use
1. Copy only data
insert into tablename select * from dbname..tablename
2. If we need to replicate all the tables / users / procedures in one
database to another then you can Backup and Restore
Backup database dbname1 to disk='c:\dbname.bak' with init,stats=10
go
Restore database dbname2 from disk='c:\dbname.bak' with move
'logicaldatafilename' to 'newphysicalfile.mdf',
move 'logicallogfilename' to 'newphysicalfile.ldf'
Thanks
Hari
MCDBA
"Harish Mohanbabu" <anonymous@.discussions.microsoft.com> wrote in message
news:CFDD7D65-54E0-436D-8B40-51DBE7CA6E90@.microsoft.com...
> Hi,
> I have 2 user created databases in MS SQL Server 2000. Now I want to copy
tables from one of this database to the other. The structure, relationships
etc of these tables between these 2 databases are very similar. I searched
high and low in BOL but could not find any info.
> Can some one help me in this please ...
> Thanks,
> Harish Mohanbabu|||Hi Dejan/Hari,
Thank you very much for your kind replies. Since the structure of tables between databases were same, I used DTS to copy data between tables.
Cheers,
Harish Mohanbabu

Copying tables between database

Hi,
I have 2 user created databases in MS SQL Server 2000. Now I want to copy t
ables from one of this database to the other. The structure, relationships e
tc of these tables between these 2 databases are very similar. I searched h
igh and low in BOL but coul
d not find any info.
Can some one help me in this please ...
Thanks,
Harish MohanbabuHarish, you have many different solutions:
- SELECT col_list INTO db2.dbo.newtable FROM db1.dbo.oldtable - check
SELECT statement in Books OnLine
- Use Data Transformation Services (you can do it with the DTS Import/Export
Wizard) - check "DTS Import/Export Wizard" topic
- Create scripts, if you need metadata only, and implement scripts in the
new database - check "How to generate a script (Enterprise Manager)"
- ...
Dejan Sarka, SQL Server MVP
Associate Mentor
Solid Quality Learning
More than just Training
www.SolidQualityLearning.com
"Harish Mohanbabu" <anonymous@.discussions.microsoft.com> wrote in message
news:CFDD7D65-54E0-436D-8B40-51DBE7CA6E90@.microsoft.com...
> Hi,
> I have 2 user created databases in MS SQL Server 2000. Now I want to copy
tables from one of this database to the other. The structure, relationships
etc of these tables between these 2 databases are very similar. I searched
high and low in BOL but could not find any info.
> Can some one help me in this please ...
> Thanks,
> Harish Mohanbabu|||Hi,
Since you have the schema in both the databases, Probably you need to copy
the data from database to another in same server, then you can use
1. Copy only data
insert into tablename select * from dbname..tablename
2. If we need to replicate all the tables / users / procedures in one
database to another then you can Backup and Restore
Backup database dbname1 to disk='c:\dbname.bak' with init,stats=10
go
Restore database dbname2 from disk='c:\dbname.bak' with move
'logicaldatafilename' to 'newphysicalfile.mdf',
move 'logicallogfilename' to 'newphysicalfile.ldf'
Thanks
Hari
MCDBA
"Harish Mohanbabu" <anonymous@.discussions.microsoft.com> wrote in message
news:CFDD7D65-54E0-436D-8B40-51DBE7CA6E90@.microsoft.com...
> Hi,
> I have 2 user created databases in MS SQL Server 2000. Now I want to copy
tables from one of this database to the other. The structure, relationships
etc of these tables between these 2 databases are very similar. I searched
high and low in BOL but could not find any info.
> Can some one help me in this please ...
> Thanks,
> Harish Mohanbabu

Tuesday, March 20, 2012

copying sql server logins and users

Hi All,
I have a user database with 20 users. I have to transfer this database to some other location (location B) with the user and login, so that others would be able to login (assuming i have provided them username and pwd for logging). I can take the backup of the database, which can be restored at location b, in which the users will also be available.
Now my question i
Is there a mechansim to copy sql server logins also, such that, when the database is restored at location b, the users will be able to simply login...
Thanks
GYKThis should help
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q246133&
Ray Higdon MCSE, MCDBA, CCNA
--
"GYK" <anonymous@.discussions.microsoft.com> wrote in message
news:40A125DF-6C22-48DA-9780-DA7A7ED52B5E@.microsoft.com...
> Hi All,
> I have a user database with 20 users. I have to transfer this database to
some other location (location B) with the user and login, so that others
would be able to login (assuming i have provided them username and pwd for
logging). I can take the backup of the database, which can be restored at
location b, in which the users will also be available.
> Now my question is
> Is there a mechansim to copy sql server logins also, such that, when the
database is restored at location b, the users will be able to simply
login...
> Thanks
> GYK

Copying reports to server

What is the best/fastest way of copying lots of user developed reports from
one server to the other.
TIA..Copy the RDL if you have access to it.
"sqlster" <trisha@.nospam.nospam> wrote in message
news:2DE69E99-C99B-4844-8B46-805E0F265E4E@.microsoft.com...
> What is the best/fastest way of copying lots of user developed reports
> from
> one server to the other.
> TIA..|||No, this does not work. At the server the RDL does not exist as a file, it
is stored in the database. You have to either manually extract the RDL using
Report Manager or using scripting. For a lot of reports, scripting is best.
Search Books Online on the word scripting. Also, a variety of people have
posted about scripting this as well. It ships with a scripting example for
publishing reports, need to have a script to extract the reports and then
you are good to go.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Patrick Allmond" <patrick24601@.yahoo.com> wrote in message
news:Y_pIe.65331$5N3.3008@.bgtnsc05-news.ops.worldnet.att.net...
> Copy the RDL if you have access to it.
> "sqlster" <trisha@.nospam.nospam> wrote in message
> news:2DE69E99-C99B-4844-8B46-805E0F265E4E@.microsoft.com...
>> What is the best/fastest way of copying lots of user developed reports
>> from
>> one server to the other.
>> TIA..
>|||Can anyone point me in the direction of a sample script ?
I know reports can be published using the rsutility, but i dont know of any
equivalent to extract or copy the rdl files once they have been uploaded.
Regards
Kamlesh
"Bruce L-C [MVP]" wrote:
> No, this does not work. At the server the RDL does not exist as a file, it
> is stored in the database. You have to either manually extract the RDL using
> Report Manager or using scripting. For a lot of reports, scripting is best.
> Search Books Online on the word scripting. Also, a variety of people have
> posted about scripting this as well. It ships with a scripting example for
> publishing reports, need to have a script to extract the reports and then
> you are good to go.
>
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "Patrick Allmond" <patrick24601@.yahoo.com> wrote in message
> news:Y_pIe.65331$5N3.3008@.bgtnsc05-news.ops.worldnet.att.net...
> > Copy the RDL if you have access to it.
> >
> > "sqlster" <trisha@.nospam.nospam> wrote in message
> > news:2DE69E99-C99B-4844-8B46-805E0F265E4E@.microsoft.com...
> >> What is the best/fastest way of copying lots of user developed reports
> >> from
> >> one server to the other.
> >>
> >> TIA..
> >
> >
>
>

Saturday, February 25, 2012

Copying .mdf and .ldf files bewteen servers

We have a user at work at enjoys stopping SQL Server 7 and 2000 machines and
copying the .mdf and .ldf files from one server to another. He then simply
restarts the production server and re-attaches the database to the new
server.
I have asked this employee to either backp the DB to disk and copy this to
another server or use the sp_detach command and copy file then re-attach.
What are the ramifications of doing a simple .mdf and .ldf copy?
We have a number of MSDE databases as well. Is this acceptable for these?
Perhaps the reason I am getting the SQL-DMO the name 'dbo' was not found in
the users collection is because of these types of copies.
Thanks
--
...david
http://www.micro-mess.com
http://www.va-mustang.com
If you wish to reply to me personally, please remove
the "underline" from scandal_123@.cox.net. The is done to avoid SPAM!I agree with you that backup/restore is probably a better approach. This
eliminates the need to stop the SQL Server service on the source server.
Although sp_attach_db often works without sp_detach_db, the documentation
clearly states that it should only be used with database files detached with
sp_detach_db.
After attaching or restoring databases from another server, you can run
sp_changedbowner to correct the login mapping for the 'dbo' user. This will
correct the DMO 'dbo' user problem. You may also need to run
sp_change_users_login to correct the login/user mapping for other users.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"DavidM" <scandal_123@.cox.net> wrote in message
news:%23I8gmHdxDHA.1364@.tk2msftngp13.phx.gbl...
> We have a user at work at enjoys stopping SQL Server 7 and 2000 machines
and
> copying the .mdf and .ldf files from one server to another. He then simply
> restarts the production server and re-attaches the database to the new
> server.
> I have asked this employee to either backp the DB to disk and copy this to
> another server or use the sp_detach command and copy file then re-attach.
> What are the ramifications of doing a simple .mdf and .ldf copy?
> We have a number of MSDE databases as well. Is this acceptable for these?
> Perhaps the reason I am getting the SQL-DMO the name 'dbo' was not found
in
> the users collection is because of these types of copies.
> Thanks
>
> --
> ...david
> http://www.micro-mess.com
> http://www.va-mustang.com
> If you wish to reply to me personally, please remove
> the "underline" from scandal_123@.cox.net. The is done to avoid SPAM!
>

Copying .mdf and .ldf files bewteen servers

We have a user at work at enjoys stopping SQL Server 7 and 2000 machines and
copying the .mdf and .ldf files from one server to another. He then simply
restarts the production server and re-attaches the database to the new
server.
I have asked this employee to either backp the DB to disk and copy this to
another server or use the sp_detach command and copy file then re-attach.
What are the ramifications of doing a simple .mdf and .ldf copy?
We have a number of MSDE databases as well. Is this acceptable for these?
Perhaps the reason I am getting the SQL-DMO the name 'dbo' was not found in
the users collection is because of these types of copies.
Thanks
...david
http://www.micro-mess.com
http://www.va-mustang.com
If you wish to reply to me personally, please remove
the "underline" from scandal_123@.cox.net. The is done to avoid SPAM!I agree with you that backup/restore is probably a better approach. This
eliminates the need to stop the SQL Server service on the source server.
Although sp_attach_db often works without sp_detach_db, the documentation
clearly states that it should only be used with database files detached with
sp_detach_db.
After attaching or restoring databases from another server, you can run
sp_changedbowner to correct the login mapping for the 'dbo' user. This will
correct the DMO 'dbo' user problem. You may also need to run
sp_change_users_login to correct the login/user mapping for other users.
Hope this helps.
Dan Guzman
SQL Server MVP
"DavidM" <scandal_123@.cox.net> wrote in message
news:%23I8gmHdxDHA.1364@.tk2msftngp13.phx.gbl...
quote:

> We have a user at work at enjoys stopping SQL Server 7 and 2000 machines

and
quote:

> copying the .mdf and .ldf files from one server to another. He then simply
> restarts the production server and re-attaches the database to the new
> server.
> I have asked this employee to either backp the DB to disk and copy this to
> another server or use the sp_detach command and copy file then re-attach.
> What are the ramifications of doing a simple .mdf and .ldf copy?
> We have a number of MSDE databases as well. Is this acceptable for these?
> Perhaps the reason I am getting the SQL-DMO the name 'dbo' was not found

in
quote:

> the users collection is because of these types of copies.
> Thanks
>
> --
> ...david
> http://www.micro-mess.com
> http://www.va-mustang.com
> If you wish to reply to me personally, please remove
> the "underline" from scandal_123@.cox.net. The is done to avoid SPAM!
>

Friday, February 24, 2012

Copy users between databases

Hello All,
I used DTS to copy one database to a blank database for a backup of the
database. A duplicate database.
How do I copy over the user logins to the new database.
This did not happen with DTS.
The databases are on the same instance of SQL.
Any help appreciated.
Thanks,
Terry
tgwillett@.cox.netRun this on the database to autofix users
select 'exec sp_change_users_login ''Auto_Fix'', ''' + name + '''' from
sysusers
where name not in ('INFORMATION_SCHEMA', 'dbo', 'guest', 'public')
"Terry" wrote:

> Hello All,
> I used DTS to copy one database to a blank database for a backup of the
> database. A duplicate database.
> How do I copy over the user logins to the new database.
> This did not happen with DTS.
> The databases are on the same instance of SQL.
> Any help appreciated.
> Thanks,
> Terry
> tgwillett@.cox.net
>
>

Copy users between databases

Hello All,
I used DTS to copy one database to a blank database for a backup of the
database. A duplicate database.
How do I copy over the user logins to the new database.
This did not happen with DTS.
The databases are on the same instance of SQL.
Any help appreciated.
Thanks,
Terry
tgwillett@.cox.netThis is a pretty good article on it:
http://support.microsoft.com/defaul...kb;en-us;246133
Christian
"Terry" <tgwillett@.cox.net> wrote in message
news:r_62g.56456$gE.9859@.dukeread06...
> Hello All,
> I used DTS to copy one database to a blank database for a backup of the
> database. A duplicate database.
> How do I copy over the user logins to the new database.
> This did not happen with DTS.
> The databases are on the same instance of SQL.
> Any help appreciated.
> Thanks,
> Terry
> tgwillett@.cox.net
>

Copy users between databases

Hello All,
I used DTS to copy one database to a blank database for a backup of the
database. A duplicate database.
How do I copy over the user logins to the new database.
This did not happen with DTS.
The databases are on the same instance of SQL.
Any help appreciated.
Thanks,
Terry
tgwillett@.cox.netThis is a pretty good article on it:
http://support.microsoft.com/default.aspx?scid=kb;en-us;246133
Christian
"Terry" <tgwillett@.cox.net> wrote in message
news:r_62g.56456$gE.9859@.dukeread06...
> Hello All,
> I used DTS to copy one database to a blank database for a backup of the
> database. A duplicate database.
> How do I copy over the user logins to the new database.
> This did not happen with DTS.
> The databases are on the same instance of SQL.
> Any help appreciated.
> Thanks,
> Terry
> tgwillett@.cox.net
>