hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : MSSQL - Setting a SQL Select command as a variable
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

MSSQL - Setting a SQL Select command as a variable

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 05-21-2007, 04:43 PM
Goldfiles Goldfiles is offline
Web Hosting Guru
 
Join Date: Jun 2002
Posts: 264

MSSQL - Setting a SQL Select command as a variable


I want to run a 'SELECT' command on my database that will output a small table of data. About 3 rows and 3 columns. Can I set that 'SELECT' command to a @variable for later usage?

Something Like This? (doesn't work)
PHP Code:
DECLARE @StatusTable varchar(100)

SET @variable SELECT idnamephone
  FROM user_table 
This is in MSSQL, btw. I'm new to MSSQL and I'm trying to figure out how I can set this table of data to a @variable so I can use it in a message later on in my code.

__________________
TextAdMarket - http://www.TextAdMarket.com
Supply & Demand Advertising

Reply With Quote


Sponsored Links
  #2  
Old 05-22-2007, 04:20 AM
plumsauce plumsauce is offline
******* Unleaded
 
Join Date: Feb 2004
Posts: 3,788
Much better to do it with a stored procedure. Look in books online.

__________________
edgedirector.com
managed dns global failover and load balance (gslb)
exactstate.com
uptime report for webhostingtalk.com

Reply With Quote
  #3  
Old 05-22-2007, 08:41 AM
Goldfiles Goldfiles is offline
Web Hosting Guru
 
Join Date: Jun 2002
Posts: 264
I want to include it in an email message later, like this:

PHP Code:
SELECT @msg Char(10) + Char(13)
SELECT @msg = @msg 'Message Goes Here' Char(10) + Char(13)
EXEC spSendEmail @msg'email@domain.com''Subject Line' 
Any thoughts on how I can include a small table of data in an email message?

__________________
TextAdMarket - http://www.TextAdMarket.com
Supply & Demand Advertising

Reply With Quote
Sponsored Links
  #4  
Old 05-22-2007, 11:07 AM
DatabaseMart DatabaseMart is offline
WHT Addict
 
Join Date: Feb 2005
Location: Galveston, TX USA
Posts: 101
You can use SQL Server XML technology. Please see http://www.15seconds.com/issue/001102.htm.

__________________
winservermart.com
Dedicated Windows and MSSQL Hosting Specialist

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Strategies to Reduce Operating Costs, Avoid Email Blacklisting and Improve Deliverability Webinars 2013-05-15 11:27:46
WHD.india 2013 Web Hosting Events 2013-04-24 18:18:58
Jakarta Web Hosting Introduces MSSQL Server 2012 Hosting Services Web Hosting News 2012-04-23 11:18:07
Web Host iomart Wins UK Office Supply Provider Office2Office Virtualization Contract Web Hosting News 2012-02-10 13:45:11
The Variable Requirements of Data Center Vendor Selection: Andrew Schaap of Digital Realty Trust Web Hosting News 2011-09-27 15:06:29


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?