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 |
|
desikankannan
Posting Yak Master
152 Posts |
Posted - 2011-12-23 : 01:14:10
|
| Hi,i wants to add primary key with stringexample1a1b1cbelow i built but it holds duplication value select N_WalkerId as id ,v_name as name,'walkers' as usertype,case B_Status when 1 then 'Active' else 'InActive' End As status from tblWalkerDetails where V_name like '%" + a + "%' union select n_ownerid as id,v_name as name ,'pet' as usertype,case B_Status when 1 then 'Active' else 'InActive' End As status from tblPetOwner where V_Name like '%" + a + "%' union select N_PetId as id, v_petname as name ,'client' as usertype,case B_Status when 1 then 'Active' else 'InActive' End As status from tblpetdetails where V_PetName like '%a'looking for replyDesikankannan |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-23 : 01:18:12
|
| just use ALTER TABLE <tablename> ADD CONSTRAINT...to add the PKso far as the string values are unique it wont cause any issues------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
desikankannan
Posting Yak Master
152 Posts |
Posted - 2011-12-23 : 01:36:32
|
iam using auto search option it repeats duplicate that why i want to concoct example1 wakers1 owners1 clientits come 3 times 1 quote: Originally posted by visakh16 just use ALTER TABLE <tablename> ADD CONSTRAINT...to add the PKso far as the string values are unique it wont cause any issues------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Desikankannan |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-23 : 01:57:51
|
| but concatenated values is unique right? then it wont cause any issues------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
desikankannan
Posting Yak Master
152 Posts |
Posted - 2011-12-23 : 02:07:59
|
but i don't how to concoctedi need to 1w,1c,1oquote: Originally posted by visakh16 but concatenated values is unique right? then it wont cause any issues------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Desikankannan |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-23 : 03:14:38
|
| just do likecast(col1 as varchar(10)) + col2to concatenate bothe their values------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|