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 |
|
cipriani1984
Constraint Violating Yak Guru
304 Posts |
Posted - 2009-09-22 : 07:16:53
|
| Hi,Im trying to run the following:declare @count1 varchar(max), @count2 varchar(max)SET @count1 = select count(*) from purchaseSET @count2 = select max(purchase_count) from timestamptablegetting error for setting values count1 and 2.How would I go about setting those values to what i want from the 2 tables?Thanks |
|
|
cipriani1984
Constraint Violating Yak Guru
304 Posts |
Posted - 2009-09-22 : 07:20:20
|
fixed it myself :)quote: Originally posted by cipriani1984 Hi,Im trying to run the following:declare @count1 varchar(max), @count2 varchar(max)SET @count1 = select count(*) from purchaseSET @count2 = select max(purchase_count) from timestamptablegetting error for setting values count1 and 2.How would I go about setting those values to what i want from the 2 tables?Thanks
|
 |
|
|
cipriani1984
Constraint Violating Yak Guru
304 Posts |
Posted - 2009-09-22 : 07:38:22
|
actually no i didnt lolAny help please?quote: Originally posted by cipriani1984 fixed it myself :)quote: Originally posted by cipriani1984 Hi,Im trying to run the following:declare @count1 varchar(max), @count2 varchar(max)SET @count1 = select count(*) from purchaseSET @count2 = select max(purchase_count) from timestamptablegetting error for setting values count1 and 2.How would I go about setting those values to what i want from the 2 tables?Thanks
|
 |
|
|
sanoj_av
Posting Yak Master
118 Posts |
Posted - 2009-09-22 : 07:55:47
|
| Select @count1 = count(*) from purchase |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-09-22 : 09:32:50
|
quote: Originally posted by cipriani1984 Hi,Im trying to run the following:declare @count1 varchar(max), @count2 varchar(max)SET @count1 = select count(*) from purchaseSET @count2 = select max(purchase_count) from timestamptablegetting error for setting values count1 and 2.How would I go about setting those values to what i want from the 2 tables?Thanks
It should bedeclare @count1 varchar(max), @count2 varchar(max)SET @count1 = (select count(*) from purchase)SET @count2 = (select max(purchase_count) from timestamptable)MadhivananFailing to plan is Planning to fail |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2009-09-22 : 13:35:46
|
Actually, are your variables supposed to by VARCHAR or should they be INT?declare @count1 varchar(max), @count2 varchar(max)SET @count1 = CAST((select count(*) from purchase) AS VARCHAR(10))SET @count2 = CAST((select max(purchase_count) from timestamptable) AS VARCHAR(10))-- Ordeclare @count1 INT, @count2 INTSET @count1 = (select count(*) from purchase)SET @count2 = (select max(purchase_count) from timestamptable) |
 |
|
|
|
|
|
|
|