Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Darkmatter5
Starting Member
17 Posts |
Posted - 2012-06-04 : 17:19:43
|
Here's my basic code:USE [byrndb]GOIF OBJECT_ID('spDeleteCounty') IS NOT NULL DROP PROCEDURE spDeleteCountyGOCREATE PROC [dbo].[spDeleteCounty] @ID intASIF NOT EXISTS (SELECT * FROM surveys WHERE CountyID = @ID)BEGIN DELETE FROM counties WHERE CountyID = @IDENDELSEBEGIN DECLARE @CountyName varchar(50) = (SELECT counties.CountyName FROM surveys JOIN counties ON counties.CountyID = surveys.CountyID WHERE surveys.CountyID = @ID) DECLARE @Count int = (SELECT counties.CountyName FROM surveys JOIN counties ON counties.CountyID = surveys.CountyID WHERE surveys.CountyID = @ID) PRINT 'The selected county of "' & @CountyName & '" is associated with ' & @Count & ' survey(s). Disassociate the county with those surveys prior to attempting to delete it.'END I'm wanting to get two items and output them in a print. When I try and execute I get the following error."Msg 402, Level 16, State 1, Procedure spDeleteCounty, Line 20The data types varchar and varchar are incompatible in the '&' operator."Any thoughts? |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2012-06-05 : 05:26:08
|
Why are you printing them? Just return values of both the variables to the client and let it displays the messageMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|