Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

variable Scoping Expand / Collapse
Author
Message
Posted Thursday, February 6, 2014 10:50 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, September 9, 2014 3:27 AM
Points: 1,893, Visits: 2,329
Hi all,

DECLARE @batchSize INT
Declare @siteid nchar(3)
DECLARE @Instanceid nchar(3)


set @siteid = '002'
SET @InstanceId = '001'

SELECT @batchSize = CAST(ConfigurationValue AS Int)
from ApplicationConfiguration
where ConfigurationDescription='SyncBatchSize' and InstanceId = @InstanceID and SiteiD = @SIteID

select @batchsize
-- Result NULL

SELECT @batchSize = CAST(ConfigurationValue AS Int)
from ApplicationConfiguration
where ConfigurationDescription='SyncBatchSize' and InstanceId = '001' and SiteiD = '002'

select @batchsize
-- Result 501

While passing variable I am gettign NULL in result while when I pass static value then it gives me result as 501, why this is happening...



_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1539009
Posted Friday, February 7, 2014 12:25 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 8:29 AM
Points: 12,945, Visits: 10,716
Maybe because you switched values in your example.



How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1539027
Posted Friday, February 7, 2014 1:06 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, September 9, 2014 3:27 AM
Points: 1,893, Visits: 2,329
Koen Verbeeck (2/7/2014)
Maybe because you switched values in your example.


ohhh I typed incorrectly here... but after make correction also its not working



_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1539034
Posted Friday, February 7, 2014 1:32 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 3:25 AM
Points: 3,417, Visits: 5,328
With DDL for TABLE ApplicationConfiguration, specifically data types for InstanceId and SiteiD, someone might be able to propose a hypothesis.


My mantra: No loops! No CURSORs! No RBAR! Hoo-uh!

My thought question: Have you ever been told that your query runs too fast?

My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.


Need to UNPIVOT? Why not CROSS APPLY VALUES instead?
Since random numbers are too important to be left to chance, let's generate some!
Learn to understand recursive CTEs by example.
Splitting strings based on patterns can be fast!
Post #1539040
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse