Front Office Football Central  

Go Back   Front Office Football Central > Archives > FOFC Archive
Register FAQ Members List Calendar Mark Forums Read Statistics

Reply
 
Thread Tools
Old 06-04-2009, 07:39 AM   #1
Ben E Lou
Morgado's Favorite Forum Fascist
 
Join Date: Oct 2000
Location: Greensboro, NC
MS SQL 2005 Questions

1. How do I create a script for someone that requires them to enter a parameter (a date)?

2. Is it possible to create a SELECT INTO query that pulls from a db on one server and writes to a db on another? If so, how?
__________________
The media don't understand the kinds of problems and pressures 54 million come wit'!

Ben E Lou is offline   Reply With Quote
Old 06-04-2009, 08:58 AM   #2
cartman
Death Herald
 
Join Date: Nov 2000
Location: Le stelle la notte sono grandi e luminose nel cuore profondo del Texas
Quote:
Originally Posted by Ben E Lou View Post
1. How do I create a script for someone that requires them to enter a parameter (a date)?

2. Is it possible to create a SELECT INTO query that pulls from a db on one server and writes to a db on another? If so, how?

For #1, you create a stored procedure that uses a variable. Here's an example:

Code:
create procedure sp_example @input datetime /* or whatever datatype the input is going to be */ as select blah from table where variabletable = @input go

If you need multiple inputs, separate them with a comma. The @ symbol is what declares the variable. So to run it, you capture the date, and then pass to SQL Server 'sp_example captureddate' and it will use the date in the query.

For #2, it is possible, but a bit more complicated. You have to use a fully qualified name for the tables, and the account you are using has to have permissions on both database, and the second server has to be set up as a linked server on the first server. The format of a fully qualified name is [server].[database].[schema].[table], ie. [server1].[BensTable].[dbo].[draftclass]. So instead of 'select * from draftclass', you'd use 'select * from [server1].[BensTable].[dbo].[draftclass]. The brackets are required.

Ping me if you need more in depth info.
__________________
Thinkin' of a master plan
'Cuz ain't nuthin' but sweat inside my hand
So I dig into my pocket, all my money is spent
So I dig deeper but still comin' up with lint
cartman is offline   Reply With Quote
Old 06-04-2009, 09:07 AM   #3
lordscarlet
Pro Starter
 
Join Date: Oct 2005
Location: Washington, DC
1. You want to create a "Stored Procedure" if I am understanding the question correctly. Presumably you want it to return a set of rows? If just a value, you may want a function. If I'm completely misunderstanding, it may be something else. SQL Server Stored Procedures

2. Between servers? Hm. I've never done it, but this seems to indicate you can: SQL Server 2005 : Access Tables / Entities across Servers. « Script(s)
__________________
Sixteen Colors ANSI/ASCII Art Archive

"...the better half of the Moores..." -cthomer5000
lordscarlet is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Forum Jump


All times are GMT -5. The time now is 07:51 AM.



Powered by vBulletin Version 3.6.0
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.